    $(document).ready(
    function () {
        $("#storeAlphabeticalList").click(function () {
            $("#categorialList").hide();
            $("#brandSearchList").hide();
            $("#alphabeticalList").show();
            $("#storeAlphabeticalList").parent().addClass("active");
            $("#storeCategorialList").parent().removeClass("active");
            $("#storeBrandSearch").parent().removeClass("active");
        });

    });
    $(document).ready(
    function () {
        $("#storeCategorialList").click(function () {
            $("#alphabeticalList").hide();
            $("#brandSearchList").hide();
            $("#categorialList").show();
            $("#storeAlphabeticalList").parent().removeClass("active");
            $("#storeCategorialList").parent().addClass("active");
            $("#storeBrandSearch").parent().removeClass("active");

        });
    });
    $(document).ready(
    function () {
        $("#storeBrandSearch").click(function () {
            $("#alphabeticalList").hide();
            $("#categorialList").hide();
            $("#brandSearchList").show();
            $("#storeAlphabeticalList").parent().removeClass("active");
            $("#storeCategorialList").parent().removeClass("active");
            $("#storeBrandSearch").parent().addClass("active");
        });
    });


    $(document).ready(
    function () {
        if (getParameterByName("search") != '') {
            $("#alphabeticalList").hide();
            $("#categorialList").hide();
            $("#brandSearchList").show();
            $("#brandSearchList #brandsearchinput").val(getParameterByName("search"));
            $("#storeAlphabeticalList").parent().removeClass("active");
            $("#storeCategorialList").parent().removeClass("active");
            $("#storeBrandSearch").parent().addClass("active");
        }
        else {
            $("#categorialList").hide();
            $("#brandSearchList").hide();
            $("#alphabeticalList").show();
            $("#storeAlphabeticalList").parent().addClass("active");
            $("#storeCategorialList").parent().removeClass("active");
            $("#storeBrandSearch").parent().removeClass("active");
        }
    });


function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}


jQuery.fn.autoscrollTo = function (selector) {
    $('html,body').animate({ scrollTop: $(selector).offset().top },500);
}



$(document).ready(function () {

    $('.standardForm .btnSubmit').click(function () {
        //if ($(this).closest('.standardForm').find(".errorList li").size() > 0)
            $(this).autoscrollTo($(this).closest('.standardForm'));
    });

    $('.standardForm .errorList label').live('click', function (event) {
        var targetTag = $('#' + $(this).attr('for'));
        var targetTagName = $(targetTag).get(0).tagName.toLowerCase();
        if (targetTagName.toLowerCase() == 'input' && ($(targetTag).attr('type') == 'radio' || $(targetTag).attr('type') == 'checkbox')) {
            event.preventDefault();
            $(targetTag).focus();
        }
    });

    var checkedValue = $('.giftCertificateValueChooser input[type=radio]:checked').val();
    if (!checkedValue) {
        //$(argObj).find('input[type=radio]:first').attr('checked', 'checked');
        $('.giftCertificateValueChooser input[type=radio]:first').attr('checked', 'checked');
    }
    grayOutUncheckedGiftCertificateValue('.giftCertificateValueChooser');
    $('.giftCertificateValueChooser input[type=radio]').click(function () {
        grayOutUncheckedGiftCertificateValue('.giftCertificateValueChooser');
    });
});


function grayOutUncheckedGiftCertificateValue(argObj) {
    $(argObj + ' input[type=radio]').each(function () {
         var checkedValue = $('input[name=' + $(this).attr('name') + ']:checked').val();
        if ($(this).val() == checkedValue)//checked radio
        {
            $(this).closest('.checkState').removeClass('unchecked').addClass('checked').find('select, input[type=text]').removeAttr('disabled');
        }
        else {
            $(this).closest('.checkState').removeClass('checked').addClass('unchecked').find('select, input[type=text]').attr('disabled', 'disabled');
        }
    });
}


