var sessioncookiename="sureytimer";
var persistentcookiename="surveycomplete";
var debug=false;
var minutes=5;
var countdown=minutes*60*1000;
var ms_year=365*24*60*60*1000;
var exclude=1;
var agt=navigator.userAgent.toLowerCase();

var today = new Date();
var expiry_date = new Date(today.getTime() + ms_year);
function setStyleById(i, p, v)
{
	var n = document.getElementById(i);
	n.style[p] = v;
}

function displaySurvey()
{
	
	SetCookie(persistentcookiename,"true",expiry_date,"/");
	SetCookie(sessioncookiename,today.getTime(),null,"/");
	
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth ;
		y = document.body.clientHeight;
	}
	surveyWidth = document.getElementById("survey").clientWidth;
	surveyHeight = document.getElementById("survey").clientHeight;
	scrollDistance = document.documentElement.scrollTop
	
	//setStyleById("survey","left",(x-surveyWidth-40) + "px");
	setStyleById("survey","left",(10) + "px");
	setStyleById("survey","top",(y-surveyHeight-20+scrollDistance) + "px");
	setStyleById("survey","visibility","visible");
}

function hideSurvey()
{
	document.getElementById('survey').style.visibility='hidden';
	
}

function initSurvey()
{
	if(debug)alert("Checking cookie states");	
	if (GetCookie(persistentcookiename)==null)
	{
		// Customer has not been surveyed
		if (GetCookie(sessioncookiename)==null)
		{  
			SetCookie(sessioncookiename,today.getTime(),null,"/");
			if(debug)alert("New session cookie");
			if(GetCookie(sessioncookiename)!=null)
				setTimeout("displaySurvey()",countdown);		
		}
		else
		{
			if(debug)alert("Session cookie already set");
			cookieDate=GetCookie(sessioncookiename);
			if ((today.getTime()-cookieDate) >= countdown)
			{
				if(debug)alert("Session cookie time older than "+minutes+" minute - show the survey")
				displaySurvey();
			}
			else
				setTimeout("displaySurvey()",countdown - (today.getTime()-cookieDate));
		}
	}
	else
		if(debug)alert("Persistent cookie already set, don't show the survey");

}

function writeSurvey()
{
	
	document.writeln('<div id="survey" style="visibility: hidden">');
	document.writeln('	<div style="float: right"><a href="javascript:void(0)" onClick="hideSurvey()">X close</a></div>');
	document.writeln('	<p class="statement">We value your opinion.  We have recently updated the Entrust Website and would like to gather your feedback.  Please take a moment to complete this short questionnaire.</p>');
	document.writeln('	<p class="statement">What type of information are you looking for today?<br />');
	document.writeln('	Please check all that apply.</p>');
	document.writeln('	<form action="/survey.cfm" method="post">');
	document.writeln('	<input type="checkbox" name="type_info" value="2-factor authentication" />2-factor authentication<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Access control/web portal security" />Access control/web portal security<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Compliance products" />Compliance products<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Data protection solutions" />Data protection solutions<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Email security" />Email security<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="PKI products" />PKI products<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Secure identity management solutions" />Secure identity management solutions<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="SSL certificates" />SSL certificates<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Web services security" />Web services security<br />');
	document.writeln('	<input type="checkbox" name="type_info" value="Other" />Other, please explain <input type="text" name="type_info_other" size="50"><br /><br />');
	document.writeln('<p class="statement">Were you aware that Entrust provides all the solutions listed above?</p>');
	document.writeln('<input type="radio" name="aware" value="yes" /> Yes');
	document.writeln('<input type="radio" name="aware" value="no" /> No');
	document.writeln('<br /><br />');
	document.writeln('<p class="statement">How easy was it to find the information you were looking for today?</p>');
	document.writeln('<table border="0" cellpadding="5" cellspacing="0" width="100%" id="survey_rating">');
	document.writeln('	<tr align="center">');
	document.writeln('		<td>1<br /><input type="radio" name="find_rating" value="1" /></td>');
	document.writeln('		<td>2<br /><input type="radio" name="find_rating" value="2" /></td>');
	document.writeln('		<td>3<br /><input type="radio" name="find_rating" value="3" /></td>');
	document.writeln('		<td>4<br /><input type="radio" name="find_rating" value="4" /></td>');
	document.writeln('		<td>5<br /><input type="radio" name="find_rating" value="5" /></td>');
	document.writeln('		<td>6<br /><input type="radio" name="find_rating" value="6" /></td>');
	document.writeln('		<td>7<br /><input type="radio" name="find_rating" value="7" /></td>');
	document.writeln('		<td>8<br /><input type="radio" name="find_rating" value="8" /></td>');
	document.writeln('		<td>9<br /><input type="radio" name="find_rating" value="9" /></td>');
	document.writeln('		<td>10<br /><input type="radio" name="find_rating" value="10" /></td>');
	document.writeln('	</tr>');
	document.writeln('	<tr align="center">');
	document.writeln('		<td colspan="3">Very difficult</td>	');
	document.writeln('		<td colspan="4">Average</td>');
	document.writeln('		<td colspan="3">Very easy</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('<p class="statement">What directed you to our Website today?</p>');
	document.writeln('<select name="resource">');
	document.writeln('	<option value="">Please select</option>');
	document.writeln('	<option value="Referral from friend / colleague">Referral from friend / colleague</option>');
	document.writeln('	<option value="Search engine">Search engine</option>');
	document.writeln('	<option value="Trade show">Trade show</option>');
	document.writeln('	<option value="Trade magazine or web article link">Trade magazine or web article link</option>');
	document.writeln('	<option value="Marketing email or direct mail">Marketing email or direct mail</option>');
	document.writeln('	<option value="Partner / customer referral or website link">Partner / customer referral or website link</option>');
	document.writeln('	<option value="other">Other');
	document.writeln('</select>');
	document.writeln('<br />If other, please explain <input type="text" name="resource_other" size="50"><br /><br />');
	document.writeln('<p class="statement">Do you have any suggestions for improvement?</p>');
	document.writeln('	<textarea name="improvement" id="improvement"></textarea>');
	document.writeln('<p class="statement">What is your level of responsibility?</p>');
	document.writeln('<select name="level">');
	document.writeln('	<option value="">Please select</option>');
	document.writeln('	<option value="CIO or SVP of IT">CIO or SVP of IT');
	document.writeln('	<option value="Non-technical Executive">Non-technical Executive');
	document.writeln('	<option value="Privacy / Compliance / Regulatory Staff">Privacy / Compliance / Regulatory Staff');
	document.writeln('	<option value="Technical Management">Technical Management');
	document.writeln('	<option value="Technical Staff">Technical Staff');
	document.writeln('	<option value="Non-technical Management / Staff">Non-technical Management / Staff');
	document.writeln('	<option value="Procurement">Procurement');
	document.writeln('	<option value="Administrative Staff">Administrative Staff');
	document.writeln('	<option value="Other">Other');
	document.writeln('</select>');
	document.writeln('<br />If other, please explain <input type="text" name="level_other" size="50"><br /><br />');
	document.writeln('<br />');
	document.writeln('	<p><input type="image" src="/images/common/button_submit-form.gif" alt="Submit Form" /></p>');
	document.writeln(' <p style="float:right"><a href="/privacy/index.htm" target="_blank">Privacy Statement</a></li></p>');
	document.writeln('</div>');

}

if(agt.indexOf('mac')==-1)
{
	//writeSurvey();
	//initSurvey();
}




