// Check URL for thm parameter and add a cookie and a css stylesheet
function setThm()
{
	var urlparams = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	var thm = '';
    for(var i = 0; i < urlparams.length; i++)
    {
        pair = urlparams[i].split('=');
		if (pair[0] == 'thm') {
			thm = pair[1];
			// SET COOKIE
			var yum= "thm=" + thm + '; secure; path=/';
			document.cookie=yum;
		}
    }
    if(thm == '' ) {
		// 	look for cookie and set thm
		cookies=document.cookie.split(";")
		for (i=0;i<cookies.length;i++)
		{
		  if(cookies[i].substr(1,cookies[i].indexOf("=")) == "thm=") {
			var cthm = cookies[i].split("=");
			thm = cthm[1];
		  }
		}
	}
	if(thm.length == 3) {
		document.write("<link rel=\"stylesheet\" type=\"text/css\" media=\"screen, handheld\" href=\"/files/", thm, ".css\" \\>");	
	}
}
setThm();
