﻿$(document).ready(function () {
    var scrollTime = 800;

    $('a').click(function (e) {
        if ($(this).attr('href').substr(0, 1).indexOf("#") != -1) {
            if ($(this).attr('href') != "#") {
                e.preventDefault();
                var negativeTop = 0;

                if ($(this).attr('href') != "#Home") negativeTop = -110;

                var targetPos = $($(this).attr('href')).offset()

                $('html, body').stop().animate({ 'scrollTop': (targetPos.top + negativeTop) + 'px' }, scrollTime);
            } else {
                $('html, body').stop().animate({ 'scrollTop': '0px' }, scrollTime);
            }
        }
    });
});

/*FORM FUNCTIONS*/
function ClearRefillFields() {
    $.each($('input[type="text"]'), function (i, v) {
        v.initialValue = $(v).attr('value');
    });
    $.each($('textarea'), function (i, v) {
        v.initialValue = $(v).attr('value');
    });

    $('input[type="text"]').focus(function () {
        if ($(this).attr('value') == this.initialValue) $(this).attr('value', '');
        $('input[type="text"]').blur(function () {
            if ($(this).attr('value') == '') $(this).attr('value', this.initialValue);
        });
    });
    $('textarea').focus(function () {
        if ($(this).attr('value') == this.initialValue) $(this).attr('value', '');
        $('textarea').blur(function () {
            if ($(this).attr('value') == '') $(this).attr('value', this.initialValue);
        });
    });
}


