// JavaScript Document
$(document).ready(function () {
    //Search autofill
    $('.formAutoFill').each(function () {
        // Bind focus event to inputs & textareas
        $(this).find('input[type="text"],textarea').focus(function () {
            if ($(this).val() == $(this).attr('title')) $(this).val('');
            $(this).css({ fontWeight: 'normal' });
        });

        // Bind blur event to inputs & texteareas
        $(this).find('input:text,textarea').blur(function () {
            if (!$(this).val()) $(this).val($(this).attr('title'));
            if ($(this).val() == $(this).attr('title')) {
                if ($(this).parent().parent().find('label[for="' + $(this).attr('id') + '"] strong').length) $(this).css({ fontWeight: 'bold' });
            }
        });

        // Hide labels and auto-fill inputs
        $(this).find('input[type="text"],textarea').each(function () {
            var myLabel = $(this).parent().parent().find('label[for="' + $(this).attr('id') + '"]:not(.formHide)');
            if (!myLabel.find('input[type="text"]').length) myLabel.addClass('formLabelHide');
            $(this).val($(this).attr('title'));
            if (myLabel.find('strong').length) $(this).css({ fontWeight: 'bold' });
        });
    });
    $('#selectAllStoresContainer').click(function (e) {
        e.stopPropagation();
        $(this).toggleClass('opened');
        $(this).find('ul').slideToggle(200);
    });
    $('body').click(function (e) {
        if ($('#selectAllStoresContainer ul').is(':visible') == true) {
            $('#selectAllStoresContainer').toggleClass('opened');
            $('#selectAllStoresContainer ul').slideUp(200);
        }
        if ($('#authenticatoinTab').is(':visible') == true) {
            $('#authenticatoinTab').slideUp(200);
        }
        if ($('#ContentPlaceHolder1_DeliveryPopUpDiv').is(':visible') == true && e.target.className != "deliveryPopupText" && e.target.className != "deliveryPopHead") {
            $('#ContentPlaceHolder1_DeliveryPopUpDiv').hide();
        }
        if ($('#ContentPlaceHolder1_BrowseControl_DeliveryPopUpDiv').is(':visible') == true && e.target.className != "deliveryPopupText" && e.target.className != "deliveryPopHead") {
            $('#ContentPlaceHolder1_BrowseControl_DeliveryPopUpDiv').hide();
        }
        if ($('#ContentPlaceHolder1_FinalPage_DeliveryPopUpDiv').is(':visible') == true && e.target.className != "deliveryPopupText" && e.target.className != "deliveryPopHead") {
            $('#ContentPlaceHolder1_FinalPage_DeliveryPopUpDiv').hide();
        }
        if ($('#ContentPlaceHolder1_outStockDiv').is(':visible') == true && e.target.className != "ImagPopUp2 outStockPopStyle" && e.target.className != "outStockDefault" && e.target.className != "outStockerrmsg" && e.target.className != "txtOutStockemailid" && e.target.className != "butOutStocksubmit" && e.target.className != "outStockHead") {
            $('#ContentPlaceHolder1_outStockDiv').hide();
        }
        if ($('#ContentPlaceHolder1_FinalPage_outStockDiv').is(':visible') == true && e.target.className != "ImagPopUp2 outStockPopStyle" && e.target.className != "outStockDefault" && e.target.className != "outStockerrmsg" && e.target.className != "txtOutStockemailid" && e.target.className != "butOutStocksubmit" && e.target.className != "outStockHead") {
            $('#ContentPlaceHolder1_FinalPage_outStockDiv').hide();
        }

        if ($('#ContentPlaceHolder1_FinalControlValuesHolder_ctl00_FDPMainSection_divShippablePopup').is(':visible') == true && e.target.className != "ImagPopUp2 notShippableStyle" && e.target.className != "NotShoppableContent") {
            $('#ContentPlaceHolder1_FinalControlValuesHolder_ctl00_FDPMainSection_divShippablePopup').hide();
        }

        //return false;
    });
    $('#authenticatoinTab').click(function (e) {
        e.stopPropagation();
    });
    $('#selectAllStoresContainer li').hover(function () {
        if ($.browser.msie) { $(this).toggleClass('opened'); }
    }, function () {
        if ($.browser.msie) { $(this).toggleClass('opened'); }
    });
    $('#selectAllStoresContainer li').click(function (e) {
        $('#selectAllStoresContainer span').html($(this).html());
        $(this).find('ul').slideToggle(200);
    });
    function getSearchStoreValue() {
        return $("#selectAllStoresContainer").find("span.value").find("span").find("span").html();
    }
    /* $('#lnkSignin').click(function (e) {
    e.stopPropagation();
    $('#authenticatoinTab').slideToggle(200);
    return false;
    });*/
    // $('.login form, .signUp form').validate();
    $("#authenticatoinTab").tabs();
   // $('.buyNow a').html('');
    //$('.addCartBut a').html('Add to Cart');


});
