styleswitcher = {
	chooseStyle: function(newstyle) {
		if (newstyle == styleswitcher.currentStyle()) return;
		var expdate = new Date();
		expdate.setTime(expdate.getTime()+(1000*3600*24*365));
		styleswitcher.createCookie('style', newstyle, 365);
		// alert('This style choice will persist for a year unless changed again.\nYou may need to reload the page.');
		if (document.getElementById) {
			var i, a, main;
			for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
				if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
					a.disabled = true;
					if(a.getAttribute("href") == '/stylesheets/switch/'+newstyle+'.css') a.disabled = false;
				}
			}
			ieLayoutFix.fixLayout(true);
		} else {
			self.location = self.location;
		}
	},
	createCookie: function(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=/";
	},
	currentStyle: function() {
		var name = 'style=';
		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(name) == 0) return c.substring(name.length,c.length);
		}
		return 'default';
	}
}
