// JavaScript Document
// Code for intercept. Add this to page where interstitial should be displayed
// Display pop up to every nth visitor
// Code below will need to change based on the survey link.

var displayPopup = 1; 

// Modify survey link here
var popuplink;
popuplink = "http://surveys.relevantview.com/aslaxequsuyixal.asp";

// Change intercept rate here. Below it is set to 50% 
var viewPercent = 100; 
// if random value over percent dont view 
var nth = 100; 

var posLeft;
var posTop;

posLeft = 100;
posTop = 200;



var rnd = Math.floor(Math.random() * nth) + 1; 

if (rnd > viewPercent) { var displayPopup = 0; } 


// function to get cookie from browser 
function rv_getCookie (name) 
{ 
	var dc = document.cookie; 
	var cname = name + "="; 
	var clen = dc.length; 
	var cbegin = 0; 
	while (cbegin < clen) 
	{ 
	var vbegin = cbegin + cname.length; 
	if (dc.substring(cbegin, vbegin) == cname) 
	{ 
	var vend = dc.indexOf (";", vbegin); 
	if (vend == -1) 
	vend = clen; 
	return unescape(dc.substring(vbegin, vend)); 
	} 
	cbegin = dc.indexOf(" ", cbegin) + 1; 
	if (cbegin== 0) break; 
	} 
	return null; 
} 

// Function to get RV cookie
if(rv_getCookie('RecruitingPopupAtom')) {
	var surveyTaken = rv_getCookie('RecruitingPopupAtom'); } else { surveyTaken=0; }


//Function to load interstitial
function AutoLoadPopup()
{ 
	// COMMENTED OUT 12/17 MCY DUE TO SCHEDULE ERRORS
	/*


	surveyTaken = rv_getCookie('RecruitingPopupAtom'); 

	if(rv_getCookie('RecruitingPopupAtom')) {
		var surveyTaken = rv_getCookie('RecruitingPopupAtom'); } else { surveyTaken=0; }
		
	var domainrelevantview = false;
	if (location.href.indexOf("surveys.relevantview.com") != -1){
		domainrelevantview = true;
	}
	
	if((displayPopup == "1") && (surveyTaken != "1") &&!(domainrelevantview))
	{ 
		DisplayPopup(); 
	}
	*/
} 


//Write Pop-up. The logo, images and colors should be modified here.
function DisplayPopup()
{ 
	expdate = new Date(); 
	expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 30 * 5); 
	document.cookie = "RecruitingPopupAtom=1; expires=" + expdate.toGMTString() + "; path=/"; 
	
		showAd('pop');
	
}

function showAd(divId) 
{ 
 //alert(document.getElementById('flash_carousel'));
 //alert(document.getElementById(divId));
if (document.layers) document.layers[divId].visibility = 'show';
  else if (document.all) document.all[divId].style.visibility = 'visible';
  else if (document.getElementById) document.getElementById(divId).style.visibility = 'visible';
   
   
  //  alert(document.getElementById(divId).style.visibility);
}


function hideAd(divId) 
{ 

if (document.layers) document.layers[divId].visibility = 'hide';
  else if (document.all) document.all[divId].style.visibility = 'hidden';
  else if (document.getElementById) document.getElementById(divId).style.visibility = 'hidden';
}


//Function to hide Interstitial
setTimeout("hideAd(\'pop\');",30000);



// CALL THE AutoLoadPopup() function on load of the page where the interstitial should be displayed. e.g. : <body onload=AutoLoadPopup() ></body>