// Font Size Selector object, works with Flash Object sd006
// This object overrides the any font size associate with the body tag
// to provide user control over font size, by appending an in-line style.
// The font size is selected from the sizeLookup array. The index is saved in 
// a cookie for later retrieval.

// load immediately after the "body" tag.

var coeusTechnologyFontSize = {
	
	index:0,
	sizeLookup: ["8px", "10px", "12px", "14px", "16px", "18px", "20px", "22px", "24px"],

// sets a new font size and saves the index value in a cookie.
	set: function(setIndex) {
		this.index = parseInt(setIndex);
		document.body.style.fontSize = this.sizeLookup[this.index];
		var date = new Date();
		date.setYear(parseInt(date.getFullYear())+1);
		document.cookie = "coeusTechnology_fontSize=" + this.index + "; expires=" + date.toUTCString();
	},
	
// Gets the current index so that it can be returned to the flash object (sd006) to 
// set its pointer to the current value.
	getIndex: function(){
		var fontSizeStringIndex=document.cookie.indexOf("coeusTechnology_fontSize");
		if (fontSizeStringIndex > -1) {
			var fontSizeString = document.cookie.substring(fontSizeStringIndex);
			this.index = parseInt(fontSizeString.substring(fontSizeString.indexOf("=")+1));
		}
		else {
			// cookie not set, so set cookie
			this.set(4);
		}
		return this.index;
	},
	
// Call this function every page load to set the previously selected font size.
// If no cookie is found, then the font size is set to the mid value.
	initialise: function() {
		document.body.style.fontSize = this.sizeLookup[this.getIndex()];
	}
} // end of coeusTechnologyFontSize object

// auto initialise
coeusTechnologyFontSize.initialise();

