// topoCookie.js
/* <SCRIPT>
* JavaScript functions to handle cookies
* Rasmus Holm Jensen
* Eagle Technology 2003
*/

function topoReadCookie(name) {
 
 if (document.cookie == '') {
	return false;
 } 
 else {

 var firstChar, lastChar;
 var theBigCookie = document.cookie;
 firstChar = theBigCookie.indexOf(name);
 
 if(firstChar != -1) {
 	firstChar += name.length + 1;
 	lastChar = theBigCookie.indexOf(';', firstChar);
 	
	if(lastChar == -1) lastChar = theBigCookie.length;
		return unescape(theBigCookie.substring(firstChar, lastChar));
 	} 
	else {
 		return false;
 	}
 }
}

function topoSaveCookie(strName, strValue){
 	var strCookie = document.cookie;
 	var today = new Date();
 	var expiry = new Date(today.getTime() + 120 * 1000);
 	document.cookie=strName + "=" + escape(strValue) + "; path=/";
 }

 var numWRes = 0;
 var numHRes = 0;
 var userScreenSize = 15;

function setTopoScreen (rdoValue) {
 	userScreenSize = rdoValue;
}


function topoCalculatePPI() {
 	var topoPPI = 116;
 	var strSize = topoReadCookie("ScreenSize");
 	var wScreenRes = screen.width;
 	var wScreenWidthInch = strSize;

 	if (strSize == "15"){
 	 wScreenWidthInch = 12;
 	}
 	else if (strSize == "17"){
 	 wScreenWidthInch = 12.5;
 	}
	else if (strSize == "19"){
 		wScreenWidthInch = 14.6;
 	}
 	else if (strSize == "21"){
 		wScreenWidthInch = 15.9;
 	}
 	else if (strSize == "False"){
 		wScreenWidthInch = 12.5
 	}

 	topoPPI = wScreenRes/wScreenWidthInch;
	return topoPPI;

}
