//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 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)

function initStyle() { var formref=document.getElementById("switchform"); indicateSelected(formref.choice); }

document.write('<form action="" id="switchform"><div align="center" id="styleswitch_block"><div id="styleswitch_topbar" title="Themes" onClick="document.getElementById(\'switchselect\').focus()">&nbsp;Themes</div><select name="choice" size="1" onChange="chooseStyle(this.options[this.selectedIndex].value, 60)" class="styleswitch" id="switchselect"><option value="none" selected="selected" style="background:#f5f5f5 none;">Grey</option><option value="Blue Theme" style="background:#EFF7FF none;">Blue</option><option value="Brown Theme" style="background:#FFFAEF none;">Brown</option><option value="Red Theme" style="background:#ffeaea none;">Red</option><option value="Green Theme" style="background:#eaffea none;">Green</option><option value="Purple Theme" style="background:#ffeaff none;">Purple</option></select></div></form>');

