﻿/**
* Adds class to the input and label on focus
*/
$(document).ready(function() {
    $('input[type="text"], input[type="password"], select, textarea, input[type="checkbox"]').focus(function() {
        if ($(this).attr('type') != 'checkbox') {
            $(this).addClass('focus').prevAll('label:first').addClass('focus');
        }
        else {
            $(this).next('label').addClass('focus');
        }
    });

    $('input[type="text"], input[type="password"], select, textarea, input[type="checkbox"]').blur(function() {
        $('input[type="text"], input[type="password"], select, label, textarea, input[type="checkbox"]').removeClass('focus');
    });
});

/**
* Hide asp.net validators
*/
function HideValidators() {
    if (window.Page_Validators) {
        for (var i = 0; i < Page_Validators.length; i++) {
            var vValidator = Page_Validators[i];
            vValidator.isvalid = true;
            ValidatorUpdateDisplay(vValidator);
        }

        for (var i = 0; i < Page_ValidationSummaries.length; i++) {
            var summary = Page_ValidationSummaries[i];
            summary.style.display = "none";
        }

        $('.success, .error').hide();
    }
}

/**
* Add Hash To Url
*/
function addHash(hash) {
    //pageTracker._trackPageview('/market/' + hash);
    if ('#' + hash == window.location.hash) {
        window.location.hash = new String((new Date().getMilliseconds()));
    }
    window.location.hash = hash;
}