function showHide(popUpLink, popUpId, topOffset, leftOffset) {
	var linkPosition = $(popUpLink).cumulativeOffset();
	var popUp = $(popUpId);

	popUp.style.top = (linkPosition.top - popUp.offsetHeight + topOffset) + 'px';
	popUp.style.left = (linkPosition.left- popUp.offsetWidth + leftOffset) + 'px';

	if(popUp.style.visibility == 'hidden') {
		popUp.style.visibility = 'visible';
	}
	else {
		popUp.style.visibility = 'hidden';
	}
}
function hideTheRest() {
	var popUps = ['Layer1','Layer2','Layer3','Layer4'];
	popUps = popUps.map( function(popUp) { return $(popUp); } );

	popUps.compact().each(
		function(popUp) {
			popUp.style.visibility = 'hidden';
		}
	);
}
function openBMLWindow_PALA(popup)
{
	switch(popup) {
		case 0 : NW=window.open("https://www.securecheckout.billmelater.com/paycapture-content/fetch?hash=WPE25WEB&content=/bmlweb/coreiw.html","NewWindow","width=525,height=445,scrollbars=1,resizable=1,menubar=0,status=1,toolbar=0");break;
		case 1 : NW=window.open("https://www.securecheckout.billmelater.com/paycapture-content/fetch?hash=WPE25WEB&content=/bmlweb/coreiw.html","NewWindow","width=525,height=445,scrollbars=1,resizable=1,menubar=0,status=1,toolbar=0");break;
	}
	if(NW) {
		NW.focus();
	}
	return false;
}	

 function getCookieData(labelName) {
    var labelLen = labelName.length
    
    var cookieData = document.cookie;
    var cLen = cookieData.length;
    
    var i=0;
    var cEnd;
    while( i< cLen) {
       var j = i + labelLen;
       if ( cookieData.substring(i,j) == labelName ) {
         cEnd = cookieData.indexOf(";", j);
         if ( cEnd == -1 ) {
             cEnd = cookieData.length;
         }
         return unescape(cookieData.substring(j+1, cEnd)); 
       }
       i++;
    }
    return "";
 }


function setRecentlyViewedProductIdsCookie(thisProductId, domain)
{
     var productIds = getCookieData( "RecentlyViewedProductIds" );
     
     var foundId = false;
     var productIdsStr = "";
     if ( productIds != "" )
     {
         var productIdArr = productIds.split( "," );
         for( var i = 0; i < productIdArr.length; i++ )
         {
            if ( productIdArr[ i ] == thisProductId )
            {
                foundId = true;
            }
            if ( i < 20 )
            {
                if ( i > 0 )
                {
                    productIdsStr = productIdsStr + ",";
                }
                productIdsStr = productIdsStr + productIdArr[ i ];
            }
         }
         
         if ( foundId == false )
         {
             productIdsStr = "," + productIdsStr;
         }
     }	    
     
     if ( foundId == false )
     {
         productIdsStr =  thisProductId + productIdsStr;
     }
     
     document.cookie = "RecentlyViewedProductIds=" + productIdsStr + ";path=/;domain=" + domain;
}

 function go360(go360URL) 
 {
     var popup = window.open(go360URL,'Go360','width=793,height=459,top=5,left=5');
     popup.focus();
 }

