function getHilo(hilo) {
	if ((hilo!="high")||(hilo!="low")) {
		hilo="high";
	}
	if (getCookieValue("hilo")) {
		hilo=getCookieValue("hilo");
	}
	if (getParam("hilo")!="") {
		hilo=getParam("hilo");
		writeSessionCookie("hilo",hilo);
	}
	return hilo;
}

function fixLink(hilo) {
	var link=document.getElementById("hilo");
	notHilo=(hilo=="low"?"high":"low");
	link.href=link.href.replace(/\&?hilo=(high|low)/,"");
	link.href=link.href.replace("#","")+(link.href.indexOf("?")>0?"&":"?")+"hilo="+notHilo;
	link.innerHTML="[ switch to "+notHilo+"-bandwidth version ]";
}

function getParam(name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if( results == null ) {
		return "";
	} else {
		return results[1];
	}
}
