<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link id="dynCSS" rel="stylesheet" type="text/css" href="">
<script type="text/javascript">
DynCSS = {
css: [
{ title: 'CSS1', url: '/pathto/css1.css' },
{ title: 'CSS2', url: '/pathto/css2.css' },
{ title: 'CSS3', url: '/pathto/css3.css' }
],
id2e: function(id) { return document.getElementById(id); },
init: function() {
this.renderOptions();
var icss = (icss = String(document.cookie).match(/\bdyncss=([^;]*)/)) && icss[1];
this.setCSS(icss);
},
setCSS: function(icss) {
var s = this.id2e('dynCSSSelect');
if (!arguments.length) icss = s.value;
else s.value = this.css[icss = parseInt(icss) || 0] ? icss : 0;
var css = this.css[icss];
this.id2e('dynCSS').href = css.url;
var d = new Date();
d.setFullYear(d.getFullYear() + 1);
document.cookie = ['dyncss=', icss, ';expires=', d.toGMTString(), ';path=/;'].join('');
return this;
},
renderOptions: function() {
for (var i = 0, s = this.id2e('dynCSSSelect'); i < this.css.length; ++i)
s.options.add(new Option(this.css[i].title, i));
}
};
</script>
</head>
<body>
<select id="dynCSSSelect"></select>
<button type="button" onclick="DynCSS.setCSS()">go</button>
<script type="text/javascript">DynCSS.init();</script>
</body>
</html>