

function OpenRightNowChat(chatURL) {
    var chatWindow = window.open(chatURL, "mywindow", "width=360,height=515,top=300,left=500");   
}

//TODO:Need top refine all the hideProductShadesDIV DIV methods into alert single method

//Function to hide the product shades div when no colors are mapped to a product
//Called from the cs file e.g. for Tools
function fnHideProductShadesDIV() {  
    document.getElementById("productshades").style.display = "none";
    document.getElementById("divSwatchMain").style.display = "none";
    document.getElementById("selectedproductname").style.display = "none";
}

//TODO:Need to collate hidetabs into a single function by passing the div and li dynamically
//For hiding the tabs in the Product Details page
function fnHideAwardsTab()
{
    document.getElementById("tabs-5").style.display = "none";
    document.getElementById("litabs5").style.display = "none";
}

function fnHideSimilarProductsTab() {
    document.getElementById("tabs-2").style.display = "none";
    document.getElementById("litabs2").style.display = "none";
}

function fnHideCompleteTheLookTab() {
    document.getElementById("tabs-3").style.display = "none";
    document.getElementById("litabs3").style.display = "none";
}
function fnHideFAQTab() {
    document.getElementById("tabs-6").style.display = "none";
    document.getElementById("litabs6").style.display = "none";
}
function fnHowToApplyTab() {
    document.getElementById("tabs-4").style.display = "none";
    document.getElementById("litabs4").style.display = "none";
}

function fnApplyDIVBackGroundImage(controlId, imagePath, others) {    
    var control = document.getElementById(controlId);
    //control.style.background = "background-image: url('" + imagePath + "') " + others + " ";
    control.style.background = "url(" + imagePath + ") " + others + "";
   // control.style.background = "url(" + imagePath + ")" + others + " ";
}

function fnApplyDIVClass(controlId, className) {
   
    var control = document.getElementById(controlId);
    if (control == null)
        return;
    control.className = className;
    
}
function fnApplyHBackGroundImage(controlId, imagePath, others) { 
    var control = document.getElementById(controlId);
    control.style.background = "background-image: url('" + imagePath + "') " + others + " ";
}

function fnApplyHTagBackGroundImage(controlId, imagePath, others, innerText) {

    var control = document.getElementById(controlId);
    control.style.background = "background-image: url('" + imagePath + "') " + others + " ";

    if (innerText != null && innerText != "") {
        control.innerText = innerText;
    }
}
function fnAddInnerText(controlId, innerText) 
{
    
    var control = document.getElementById(controlId);
    if (innerText != null && innerText != "") 
     {
          control.innerText = innerText;
     }
 }
 function fnOpenProductMontage(targetPath) 
 {
          
     window.open(targetPath, 'PAwMontage', config = 'height=410,width=650, top=190, left=160, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no,titlebar=no directories=no, status=no');


 }
 function fnSpecialLinkMouseOver(controlId, imagePath)
  {     
     var control = document.getElementById(controlId);
     control.style.background = "url('" + imagePath + "')  ";  
control.style.display = "block";  
 }

 function fnSpecialLinkOnClick(controlId, imagePath) {
     
                
     var control = document.getElementById(controlId);     
     control.style.background = "background-image: url('" + imagePath + "')  ";
     control.onmouseout = null;

 }

 //Function to hide the filters
 function fnHideFilters(controlID) {
   
     var control = document.getElementById(controlID);
     if (control == null)
         return;
     control.style.display = "none";
 }
 //Function to show the add to cart and save for later success  messages to the user.
  var gloSetTop = 0; //colorMatch Results. 
 function showCurrentPopupMyCG(clientId, displayText, msgLink, linkText) {
     
     if ($(clientId).length == 1);
     {
         $(clientId).addClass('mobilepopup');
         obj = document.getElementById(clientId);
         if (!obj)
             return;
         if (msgLink.length > 0 && linkText.length > 0)
             displayText = displayText.replace("{0}", "<a " + "href='" + msgLink + "'>" + linkText + "</a>");
         $('#' + clientId).closest('.section').append('<div id="cgOverlayContentContainer">\
                                          <div id="cgOverlayContent">\
                                                    <div id="cgOverlayTop"><img border="0" src="/images/popup/mobileTop.png"></div>\
                                                <div id="cgOverlayBodyContainer">\
                                                            <div align="right" id="close"><img src="/images/popup/icon_close.gif"></div>\
                                                            <div id="cgOverlayBody" class="cgOverlayBodyCls"></div>\
                                                </div>            \
                                                <div id="cgOverlayBottom"><img src="/images/popup/mobileBottom.png"></div>\
                                          </div></div>');
         if (document.getElementById("cgOverlayBody") == null)
             return;
         $("#cgOverlayBody").html(displayText);
         
         var curleft = 0, curtop = 0, width=0;
         clientId = "#" + clientId;
       
         obj = $(clientId);
         var offset = obj.position();
         curleft = offset.left;
         curtop = offset.top;         
         width = parseInt($(clientId).width());
         var widthval;
         if ($.browser.msie) {
             widthval = curleft + (width / 2);
         } else {
             widthval = curleft + (width / 2);
         }       

         $('#cgOverlayContentContainer').show();
         document.getElementById('cgOverlayContentContainer').style.left = widthval + 'px';
        // $('#cgOverlayContentContainer').css({ "left": "'+curleft+'+px" }); 
         document.getElementById('cgOverlayContentContainer').style.top = curtop + 45 + 'px';
     }

     $('#cgOverlayBodyContainer #close').click(function() { $('#cgOverlayContentContainer').remove(); });
 }

 //Function to show the add to cart and save for later success  messages to the user.
 function showCurrentPopup(clientId, displayText, msgLink, linkText) {

     if ($(clientId).length == 1);
     {
         $(clientId).addClass('mobilepopup');
         obj = document.getElementById(clientId);
         if (!obj)
             return;
         if (msgLink.length > 0 && linkText.length > 0)
             displayText = displayText.replace("{0}", "<a " + "href='" + msgLink + "'>" + linkText + "</a>");
         $("body").append('<div id="cgOverlayContentContainer">\
                                          <div id="cgOverlayContent">\
                                                    <div id="cgOverlayTop"><img border="0" src="/images/popup/mobileTop.png" style="behavior:url(\'/images/iepngfix.htc\')"></div>\
                                                <div id="cgOverlayBodyContainer" style="behavior:url(\'/images/iepngfix.htc\')">\
                                                            <div align="right" id="close"><img src="/images/popup/icon_close.gif"></div>\
                                                            <div id="cgOverlayBody"></div>\
                                                </div>            \
                                                <div id="cgOverlayBottom"><img src="/images/popup/mobileBottom.png" style="behavior:url(\'/images/iepngfix.htc\')"></div>\
                                          </div></div>');
         if (document.getElementById("cgOverlayBody") == null)
             return;
         $("#cgOverlayBody").html(displayText);

         var curleft = 0, curtop = 0, width = 0;
         clientId = "#" + clientId;
         obj = $(clientId);
         var offset = obj.offset();
         curleft = offset.left;
         curtop = offset.top;
         width = parseInt($(clientId).width());
         var widthval;
         if ($.browser.msie) {
             widthval = curleft + (width / 2);
         } else {
             widthval = curleft + (width / 2);
         }



         $('#cgOverlayContentContainer').show();
         document.getElementById('cgOverlayContentContainer').style.left = widthval + 'px';
         // $('#cgOverlayContentContainer').css({ "left": "'+curleft+'+px" }); 
         document.getElementById('cgOverlayContentContainer').style.top = curtop - 105 + 'px';
     }

     $('#cgOverlayBodyContainer #close').click(function() { $('#cgOverlayContentContainer').hide(); });
 }

//Function to show the add to cart and save for later success  messages to the user only for Flipstick Page.
 function showCurrentPopupHTML(clientId, displayText, msgLink, linkText) {
//alert("client id"+clientId);
//alert("displayText"+displayText);
//alert("msgLink"+msgLink);
//alert("linkText"+linkText);
     if ($(clientId).length == 1)
     {
         $(clientId).addClass('mobilepopup');
         obj = document.getElementById(clientId);
	  obj="ctl00_ctl00_MainContent_cpShopProducts_btnAddtocart";
         if (!obj)
             return;
         if (msgLink.length > 0 && linkText.length > 0)
             displayText = "Item has been added to cart. Click <a href='" + msgLink + "'>" + linkText + "</a> to view it.";
         $("body").append('<div id="cgOverlayContentContainer">\
                                          <div id="cgOverlayContent">\
                                                    <div id="cgOverlayTop"><img border="0" src="/images/popup/mobileTop.png" style="behavior:url(\'/images/iepngfix.htc\')"></div>\
                                                <div id="cgOverlayBodyContainer" style="behavior:url(\'/images/iepngfix.htc\')">\
                                                            <div align="right" id="close"><img src="/images/popup/icon_close.gif"></div>\
                                                            <div id="cgOverlayBody"></div>\
                                                </div>            \
                                                <div id="cgOverlayBottom"><img src="/images/popup/mobileBottom.png" style="behavior:url(\'/images/iepngfix.htc\')"></div>\
                                          </div></div>');
         if (document.getElementById("cgOverlayBody") == null)
            return;
         $("#cgOverlayBody").html(displayText);

         var curleft = 0, curtop = 0, width = 0;
         //clientId = "#" + clientId;
         obj = $(clientId);
         var offset = obj.offset();
         curleft = offset.left;
         curtop = offset.top;
         width = parseInt($(clientId).width());
         var widthval;
         if ($.browser.msie) {
             widthval = curleft + (width / 2);
         } else {
             widthval = curleft + (width / 2);
         }



         $('#cgOverlayContentContainer').show();
         document.getElementById('cgOverlayContentContainer').style.left = widthval + 'px';
         // $('#cgOverlayContentContainer').css({ "left": "'+curleft+'+px" }); 
         document.getElementById('cgOverlayContentContainer').style.top = curtop - 105 + 'px';
     }

     $('#cgOverlayBodyContainer #close').click(function() { $('#cgOverlayContentContainer').hide(); });
 }


 //Function to hide any control
 function fnHideControl(controlID) {

     var control = document.getElementById(controlID);
     if (control == null)
         return;
     control.style.display = "none";
 }
 //Function to show control
 function fnShowControl(controlID) {

     var control = document.getElementById(controlID);
     if (control == null)
         return;
     control.style.display = "inline";
 }
 //Function to set the UI for shop products-filters
 function SetFiltersCheckBoxStyle() {

     $("#productfilters span input").customInputForFilters('true');
 CoverGirl.enableResetFilterLink();
}

//Function to set the UI for shopping cart
function SetShoppingCartCheckBoxStyle() {
    
    $("#basketcontent span input").customInputForFilters();
}


//Function to disable a checkbox
function DisableCheckBox(id) {

    if (document.getElementById(id) == null)
        return;
    document.getElementById(id).disabled = true;

}
//Added by MT-Since span was inserted during checkbox rendering
jQuery.fn.customInputForFilters = function(isGreyBackGround) {
    $(this).each(function(i) {

        if ($(this).is('[type=checkbox],[type=radio]')) {
            var input = $(this);

            // get the associated label using the input's id
            var label = $('label[for=' + input.attr('id') + ']');

            //get type, for classname suffix 
            var inputType = (input.is('[type=checkbox]')) ? 'checkbox' : 'radio';

            // add the appropriate class to the container div
            if ($(input).parent("div").length <= 0)
                if(isGreyBackGround == 'true')
                    $(input).parent("span").parent("div").addClass("custom-" + inputType).addClass("custom-" + inputType + "2");
                else
                    $(input).parent("span").parent("div").addClass("custom-" + inputType);
            else
                $(input).parent("div").addClass("custom-" + inputType);

            // find all inputs in this set using the shared name attribute
            var allInputs = $('input[name=' + input.attr('name') + ']');

            // necessary for browsers that don't support the :hover pseudo class on labels
            label.hover(
				function() {
				    $(this).addClass('hover');
				    if (inputType == 'checkbox' && input.is(':checked')) {
				        $(this).addClass('checkedHover');
				    }
				},
				function() { $(this).removeClass('hover checkedHover'); }
			);

            //bind custom event, trigger it, bind click,focus,blur events					
            input.bind('updateState', function() {
                if (input.is(':checked')) {
                    if (input.is(':radio')) {
                        allInputs.each(function() {
                            $('label[for=' + $(this).attr('id') + ']').removeClass('checked');
                        });
                    };
                    label.addClass('checked');
                }
                else { label.removeClass('checked checkedHover checkedFocus'); }

            })
			.trigger('updateState')
			.click(function() {
			    $(this).trigger('updateState');
			})
			.focus(function() {
			    label.addClass('focus');
			    if (inputType == 'checkbox' && input.is(':checked')) {
			        $(this).addClass('checkedFocus');
			    }
			})
			.blur(function() { label.removeClass('focus checkedFocus'); });
        }
    });
};


onload=function(){
$("#search input.searchbox").val($("#search input.searchbox").attr('title'));
}
