﻿$(document).ready(function() {
       // Use the each() method to gain access to each of the elements attributes
       $('#content img').each(function()
       {
          $(this).qtip(
          {
             content: '<div class="continuityToolTipHeader">Save Time and Money!</div><div class="continuityToolTip">Receive your refill at a designated frequency - <strong>Automatically</strong> and receive <strong>$1.99 shipping</strong>  on all Auto Refill orders after your initial order</div>', 
             position: {
                  corner: {
                     target: 'rightMiddle',
                     tooltip: 'leftMiddle'
                  }
               },
             hide: {
                fixed: true // Make it fixed so it can be hovered over
             },
             style: { 
                width: 250,
                padding: 10,
                background: '#fff',
                color: 'black',
                border: {
                    width: 4,
                    radius: 3,
                    color: '#1b76bc'
                },
                tip: 'leftMiddle',
                name: 'dark' // Inherit the rest of the attributes from the preset dark style
             }
          });
       });
     /// Created by:     Justin C Miller
    /// Created on:     2010-02-24
    /// Description:    Creates jquery popup window for Processing Fee 'whats this' on the Order Totals control
    ///  
    /// Updates:
    ///     Modified by:    
    ///     Modified on:    
    ///     Description:    
    $('#processingFeeWhatsThisDiv a').each(function()
    {
      $(this).qtip(
      {
         content: '<div class="processingFeeWhatsThisToolTip">' + $('<div/>').html($("#ProcessingFeeWhatsThisPopupTextHiddenValue").val()).text() + ' <a href="' + $("#ProcessingFeeWhatsThisPopupTextMoreInfoLinkHiddenValue").val() + '">' + $("#ProcessingFeeWhatsThisPopupTextMoreInfoLinkTextHiddenValue").val() + '</a></div>', 
         position: {
              corner: {
                 target: 'rightMiddle',
                 tooltip: 'leftMiddle'
              }
           },
         hide: {
            fixed: true // Make it fixed so it can be hovered over
         },
         style: { 
            width: 250,
            padding: 10,
            background: '#fff',
            color: 'black',
            border: {
                width: 4,
                radius: 3,
                color: '#1b76bc'
            },
            tip: 'leftMiddle',
            name: 'dark' // Inherit the rest of the attributes from the preset dark style
         }
      });
    });
    
    /// Created by:     Justin C Miller
    /// Created on:     2010-02-25
    /// Description:    Creates jquery popup window for Shipping Total View Details on the Order Totals control
    ///  
    /// Updates:
    ///     Modified by:    
    ///     Modified on:    
    ///     Description:    
    $('#shippingTotalViewDetailsDiv a').each(function()
    {
      $(this).qtip(
      {
         content: '<div class="shippingTotalViewDetailsToolTip">' + $('<div/>').html($("#shippingTotalViewDetailsPopupTextHiddenValue").val()).text() + ' <a href="' + $("#shippingTotalViewDetailsPopupTextMoreInfoLinkHiddenValue").val() + '">' + $("#shippingTotalViewDetailsPopupTextMoreInfoLinkTextHiddenValue").val() + '</a></div>', 
         position: {
              corner: {
                 target: 'rightMiddle',
                 tooltip: 'leftMiddle'
              }
           },
         hide: {
            fixed: true // Make it fixed so it can be hovered over
         },
         style: { 
            width: 250,
            padding: 10,
            background: '#fff',
            color: 'black',
            border: {
                width: 4,
                radius: 3,
                color: '#1b76bc'
            },
            tip: 'leftMiddle',
            name: 'dark' // Inherit the rest of the attributes from the preset dark style
         }
      });
    });


    $(".RegistrationContainer").hide();
    
    $(".ShowFormButton").click(function() {
        $(".LoginNewUserText").hide();
        $(".RegistrationContainer").show();
        $(".Login").css('height','550px');
        return false;
    });
    
	$(".RegisterButton").click(function() {
	    var isValid;
	    var errorList;
	    errorList = "<ul class='ErrorMessageLabel'>";
	    isValid = true;
	    
	    if($(".RegisterEmailTextBox").val().length == 0){
	        $(".RegisterEmailTextBox").addClass("FormTextBoxError");
	        $(".RegisterEmailLabel").addClass("FormLabelError");
	        errorList += "<li>Please enter an email address.</li>";
	        isValid = false;
	    }
	    if($(".RegisterEmailTextBox").val() != $(".RegisterConfirmEmailTextBox").val()){
	        $(".RegisterConfirmEmailTextBox").addClass("FormTextBoxError");
	        $(".RegisterConfirmEmailLabel").addClass("FormLabelError");
	        $(".RegisterEmailTextBox").addClass("FormTextBoxError");
	        $(".RegisterEmailLabel").addClass("FormLabelError");
	        errorList += "<li>Email Address and Confirm Email Address do no match.</li>";
	        isValid = false;
	    }
	    if($(".RegisterPasswordTextBox").val().length == 0){
	        $(".RegisterPasswordTextBox").addClass("FormTextBoxError");
	        $(".RegisterPasswordLabel").addClass("FormLabelError");
	        errorList += "<li>Please enter your password.</li>";
	        isValid = false;
	    }
	    if($(".RegisterPasswordTextBox").val() != $(".RegisterConfirmPasswordTextBox").val()){
	        $(".RegisterConfirmPasswordTextBox").addClass("FormTextBoxError");
	        $(".RegisterConfirmPasswordLabel").addClass("FormLabelError");
	        $(".RegisterPasswordTextBox").addClass("FormTextBoxError");
	        $(".RegisterPasswordLabel").addClass("FormLabelError");
	        errorList += "<li>Password and Confirm Password do not match.</li>";
	        isValid = false;
	    }
	    if($(".RegisterQuestionsDropdown").val() == "-1") {
	        $(".RegisterQuestionsDropdown").addClass("FormSelectBoxError");
	        errorList += "<li>Please select a password reset question.</li>";
	        isValid = false;
	    }
	    if($(".RegisterPasswordAnswer").val().length == 0){
	        $(".RegisterAnswerLabel").addClass("FormLabelError");
	        errorList += "<li>Please enter a password reset answer</li>";
	        isValid = false;
	    }
        if(!isValid)
        {
            errorList += "</ul>";
            $(".RegistrationErrors").html(errorList);
            $(".Login").css('height','650px');
		    return false;
		}
	});
	
	 $(".MultShipToLinkButton").click(function() {
        //enableDisableMultShipToButton(false);
	    isValidBA = true;
	    isValidSH = true;
	        
	    /* we need to make sure we remove any error classes that my exist first, otherwise, they'll never be removed*/	
        removeErrorClasses();
	    
	    isValidBA = validateBillingAddress();
	    
		if(!isValidBA)
		{
		    $(".MultShipToLinkButton:disabled").removeAttr('disabled');
		    scroll(0,0);
		    return false;
		}
		
	});
	
	 $(".PaymentReviewButton").click(function() {
	    isValidBA = true;
	    isValidSH = true;
	        
	    /* we need to make sure we remove any error classes that my exist first, otherwise, they'll never be removed*/	
        removeErrorClasses();
	    
	    isValidBA = validateBillingAddress();
	    
	    // validate the shipping address if we need to
	    // if they are not shipping to their billing address, and they have not select an address from the radio button group, then we need to 
	    // validate the shipping form.
	    if(!$('.SHAlsoShippingAddressCheckBox').hasClass("SHAlsoShippingAddressCheckBoxChecked")){ 
	        if($(".ShippingAddressesRadioButtons input:checked").val() == 'NewAddress' || $(".ShippingAddressesRadioButtons input").val() == undefined){
                isValidSH = validateShippingAddress();
            }
	    }
		if(!isValidBA || !isValidSH)
		{
		    scroll(0,0);
		    return false;
		}
	});
	
	$(".ShippingAddressesRadioButtons").click(function() {
	    if($(".SHAlsoShippingAddressCheckBox").hasClass("SHAlsoShippingAddressCheckBoxChecked"))
	    {   
	        toggleShippingAddressForm(false, true);
	        $('.SHAlsoShippingAddressCheckBox input').removeAttr("checked");
	        $(".SHAlsoShippingAddressCheckBox").removeClass("SHAlsoShippingAddressCheckBoxChecked");
	    }
	    
	    if($(".ShippingAddressesRadioButtons input:checked").val() == 'NewAddress' || $(".ShippingAddressesRadioButtons input").val() == undefined){
	        $(this).removeClass("ShippingAddressesRadioButtonsChecked");
	        toggleShippingAddressForm(false, false);
	    } else {
	        $(this).addClass("ShippingAddressesRadioButtonsChecked");
	        toggleShippingAddressForm(true, false);
	    }
	});
	
	$('.SHAlsoShippingAddressCheckBox').click(shippingBoxChecked);
	
	 //Swap StickyFooter
    $('#hideBar').click(hideStickyFooter);
    $('#showBar').click(showStickyFooter);
    
     if($.cookie('stickyFooter') == null){
        showStickyFooter();
    }
    else{
       hideStickyFooter();
    }
    
    function hideStickyFooter(){
        $('#hideBar').hide();
        $('#stickyContent').hide();
        $('#showBar').show();
        $('.stickyFooter').addClass('shrinkStickyFooter');
        
        if(this.id == 'hideBar'){
             $.cookie('stickyFooter', 'hide');
        }
    }
    function showStickyFooter(){
        $('#showBar').hide();
        $('#stickyContent').show();
        $('#hideBar').show();
        $('.stickyFooter').removeClass('shrinkStickyFooter');
      
         if(this.id == 'showBar'){
             $.cookie('stickyFooter', null,{ expires: -1 }); 
        }
    }
    
    //Trim email unsubscribe boxes. 3/26/10 TW
    $('#ctl00_ContentPlaceHolder1_EmailUnsubscribe1_EmailAddressTextBox').blur(trimText);
    $('#ctl00_ContentPlaceHolder1_EmailUnsubscribe1_ConfirmEmailAddressTextBox').blur(trimText);
    $('#ctl00_ContentPlaceHolder1_EmailSignup1_EmailAddressTextBox').blur(trimText);
    $('#ctl00_ContentPlaceHolder1_EmailSignup1_ConfirmEmailAddressTextBox').blur(trimText);
    
    function trimText() {
        var textValue = this.value;
        textValue.trim();
        this.value = textValue.trim();
    }
    
});

/// Original JQueryFunctions taken out of document ready

function checkAddressCookie()
{
    if($.cookie('addChecked') == 'show'){
        shippingBoxCheckedHelper(false);
    }
}

function shippingBoxChecked()
{ 
    shippingBoxCheckedHelper(true);
}

/// Modified by:    Erica Mutsch
/// Modified on:    05/03/10
/// Description:    WO 2068 - fixed bug that caused the "use billing address for shipping" box to stay checked
function shippingBoxCheckedHelper(ValidateTheBillingAddress) {
    if($(".ShippingAddressesRadioButtons").hasClass("ShippingAddressesRadioButtonsChecked"))
    {
        toggleShippingAddressForm(false, false)
        $(".ShippingAddressesRadioButtons input")[0].checked = true;
        $(".ShippingAddressesRadioButtons").removeClass("ShippingAddressesRadioButtonsChecked");
    }

    var isValidSH;
    removeErrorClasses();
    if($(".SHAlsoShippingAddressCheckBox").hasClass("SHAlsoShippingAddressCheckBoxChecked")) 
    {
        $(".MultShipToLinkButton:disabled").removeAttr('disabled');
        $(".SHAlsoShippingAddressCheckBox").removeClass("SHAlsoShippingAddressCheckBoxChecked");
        toggleShippingAddressForm(false, true);
        checkForBillingAddressChange(false);
        
         if($.cookie('addChecked') == 'show'){
            $.cookie('addChecked', null,{ expires: -1 });
         }
    } 
    else 
    {
        if(ValidateTheBillingAddress == true){
            isValidSH = validateBillingAddress();
        }// closes if
        
        if(isValidSH)
        {
            $(".MultShipToLinkButton").attr('disabled','disabled');
            $(".SHAlsoShippingAddressCheckBox").addClass("SHAlsoShippingAddressCheckBoxChecked");
            $('.SHAlsoShippingAddressCheckBox input').attr('checked','true');
            $(".SHErrorMessageLabel").html("");
            toggleShippingAddressForm(true, true);
            checkForBillingAddressChange(true);
            
            if($.cookie('addChecked') == null){
                $.cookie('addChecked', 'show');
            }
        } 
        else 
        {
            $(".MultShipToLinkButton:disabled").removeAttr('disabled');
            $('.SHAlsoShippingAddressCheckBox input').removeClass("SHAlsoShippingAddressCheckBoxChecked");
            $('.SHAlsoShippingAddressCheckBox input').removeAttr("checked");
             if($.cookie('addChecked') == 'show'){
                $.cookie('addChecked', null,{ expires: -1 });
             }
        }
    }

}

    function toggleShippingAddressForm(enabled, autofill) {
        var arrFields = ["FirstNameTextBox","LastNameTextBox","Address1TextBox","Address2TextBox","CityTextBox","StateDDL","ZipTextBox","ZipExtTextBox","DayTimeTextBox1","DayTimeTextBox2","DayTimeTextBox3","EveningPhoneTextBox1","EveningPhoneTextBox2","EveningPhoneTextBox3"];

        if(enabled)
        {
            $.each(arrFields, function() {
                if(autofill)
                {
                    $(".SH" + this).val($(".BA" + this).val())
                }
                $(".SH" + this).attr("disabled", "disabled");
            })
        }
        else
        {
            $.each(arrFields, function() {
                if(autofill)
                {
                    $(".SH" + this).val('')
                }
                $(".SH" + this).removeAttr("disabled", "disabled");
            })
            $(".SHStateDDL").val("-1")
        }
    }
    
    function checkForBillingAddressChange(checkKeyUp) {
        var arrFields = ["BAFirstNameTextBox","BALastNameTextBox","BAAddress1TextBox","BAAddress2TextBox","BACityTextBox","BAZipTextBox","BAZipExtTextBox","BADayTimeTextBox1","BADayTimeTextBox2","BADayTimeTextBox3","BAEveningPhoneTextBox1","BAEveningPhoneTextBox2","BAEveningPhoneTextBox3"];
        if(checkKeyUp) {
            $.each(arrFields, function() {
                $("." + this).one("keyup", billingChanged);
                $('.BAStateDDL').change(billingChanged);
            });
        } else {
            $.each(arrFields, function() {
                $("." + this).unbind("keyup");
            });
        }
    }
    
    function billingChanged() {
        var arrFields = ["BAFirstNameTextBox","BALastNameTextBox","BAAddress1TextBox","BAAddress2TextBox","BACityTextBox","BAZipTextBox","BAZipExtTextBox","BADayTimeTextBox1","BADayTimeTextBox2","BADayTimeTextBox3","BAEveningPhoneTextBox1","BAEveningPhoneTextBox2","BAEveningPhoneTextBox3"];
        toggleShippingAddressForm(false, true);
        $('.SHAlsoShippingAddressCheckBox input').removeAttr("checked");
        $('.SHAlsoShippingAddressCheckBox').removeClass("SHAlsoShippingAddressCheckBoxChecked");
        
        $.each(arrFields, function() {
            $("." + this).unbind("keyup");
        });
    }
    
    function removeErrorClasses() {
    	$("label").removeClass("FormLabelError");
	    $(":input").removeClass("FormTextBoxError");
    }
    
    function validateBillingAddress() {
        var isValidBA;
        var billingErrorList;
        isValidBA = true;
        billingErrorList = "<ul class='ErrorMessageLabel'>";
        
        if($(".BAFirstNameTextBox").val().length == 0){
	        $(".BAFirstNameTextBox").addClass("FormTextBoxError");
	        $(".BAFirstNameLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter your first name.</li>";
	        isValidBA = false;
	    }
	    if($(".BALastNameTextBox").val().length == 0){
	        $(".BALastNameTextBox").addClass("FormTextBoxError");
	        $(".BALastNameLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter your last name.</li>";
	        isValidBA = false;
	    }	    
	    if($(".BAAddress1TextBox").val().length == 0){
	        $(".BAAddress1TextBox").addClass("FormTextBoxError");
	        $(".BAAddress1Label").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter your address.</li>";
	        isValidBA = false;
	    }	    
	    if($(".BACityTextBox").val().length == 0){
	        $(".BACityTextBox").addClass("FormTextBoxError");
	        $(".BACityLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter your city.</li>";
	        isValidBA = false;
	    }	 	    
	    if($(".BAStateDDL").val() == "Select State"){
	        $(".BAStateDDL").addClass("FormDropDownBoxError");
	        $(".BAStateLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter your state.</li>";
	        isValidBA = false;
	    }
	    if(!$(".BAZipTextBox").val().match(/\d{5}/)){
	        $(".BAZipTextBox").addClass("FormTextBoxError");
	        $(".BAZipLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter your state.</li>";
	        isValidBA = false;
	    }
	    if($(".BAZipExtTextBox").val().length > 0 && !$(".BAZipExtTextBox").val().match(/\d{4}/)){
	        $(".BAZipExtTextBox").addClass("FormTextBoxError");
	        $(".BAZipLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter a valid zip code extension.</li>";
	        isValidBA = false;
	    }
	    if(!$(".BADayTimeTextBox1").val().match(/\d{3}/)){
	        $(".BADayTimeTextBox1").addClass("FormTextBoxError");
	        $(".BADayTimePhoneLabel").addClass("FormLabelError");
	        $(".BADayTimeTextBox2").addClass("FormTextBoxError");
	        $(".BADayTimePhoneLabel").addClass("FormLabelError");
	        $(".BADayTimeTextBox3").addClass("FormTextBoxError");
	        $(".BADayTimePhoneLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter a valid day time phone number.</li>";
	        isValidBA = false;
	    } else {
	        if(!$(".BADayTimeTextBox2").val().match(/\d{3}/)){
	            $(".BADayTimeTextBox1").addClass("FormTextBoxError");
	            $(".BADayTimePhoneLabel").addClass("FormLabelError");
	            $(".BADayTimeTextBox2").addClass("FormTextBoxError");
	            $(".BADayTimePhoneLabel").addClass("FormLabelError");
	            $(".BADayTimeTextBox3").addClass("FormTextBoxError");
	            $(".BADayTimePhoneLabel").addClass("FormLabelError");
	            billingErrorList += "<li>Please enter a valid day time phone number.</li>";
	            isValidBA = false;
	        } else {
	            if(!$(".BADayTimeTextBox3").val().match(/\d{4}/)){
	                $(".BADayTimeTextBox1").addClass("FormTextBoxError");
	                $(".BADayTimePhoneLabel").addClass("FormLabelError");
	                $(".BADayTimeTextBox2").addClass("FormTextBoxError");
	                $(".BADayTimePhoneLabel").addClass("FormLabelError");
	                $(".BADayTimeTextBox3").addClass("FormTextBoxError");
	                $(".BADayTimePhoneLabel").addClass("FormLabelError");
	                billingErrorList += "<li>Please enter a valid day time phone number.</li>";
	                isValidBA = false;
	            }
	        }
	    }
	    	     
	    if(!$(".BAEmailTextBox").val().match(/^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*([A-Za-z0-9]+\-?)@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/)){
	        $(".BAEmailTextBox").addClass("FormTextBoxError");
	        $(".BAEmailLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Please enter a valid email address.</li>";
	        isValid = false;
	    }
	    if($(".BAEmailTextBox").val() != $(".BAConfirmEmailTextBox").val()){
	        $(".BAEmailTextBox").addClass("FormTextBoxError");
	        $(".BAEmailLabel").addClass("FormLabelError");
	        $(".BAConfirmEmailTextBox").addClass("FormTextBoxError");
	        $(".BAConfirmEmailLabel").addClass("FormLabelError");
	        billingErrorList += "<li>Email and Confirm Email does not match.</li>";
	        isValidBA = false;
        }
        
        if(!isValidBA)
        {
            billingErrorList += "</ul>";
            $(".BAErrorMessageLabel").html(billingErrorList);
		} else {
		    $(".BAErrorMessageLabel").html("");
		}
        return isValidBA;
    }
    
    function validateShippingAddress() {
        var isValidSH;
        var shippingErrorList;
        shippingErrorList = "<ul class='ErrorMessageLabel'>";
	    isValidSH = true;
	    
        if($(".SHFirstNameTextBox").val().length == 0){
            $(".SHFirstNameTextBox").addClass("FormTextBoxError");
            $(".SHFirstNameLabel").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter your first name.</li>";
            isValidSH = false;
        }
        if($(".SHLastNameTextBox").val().length == 0){
            $(".SHLastNameTextBox").addClass("FormTextBoxError");
            $(".SHLastNameLabel").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter your last name.</li>";
            isValidSH = false;
        }
        if($(".SHAddress1TextBox").val().length == 0){
            $(".SHAddress1TextBox").addClass("FormTextBoxError");
            $(".SHAddress1Label").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter your address.</li>";
            isValidSH = false;
        }	    
        if($(".SHCityTextBox").val().length == 0){
            $(".SHCityTextBox").addClass("FormTextBoxError");
            $(".SHCityLabel").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter your city.</li>";
            isValidSH = false;
        }	 	    
        if($(".SHStateDDL").val() == "-1"){
            $(".SHStateDDL").addClass("FormTextBoxError");
            $(".SHStateLabel").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter your state.</li>";
            isValidSH = false;
        }
        if(!$(".SHZipTextBox").val().match(/\d{5}/)){
            $(".SHZipTextBox").addClass("FormTextBoxError");
            $(".SHZipLabel").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter your zip code.</li>";
            isValidSH = false;
        }
        if($(".SHZipExtTextBox").val().length > 0 && !$(".SHZipExtTextBox").val().match(/\d{4}/)){
            $(".SHZipExtTextBox").addClass("FormTextBoxError");
            $(".SHZipLabel").addClass("FormLabelError");
            shippingErrorList += "<li>Please enter a valid zip code extension.</li>";
            isValidSH = false;
        }
    
    	if(!isValidSH)
		{
		    shippingErrorList += "</ul>";
            $(".SHErrorMessageLabel").html(shippingErrorList);
		} else {
		    $(".SHErrorMessageLabel").html("");
		}
    
        return isValidSH;
    }
    
    function enableDisableMultShipToButton(setToEnabled){
        if(setToEnabled == true){
            $(".MultShipToLinkButton:disabled").removeAttr('disabled');
        } else {
            $(".MultShipToLinkButton").attr('disabled','disabled');
        }
        
    }
        /* begin of the Photo Pers*/
function closeModal(){
   $('.window').hide();
}

function openModal()
{
    //Get the A tag
    var id = $('#test').attr('href');
            
    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();
      
    //Set heigth and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});
            
    //transition effect           
    $('#mask').fadeIn(1000);      
    $('#mask').fadeTo("slow",0.8);      
      
    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();
              
    //Set the popup window to center
    $(id).css('top',  winH/2-$(id).height()/2);
    $(id).css('left', winW/2-$(id).width()/2);
      
    //transition effect
     $(id).fadeIn(2000);
}

/* end of the Photo Pers*/

/* Removed from checkout step 2a */

 function ShowGreyout() {
    var modalPopupBehavior = $find('PanelCoverBh');
    if(Page_ClientValidate())
    {
        modalPopupBehavior.show();
    }
    return false;
    }
    function ShowGreyoutPayPal() {
    var modalPopupBehavior = $find('PanelCoverBh');
  
        modalPopupBehavior.show();
   
    return false;
    }
    
    function HideGreyout() {
        var modalPopupBehavior = $find('PanelCoverBh');
        modalPopupBehavior.hide();
        return false;
    }