// VARIABLES //

var surveyOn='yes';  
// Switch the survey on and off. Must be 'yes' or 'no' in lower case 
// and within quotes

var daysOut=270;	
// number of days the survey will remain hidden once it has been seen

var chance=1;		
// number sides of the dice that will be thrown to decide who gets 
// to see the survey e.g. 20 means that 1 visitor in 20 will see the survey.

var pWidth=320;
var pHeight=330;
// Width and height of popup in pixels

var leftDist=400;
// Distance of left hand edge of pop-up from left hand edge of window in pixels

var topDist=250;
// Distance of top edge of pop-up from top edge of window in pixels

var TandCdisplay='yes';
// Whether or not to display link to Terms and Conditions.
// Must be 'yes' or 'no' in lower case and within quotes marks.

var TandCurl='http://www.keysurvey.com/survey/409169/2398/';
// URL of Terms and Conditions. Must be within quote marks.

var surveyURL='http://www.keysurvey.com/survey/405576/4002/';
// URL of Survey. Must be within quote marks.

var logo1='logos/boots_resized_2.png';
// path and filename of left or only logo. Must be within quote marks.

var logo2='';
// path and filename of right logo. Must be within quote marks. If none, use '';

var baseURL='http://enhance-media.s3.amazonaws.com';
// URL where logos and CSS file can be found.


// SEE ALSO EMsurvey.css //
// END OF VARIABLES //


document.write('<style type="text/css">\n');
document.write('@import url("'+baseURL+'/EMsurvey.css");\n');
document.write('</style>\n');
document.write('<div id="blanket" style="display:none;"></div>\n');
document.write('<div id="popUpDiv" class="EMpop"\n');
document.write('style="display:none;"></div>');

function eBSetCookie(cookieName,cookieValue,nDays){
	var eBtoday=new Date();
	var eBexpire=new Date();
	if (nDays==null||nDays==0)nDays=1;
	eBexpire.setTime(eBtoday.getTime()+3600000*24*nDays);
	document.cookie=cookieName+'='+escape(cookieValue)
	+';path=/ ;expires='+eBexpire.toGMTString();
}
function eBReadCookie(cookieName){
	var eBCookie=''+document.cookie;
	var eBind=eBCookie.indexOf(cookieName);
	if (eBind==-1||cookieName=='')return'';
	var eBind1=eBCookie.indexOf(';',eBind);
	if (eBind1==-1)eBind1=eBCookie.length;
	return unescape(eBCookie.substring(eBind+cookieName.length+1,eBind1));
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
//	popUpDiv_height=topDist;
//	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	document.getElementById('popUpDiv').style.left = leftDist + 'px';
	document.getElementById('popUpDiv').style.width = pWidth + 'px';
	document.getElementById('popUpDiv').style.height = pHeight + 'px';
	document.getElementById('popUpDiv').style.top = topDist + 'px';
	window.scroll(0,0);
}

function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('blanket');
	toggle(windowname);		
}

var EMtext='<a href="#" onclick="popup(\'popUpDiv\');">';
EMtext=EMtext+'<img src="'+baseURL+'/w_close.gif" hspace="5" ';
EMtext=EMtext+'style="float:right;" vspace="6" border="0" /></a>';
EMtext=EMtext+'<img src="'+baseURL+'/'+logo1+'" vspace="8"  />';
EMtext=EMtext+'<p class="EMheader">Visitor Survey</p>';
EMtext=EMtext+'<p class="EMmain">';
EMtext=EMtext+'<p class="EMmain">';
EMtext=EMtext+'We are conducting a short survey about Online Recruitment and ';
EMtext=EMtext+'we would appreciate you taking a few minutes to give us your ';
EMtext=EMtext+'views. This survey will take about 5 minutes of your time and ';
EMtext=EMtext+'the information will only be used for research purposes ';
EMtext=EMtext+'and to help us improve our careers website.<br>';
EMtext=EMtext+'<p class="EMmain">';
EMtext=EMtext+'<p class="EMmain">';
EMtext=EMtext+'<a href="'+surveyURL+'" target="_blank" onclick="popup(\'popUpDiv\'';
EMtext=EMtext+');"     ><img src="'+baseURL+'/green-button.png" alt="Take Survey" ';
EMtext=EMtext+' border=0></a><a href="#" onclick="popup(\'popUpDiv\');">';
EMtext=EMtext+'<img src="'+baseURL+'/Red-button2.png" border=0  alt="No ';
EMtext=EMtext+'Thanks" border=0></a>';
if(TandCdisplay=="yes") {
	EMtext=EMtext+'<BR><p class="EMsmall"><a href="';
	EMtext=EMtext+TandCurl+'" target="_blank">Terms and Conditions</a>';
}
EMtext=EMtext+'</p>';
document.getElementById('popUpDiv').innerHTML=EMtext;


if(surveyOn=='yes') {
	var rnd=Math.floor(Math.random()*chance);
	if(rnd==0) {
		var surveySeen=eBReadCookie('EMSeen');
		if (surveySeen!='yes') {
			eBSetCookie('EMSeen','yes',daysOut);	
			popup('popUpDiv');
		}
	}
}


