/** * styleswitch stylesheet switcher built on jquery * under an attribution, share alike license * download by http://www.codefans.net * by kelvin luck ( http://www.kelvinluck.com/ ) **/ (function($) { $(document).ready(function() { $('.styleswitch').click(function() { switchstylestyle(this.getattribute("rel")); return false; }); var c = readcookie('style'); if (c) switchstylestyle(c); }); function switchstylestyle(stylename) { var ifrm = $("#rightmain").contents(); $('link[rel*=style][title]').each(function(i) { this.disabled = true; if (this.getattribute('title') == stylename) this.disabled = false; }); ifrm.find('link[rel*=style][title]').each(function(i) { this.disabled = true; if (this.getattribute('title') == stylename) this.disabled = false; }); createcookie('style', stylename, 365); } })(jquery); // cookie functions http://www.quirksmode.org/js/cookies.html 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 var 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; } function erasecookie(name) { createcookie(name,"",-1); } // /cookie functions