function setActiveSiteStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { if(a.getAttribute("title").indexOf("site") != 1) a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } } function setActiveWidthStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { if(a.getAttribute("title").indexOf("width") != 1) a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } } function setActiveFontStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { if(a.getAttribute("title").indexOf("font") != 1) a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } } function getActiveSiteStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled && a.getAttribute("title").indexOf("site") != -1) return a.getAttribute("title"); } return null; } function getActiveFontStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled && a.getAttribute("title").indexOf("font") != -1) return a.getAttribute("title"); } return null; } function getActiveWidthStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled && a.getAttribute("title").indexOf("width") != -1) return a.getAttribute("title"); } return null; } function getPreferredSiteStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title") && a.getAttribute("title").indexOf("site") != -1 ) return a.getAttribute("title"); } return null; } function getPreferredFontStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title") && a.getAttribute("title").indexOf("font") != -1 ) return a.getAttribute("title"); } return null; } function getPreferredWidthStyleSheet() { var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title") && a.getAttribute("title").indexOf("width") != -1 ) return a.getAttribute("title"); } return null; } function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } window.onload = function(e) { var cookie = readCookie("sitestyle"); var title = cookie ? cookie : getPreferredSiteStyleSheet(); setActiveSiteStyleSheet(title); if(title.indexOf('nuts') != -1) { document.getElementById('style_site').innerHTML = 'nuts' } var cookie = readCookie("fontstyle"); var title = cookie ? cookie : getPreferredFontStyleSheet(); setActiveFontStyleSheet(title); if(title.indexOf('sans') != -1) { document.getElementById('style_font_first').innerHTML = 'A' document.getElementById('style_font_second').innerHTML = 'a' } var cookie = readCookie("widthstyle"); var title = cookie ? cookie : getPreferredWidthStyleSheet(); setActiveWidthStyleSheet(title); if(title.indexOf('flexy') != -1) { document.getElementById('style_width').innerHTML = 'flexy' } } window.onunload = function(e) { if (stuffset == true) { var title = getActiveSiteStyleSheet(); createCookie("sitestyle", title, 365); title = getActiveFontStyleSheet(); createCookie("fontstyle", title, 365); title = getActiveWidthStyleSheet(); createCookie("widthstyle", title, 365); } } var stuffset = false var cookie = readCookie("sitestyle"); var title = cookie ? cookie : getPreferredSiteStyleSheet(); setActiveSiteStyleSheet(title); var cookie = readCookie("fontstyle"); var title = cookie ? cookie : getPreferredFontStyleSheet(); setActiveFontStyleSheet(title); var cookie = readCookie("widthstyle"); var title = cookie ? cookie : getPreferredFontStyleSheet(); setActiveFontStyleSheet(title); function swapstyle(thing) { stuffset = true; switch(thing){ case 'font': if(document.getElementById('style_font_first').innerHTML == 'a'){ document.getElementById('style_font_first').innerHTML = 'A' document.getElementById('style_font_second').innerHTML = 'a' setActiveFontStyleSheet('font-sans') } else { document.getElementById('style_font_first').innerHTML = 'a' document.getElementById('style_font_second').innerHTML = 'A' setActiveFontStyleSheet('font-serif') } break; case 'site': if(document.getElementById('style_site').innerHTML == 'sane'){ document.getElementById('style_site').innerHTML = 'nuts' setActiveSiteStyleSheet('site-nuts') } else { document.getElementById('style_site').innerHTML = 'sane' setActiveSiteStyleSheet('site-sane') } break; case 'width': if(document.getElementById('style_width').innerHTML == 'fixed'){ document.getElementById('style_width').innerHTML = 'flexy' setActiveWidthStyleSheet('width-flexy') } else { document.getElementById('style_width').innerHTML = 'fixed' setActiveWidthStyleSheet('width-fixed') } break; } }