function styleswitch(mode, setstyle){ var i, a; var stylepath = 'http://www.sdsameda.com/joomla/templates/colorfusion/css/'; // setting the path to the CSS directory var cookstyle = Cookie.get('Stylesheet'); // getting current cookie value for the stylesheet if (cookstyle == false ) { for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf('stylesheet') != -1 && a.getAttribute("title") // find default stylesheet, which is defined in the head section of the document ) { cookstyle = a.getAttribute("title"); Cookie.set('Stylesheet', cookstyle, {duration:365, path:"/"}); //set the default stylesheet as cookie value } } } switch (mode) { case 'set' : new Asset.css(stylepath + setstyle, {id: setstyle}); // loads the new stylesheet Cookie.set('Stylesheet', setstyle, {duration:365, path: "/"}); // sets the stylesheet into a cookie value break; case 'noset' : new Asset.css(stylepath + setstyle, {id: setstyle}); // only apply the new stylesheet, without saving it in a cookie value break; default : new Asset.css(stylepath + cookstyle, {id: cookstyle}); // sets the current cookie value as active stylesheet break; } return null; } window.addEvent('domready', styleswitch);