/* DHTML popovers */
function getOSName() {
    var OSName="Unknown OS";
    if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
    if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
    if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
    if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
    return OSName;
}
function showSplash() {
    document.getElementById('overlaySplash').style.visibility='visible';
    document.getElementById('overlaySplashInner').style.visibility='visible';
    document.getElementById('overlaySplash').style.display='block';
    document.getElementById('overlaySplashInner').style.display='block';
}
function hideSplash() {
    document.getElementById('overlaySplash').style.visibility='hidden';
    document.getElementById('overlaySplashInner').style.visibility='hidden';
    document.getElementById('overlaySplash').style.display='none';
    document.getElementById('overlaySplashInner').style.display='none';
}
function remindSplash() {
	document.getElementById('overlaySplash').style.visibility='hidden';
	document.getElementById('overlaySplashInner').style.visibility='hidden';	
	document.getElementById('overlaySplash').style.display='none';
	document.getElementById('overlaySplashInner').style.display='none';
	count=0;
	createCookie('surveyCount', count, noDaysCookieLasts);
}

// Survey Cookie 

var noDaysCookieLasts = 999; // number of days the survey cookie should last

function checkSurveyCount() {
	var page = window.location;
	var count = readCookie('surveyCount');
	if (count == null) {
		count=1;
		createCookie('surveyCount', count, noDaysCookieLasts);
	}
	else {
		count++;
		if (count == 3) {
			showSplash();		
		}
		createCookie('surveyCount', count, noDaysCookieLasts);
   }
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();	
	} 
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return (c.substring(nameEQ.length,c.length));
	}
	return null;
}

window.onload = function(e) {
	//checkSurveyCount();
	//uncomment the above to enable
}
