var stringNotPurchased = "<a onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/87330788/?cmd=file&file=visitorWantsToTalk&site=87330788&byhref=1&SESSIONVAR!skill=Customer%20Support&VISITORVAR!click2talk-source=ShoppingCart&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/CallButton-Gallery/English/General/1a', 'cbJsWindow', 'width=472,height=320,resizable,scrollbars=no');\" href='javascript:stay();'><img src='https://static.cleverbridge.com/mycontent/278/clicktotalk-notpurchased.gif' border='0' /></a>";
var stringPurchased = "<a onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/87330788/?cmd=file&file=visitorWantsToChat&site=87330788&byhref=1&SESSIONVAR!skill=Customer%20Support&VISITORVAR!source=ShoppingCart&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/', 'cbJsWindow', 'width=472,height=320,resizable,scrollbars=no');\" href='javascript:stay();'><img src='https://static.cleverbridge.com/mycontent/278/clicktotalk-purchased.gif' border='0' /></a>";

var stringErrorMsgNotPurchased = "If this problem persist, <a onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/87330788/?cmd=file&file=visitorWantsToTalk&site=87330788&byhref=1&SESSIONVAR!skill=Customer%20Support&VISITORVAR!click2talk-source=ShoppingCartErrorSection&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/CallButton-Gallery/English/General/1a', 'cbJsWindow', 'width=472,height=320,resizable,scrollbars=no');\" href='javascript:stay();' style='color:#0000ff;text-decoration:underline;'>we can call you now</a>";
var stringErrorMsgPurchased = "If this problem persist, <a onclick=\"javascript:window.open('https://server.iad.liveperson.net/hc/87330788/?cmd=file&file=visitorWantsToChat&site=87330788&byhref=1&SESSIONVAR!skill=Customer%20Support&VISITORVAR!source=ShoppingCartErrorSection&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/', 'cbJsWindow', 'width=472,height=320,resizable,scrollbars=no');\" href='javascript:stay();' style='color:#0000ff;text-decoration:underline;'>chat with a Uniblue Support representative</a>";

function get_x ( x )
{
  var results = document.cookie.match ( '(^|;) ?' + x + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}


function set_x ( name, value, path, domain, secure ) {
  var x = name + "=" + escape ( value );
  
  var expires = new Date ( 2019, 01, 15 );
     x += "; expires=" + expires.toGMTString();

  if ( path )
        x += "; path=" + escape ( path );

  if ( domain )
        x += "; domain=" + escape ( domain );
  
  if ( secure )
        x += "; secure";
		
  document.cookie = x;
}

function showPopupLayer(idOfTemplatesPopupLayer) {
  var e = document.getElementById(idOfTemplatesPopupLayer);
  if (e != null){
	if(e.style.display == "block"){
		e.style.display = "none";
	}
	else {
		e.style.display = "block";
		/*create iframe */	
		if(document.getElementById("CBPopUpLayerAutoIframe") == null) {
		
		var eIframe = document.createElement("iframe");
		eIframe.id = "CBPopUpLayerAutoIframe";
		eIframe.src = "/images/blank.gif";
		document.getElementById("cleverRecommendationPopupCompareSpecial").appendChild(eIframe);
		}

	}	
  }
}

function cbAddRecommendationPopup(idOfTemplatesPopupLayer){
	window.recommendationPopupList = window.recommendationPopupList ? window.recommendationPopupList : new Array();
 	window.recommendationPopupList[window.recommendationPopupList.length] = idOfTemplatesPopupLayer;
}

function cbAddRecommendationListener(){
	var n = document.getElementById("cleverButtonCompletePurchaseSubmit");
 	if (n != null && window.recommendationPopupList){
		/* n.type = "button";*/ //this will surely not submit. 
		
		n.onclick = function() {
			if (window.recommendationPopupList.length > 0) {
    			for (var i = 0; i < window.recommendationPopupList.length; i++){
	   				showPopupLayer(window.recommendationPopupList[i]);
     				}
   				}
				return false
			;
		}
		/*cleverEnvironment().dhtmlObject(n.id).addListener(new Listener("click",function(){
   			if (window.recommendationPopupList.length > 0) {
    			for (var i = 0; i < window.recommendationPopupList.length; i++){
	   				showPopupLayer(window.recommendationPopupList[i]);
     			}
   			}
		}));*/
	}
}
DomLoaded.load(cbAddRecommendationListener);

function enableBusinessData(){
	var l = document.getElementById("cbEventIsCompany");
	var t = document.getElementById("deliveryContactRight");
	if (l != null && t != null){
		l.onclick = enableBusinessData;
		
		var cn = t.className.replace(" disabled", "");
		t.className = l.checked ? cn : cn + " disabled"; 
		
		var ability = function(n){
			for (var i = 0; i < n.childNodes.length; i++){
				if (n.childNodes[i].type || n.childNodes[i].nodeName == "select"){
					if (l.checked){
						n.childNodes[i].disabled = false;	
						
					} else {
						n.childNodes[i].disabled = true;
						
						
					}
					
				}
				if (n.childNodes[i].childNodes.length > 0){
					ability(n.childNodes[i]);
				}
			}
		}
		ability(t);
			
	}

}
DomLoaded.load(enableBusinessData);