function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function AJAXLoad(url){
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	return xmlhttp.responseText;
}

function alterReality (scale){
	setCookie("scale",scale,7);
	for(i=0; (e = document.getElementsByTagName("link")[i]); i++) {
		if(e.getAttribute("rel").indexOf("style") != -1 && e.getAttribute("title")) {
			if(e.getAttribute("title") == scale) {e.disabled = false}else{e.disabled=true};
		}
	}
}
function findReality(){
	myReality = getCookie("scale");
	if (myReality !=""){
		for(i=0; (e = document.getElementsByTagName("link")[i]); i++) {
			if(e.getAttribute("rel").indexOf("style") != -1 && e.getAttribute("title")) {
				if(e.getAttribute("title") == myReality) {e.disabled = false}else{e.disabled=true};
			}
		}
	}
}

if (window.addEventListener) {
	//for w3c compatibilty
	window.addEventListener("load",findReality,false);
}else if (window.attachEvent) {
	//for internet exploder compatibility
	window.attachEvent("onload",findReality);
}
