/*Layer functions*/
//Ajax call for verify the the interstitial page will dosplay or not starts
var oparationType="";
var termsOfUse;
var privacyPolicy;
var resultInter="";
var showOnLoad="true";

  var xmlhttpInter;
var which;
function retrieveURL() {
var urlInter="/interstitial/emailCampaign.do?locale="+UserLocale+"&username="+UserName+"&reqType=verifyPI"	
try {
					if (window.XMLHttpRequest)
					  {// code for Firefox, Opera, IE7, etc.
							 xmlhttpInter=new XMLHttpRequest();
					  }
					else if (window.ActiveXObject)
					  {// code for IE6, IE5
							 xmlhttpInter=new ActiveXObject("Microsoft.XMLHTTP");
					  }
} catch (e) {
alert(e);
}
if(xmlhttpInter){ 
xmlhttpInter.onreadystatechange = processStateChange;
xmlhttpInter.open("GET", urlInter, true);
xmlhttpInter.send(null);
}else
{
   alert('Browser does not support this request');
}

}
function processStateChange() { 
if (xmlhttpInter.readyState == 4) { // Complete
//if (xmlhttpInter.status == 200) { // OK response
 resultInter=xmlhttpInter.responseText;
}
if(resultInter.indexOf('true')!=-1)
{
//document.write('<META NAME="WT.cg_n" CONTENT="Interstitial">');
//document.write('<META NAME="WT.cg_s" CONTENT="e-mailValidation">');
     var splitter;
	 splitter=resultInter.split('~');
	 var heightWidth=splitter[1].split(',');
	 var layerWidthIE=heightWidth[0];
	 var layerHeightIE=heightWidth[1];
	 var layerWidthFF=heightWidth[2];
	 var layerHeightFF=heightWidth[3];
	 document.getElementById('divID').style.display="inline";
	 showPopUpInter('/interstitial/emailCampaign.do?locale='+UserLocale+'&reqType=showCP&username='+UserName,layerWidthIE,layerHeightIE,layerWidthFF,layerHeightFF);
	 resultInter="";
	 window.onload=showOnLoad_on;
	
	 
}else{
	document.getElementById('divID').style.display="none";
}
}
function  verifyInterstitialpage()
{
	if((UserLocale=="en_GB")||(UserLocale=="es_ES") ||(UserLocale=="en_CA")||(UserLocale=="fr_CA")||(UserLocale=="pt_PT")||(UserLocale=="nl_NL")||(UserLocale=="fr_BE")||(UserLocale=="nl_BE")||(UserLocale=="en_SA")||(UserLocale=="en_IE")||(UserLocale=="hu_HU")||(UserLocale=="tr_TR")||(UserLocale=="da_DK")||(UserLocale=="de_AT")||(UserLocale=="fi_FI")||(UserLocale=="en_LB")||(UserLocale=="en_AE")||(UserLocale=="en_PK")||(UserLocale=="no_NO")||(UserLocale=="en_IN")||(UserLocale=="et_EE")||(UserLocale=="it_IT")||(UserLocale=="en_ZA")||(UserLocale=="de_DE"))
	{
          if(PageName!="Registration_Confirm"){
			retrieveURL();
		  }
	}
}
////Ajax call for verify the the interstitial page will dosplay or not ends
function whichBrs() {
			var agt=navigator.userAgent.toLowerCase();
			if (agt.indexOf("opera") != -1) return 'Opera';
			if (agt.indexOf("staroffice") != -1) return 'Star Office';
			if (agt.indexOf("webtv") != -1) return 'WebTV';
			if (agt.indexOf("beonex") != -1) return 'Beonex';
			if (agt.indexOf("chimera") != -1) return 'Chimera';
			if (agt.indexOf("netpositive") != -1) return 'NetPositive';
			if (agt.indexOf("phoenix") != -1) return 'Phoenix';
			if (agt.indexOf("firefox") != -1) return 'Firefox';
			if (agt.indexOf("safari") != -1) return 'Safari';
			if (agt.indexOf("skipstone") != -1) return 'SkipStone';
			if (agt.indexOf("msie") != -1) return 'Internet Explorer';
			if (agt.indexOf("netscape") != -1) return 'Netscape';
			if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
			if (agt.indexOf('\/') != -1) {
			if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
			return navigator.userAgent.substr(0,agt.indexOf('\/'));}
			else return 'Netscape';} else if (agt.indexOf(' ') != -1)
			return navigator.userAgent.substr(0,agt.indexOf(' '));
			else return navigator.userAgent;
			}

function showPopUpInter(url,layerWidthIE,layerHeightIE,layerWidthFF,layerHeightFF)
		{
		  document.getElementById('CalDiv').style.display="inline"
		  
		  /* IE width and height */
		   if(whichBrs()=='Internet Explorer') 
		   {
		    	 document.getElementById('CalDiv').style.width=layerWidthIE+"px";
		   		 document.getElementById('CalDiv').style.height=layerHeightIE+"px";
		   		 document.getElementById("iFrm").style.backgroundColor="#F2E9EB";
				 document.getElementById("CalDiv").style.backgroundColor="#F2E9EB";
		   }
		   
		   /* firefox width and height */
		    if(whichBrs()=='Firefox') 
		   {
		  		document.getElementById('CalDiv').style.width=layerWidthFF+"px";
		  		document.getElementById('CalDiv').style.height=layerHeightFF+"px";
		   }
		   /* safari width and height */
		    if(whichBrs()=='Safari') 
		   {
		  		document.getElementById('CalDiv').style.width=layerWidthFF+"px";
		  		document.getElementById('CalDiv').style.height=layerHeightFF+"px";
		   }
		   
		  positionCenter(document.getElementById('CalDiv'));
		  document.getElementById('iFrm').src=url;
		  
		  
		}
function positionCenter(obj)
		{
		  
		 obj.style.left=screen.availWidth/2-(parseInt(obj.style.width)/2)+"px";
		 obj.style.top=screen.availHeight/2-(parseInt(obj.style.height)/2+70)+"px";
		}
function closePopUpInter()
		{
		 
		  document.getElementById('iFrm').src="";
		  document.getElementById('CalDiv').style.display="none";
		  
		}
function closeLayerInter(url)
		{
         
		  document.getElementById('divID').style.display="none";
		  forwardTO();
		 
		}
function forwardTO()
{
		if(oparationType=='submitwithME'){
	        window.location.href="/medical_and_more/Email_Subscription";
	  	}else if(oparationType=='declineInInterstialPage'){
		  	window.location.href="/interstitial/policiesCampaign.do?locale="+UserLocale+"&reqType="+oparationType+"&privacyPolicy="+privacyPolicy+"&termsOfUse="+termsOfUse;
	   	}else if((oparationType=='submitInInterstitial')){
			if(UserLocale=='it_IT'){
				window.location.href="/medical_and_more/Edit_Profile";
			}
	   }else{
		  	document.getElementById('divID').style.display="none";
	   }
   
}

function showOnLoad_on()
{
   if(showOnLoad=='true')
	{
	   showLayerInter();
	}
}

function showLayerInter(){
	  var preferPage = UserLocale+"_Preferences";
	  document.getElementById('divID').style.display="inline";
	  if(PageName=="Edit_Profile"){
		document.getElementById('inDiv').style.width=screen.width-24+"px";
  		document.getElementById('inDiv').style.height='2000'+"px";
    	//window.onscroll = scrollWin;
	  }
	  if(whichBrs()=='Internet Explorer') {
		if((PageName=="Whitelist"||PageName==preferPage)) {
			document.getElementById('inDiv').style.height="1200px";
		}else{
			if(document.body.scrollHeight>1024)
			document.getElementById('inDiv').style.height=document.body.scrollHeight+"px";
		}
	   document.getElementById('inDiv').style.width=screen.width-24+"px";
	  }
	  /* firefox height */
	    if(whichBrs()=='Firefox') 
	   {
			document.getElementById('inDiv').style.width=screen.width-24+"px";
			document.getElementById('inDiv').style.height='2000'+"px";
			window.onscroll = scrollWin;
	   }
	    if(whichBrs()=='Safari') 
	   {
			document.getElementById('inDiv').style.width=screen.width-24+"px";
	  		document.getElementById('inDiv').style.height='2000'+"px";
	    	window.onscroll = scrollWin;
	   }
}
function showPopUpMyAccount(url,layerWidthIE,layerHeightIE,layerWidthFF,layerHeightFF)
{
	  document.getElementById('CalDiv').style.display="inline"
  /* IE width and height */
   if(whichBrs()=='Internet Explorer') 
   {
    	 document.getElementById('CalDiv').style.width=layerWidthIE+"px";
   		 document.getElementById('CalDiv').style.height=layerHeightIE+"px";
		// alert(1);
		 document.getElementById("iFrm").style.backgroundColor="#F2E9EB";
    	 document.getElementById("CalDiv").style.backgroundColor="#F2E9EB";
	 //				 alert(2);
   }


		   /* firefox width and height */

		    if(whichBrs()=='Firefox') 

		   {
		  		document.getElementById('CalDiv').style.width=layerWidthFF+"px";
		  		document.getElementById('CalDiv').style.height=layerHeightFF+"px";
		   }

		   /* safari width and height */

		    if(whichBrs()=='Safari') 

		   {
		  		document.getElementById('CalDiv').style.width=layerWidthFF+"px";
		  		document.getElementById('CalDiv').style.height=layerHeightFF-10+"px";
		   }

		  positionCenter(document.getElementById('CalDiv'));
		  document.getElementById('iFrm').src=url;
  

		}

		function scrollWin()
               { 
                       if(document.getElementById('divID').style.display=="inline")
                       {
			if(pageYOffset>=900)                       
			  setTimeout("scrollTo(0,0)",500)
                       }
                 }

var ct_tmr,iTmr=0,pageLoadStatus='False';

function startTmr(){
ct_tmr=setTimeout("startTmr()",1000)
iTmr++;
          if(iTmr==10||pageLoadStatus=='True'){
		  
		  closePopUp();
		  
		   clearTimeout(ct_tmr);
           }
}
function  verifySecureAccount()
{
	if((UserLocale=="nl_NL")||(UserLocale=="de_DE")||(UserLocale=="en_GB")||(UserLocale=="en_IE")||(UserLocale=="no_NO")||(UserLocale=="nl_BE")||(UserLocale=="sv_SE")||(UserLocale=="fi_FI")||(UserLocale=="fr_BE")||(UserLocale=="de_AT")||(UserLocale=="en_IN")||(UserLocale=="en_PK")||(UserLocale=="en_LB")||(UserLocale=="en_AE")||(UserLocale=="en_SA")||(UserLocale=="en_ZA")||(UserLocale=="tr_TR")||(UserLocale=="da_DK")||(UserLocale=="it_IT")||(UserLocale=="pt_PT")||(UserLocale=="es_ES"))
	{
		  if(PageName!="Registration_Confirm"){
			retrieveURL1();
		  }
	}
}

function closePopUpInterfinal()
{
  document.getElementById('CalDiv').style.display="none";
  window.location.href="/medical_and_more/"; 
}

function retrieveURL1() {
var urlInter='/interstitial/myAccountAuth.do?reqType=verifyUser&locale='+UserLocale+'&username='+UserName;	
try {
	if (window.XMLHttpRequest)
	  {// code for Firefox, Opera, IE7, etc.
			 xmlhttpInter=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {// code for IE6, IE5
			 xmlhttpInter=new ActiveXObject("Microsoft.XMLHTTP");
	  }
} catch (e) {
	alert(e);
}
	if(xmlhttpInter){ 
		xmlhttpInter.onreadystatechange = processStateChangeNew;
		if(whichBrs()!='Internet Explorer') {
			xmlhttpInter.open("GET", urlInter, true);
		}else{
			xmlhttpInter.open("POST", urlInter, true);
		}
		xmlhttpInter.send(null);
	}else{
	   alert('Browser does not support this request');
	}
}

function processStateChangeNew() { 
	if (xmlhttpInter.readyState == 4) { // Complete
	 resultInter=xmlhttpInter.responseText;
	}
	if(resultInter.indexOf('true')!=-1)
	{
	     var splitter;
		 splitter=resultInter.split('~');
		 var heightWidth=splitter[1].split(',');
		 var layerWidthIE=heightWidth[0];
		 var layerHeightIE=heightWidth[1];
		 var layerWidthFF=heightWidth[2];
		 var layerHeightFF=heightWidth[3];
		 document.getElementById('divID').style.display="inline";
		 showPopUpMyAccount('/interstitial/myAccountAuth.do?reqType=showPopUp&locale='+UserLocale+'&username='+UserName,layerWidthIE,layerHeightIE,layerWidthFF,layerHeightFF);
		 resultInter="";
		 window.onload=showOnLoad_on;
	}else{
		document.getElementById('divID').style.display="none";
	}
}
/*Layer functions*/
