var CSS = "";
var CSSNumber = "";
var CSSMax = 15;
function CSSArray () {
	this[1] = "berries";
	this[2] = "zen";
	this[3] = "spring";
	this[4] = "summer";
	this[5] = "autumn";
	this[6] = "winter";
	this[7] = "bible";
	this[8] = "red";
	this[9] = "elegance";
	this[10] = "deeppurple";
	this[11] = "storm";
	this[12] = "flashkid";
	this[13] = "egypt";
	this[14] = "childhood";
	this[15] = "bonsai";

}
CSSs = new CSSArray ();
CSSNumber = Math.floor (Math.random () * CSSMax) + 1;
CSS = CSSs[CSSNumber]+'.css';

var URL = "";
var URLNumber = "";
var URLMax = 28;
function URLArray () {
	this[1] = "muddyroad";
	this[2] = "loveopenly";
	this[3] = "threepounds";
	this[4] = "washbowl";
	this[5] = "gatesofparadise";
	this[6] = "cupoftea";
	this[7] = "correctplacement";
	this[8] = "buddhahood";
	this[9] = "parable";
	this[10] = "stolenmoon";
	this[11] = "dreamland";
	this[12] = "livingpot";
	this[13] = "education";
	this[14] = "bullride";
	this[15] = "lie";
	this[16] = "holyman";
	this[17] = "ask";
	this[18] = "clock";
	this[19] = "causality";
	this[20] = "silent1";
	this[21] = "silent2";
	this[22] = "silent3";
	this[23] = "silent4";
	this[24] = "excuses";
	this[25] = "shorter";
	this[26] = "reasons";
	this[27] = "piglife";
	this[28] = "inout";
}
URLs = new URLArray ();
URLNumber = Math.floor (Math.random () * URLMax) + 1;
URL = URLs[URLNumber]+'.htm';

Cookies = {
	save : 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=/";
	},
	read : function (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;
	},
	erase : function(name) {
		Cookies.save(name,"",-1);
	}
}

function getPrefs() {
	var csspref = Cookies.read('css')
	if (csspref!=null) {
   		document.write('<link rel="stylesheet" href="'+csspref+'" type="text/css">');
	} else {
		document.write('<link rel="stylesheet" href="bonsai.css" type="text/css">');
	    setPref('css','bonsai.css');
	}
}

function setPref(name,value){
	Cookies.erase(name);
	Cookies.save(name,value,365);
}

function setRandStyle(){
	setPref('css',CSS);
	location = location;
	window.location.href = window.location.href;
	location.reload();
	history.go(0);
}

function setFixedStyle(value){
	setPref('css',value);
	location = location;
	window.location.href = window.location.href;
	location.reload();
	history.go(0);
}

getPrefs();
