//**********
// Cookie defined as:
// cssdata=XYZ
// where:
// X = style
// Y = fontsize (this is a "pointer" to the fontsizes array)
// Z = mode
//
// Expiry date for cookie set using functions which gets the date from the machine
// Avoid typing in date yourself since different computers and OS's store and display
// dates differently.
//**********
var style = 0;
var fontsize = 0;
var mode = 0;


//**********
// fgcol (forground colour) is the colour of the text
// bgcol (background colour) is the colour of the page
// textsizes is the different sizes of text available
//**********
var fgcol = new Array("000000", "000000", "FFFFFF", "FFFF00", "FFFFFF");
var bgcol = new Array("FFFFFF", "FFFFFF", "000000", "000000", "0000FF");
var fontsizes = new Array(6, 8, 10, 12, 16, 20, 30, 40, 50, 60);

//* Search for cookies relevant to the site and find position of the string
var allcookies = document.cookie;
var pos = allcookies.indexOf("cssdata=");

if(pos != -1)
{
	//* Cookie exists. Extract relevant data items
	var start = pos + 8;
	var end = allcookies.indexOf(";", start);
	if(end == -1)
		end = allcookies.length;

	var value = allcookies.substring(start, end);

	style = value.substring(0, 1);
	fontsize = value.substring(1, 2);
	mode = value.substring(2, 3);
}
else
{
	//* If the cookie does not exist, create one
	//* Expiry date is required to allow cookie to be created
	var the_cookie = "cssdata=120";
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	the_cookie = the_cookie + ";expires=" + nextyear.toGMTString();
	document.cookie = the_cookie;

	style = 1;
	fontsize = 2;
	mode = 0;
}

//*** This is the actual stylesheet ***
document.write('<style type="text/css">');
document.write("BODY { BACKGROUND-COLOR: #" + bgcol[style] + " }");
document.write("A, P, TR, TD, CAPTION { FONT-FAMILY: Arial, Verdana, Helvetica; FONT-SIZE: " + fontsizes[fontsize] + "pt; COLOR: #" + fgcol[style] + "; }");
document.write("a.header {text-decoration: none}")
document.write("a.header:hover {text-decoration: underline}")
document.write("</style>");
