function createCookie( name, value, days ) { var expires; 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 cookies = document.cookie.split(';'); for( var i=0; i < cookies.length; i++ ) { var c = cookies[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; } ActiveStyle = Class.create(); ActiveStyle.prototype = { _styles: [], initialize: function() { var i, el; var els = document.getElementsByTagName("link"); for( var i = 0; i < els.length ; i++ ) { el = els[i]; if( el.getAttribute("rel").indexOf("style") != -1 && el.getAttribute("title") ) { this._styles.push( el ); } } var style = readCookie( "style" ); style = this._styles[0].getAttribute("title"); this.enable( style ); }, enable: function( act_style ) { this._styles.each( function( s ) { s.disabled = true; if( s.getAttribute("title") == act_style ) { s.disabled = false; } }); this._current = act_style; // $("menu_style").innnerHTML = this.genHTML(); }, current: function() { return this._current; }, genHTML: function() { var html = ""; html += '-' + ' style: ' + '1' + '' + ' | ' + '2'; return html; } } /* window.onunload = function( e ) { var title = activeStyle.current(); createCookie( "style", title, 365 ); } */ var as = new ActiveStyle();