//---Thanks to alistapart and RNIB
//---Modified by Peter Hammans
var oFontsize = {
	aLinks : ["small", "medium", "large"],
	sContainerId : "wrapper",
	nSize : 80,
	createCookie : function(sName, sValue, nDays) {
		if (nDays) {
			var oDate = new Date();
			oDate.setTime(oDate.getTime() + (nDays * 24 * 60 * 60 * 1000));
			var sExpires = "; expires=" + oDate.toGMTString();
		} else { 
			sExpires = "";
		};
		document.cookie = sName + "=" + sValue + sExpires + "; path=/tna/20081105144808/http://www.environment-agency.gov.uk/";
	},
	readCookie : function(sName) {
		var sNameEQ = sName + "=";
		var aValues = document.cookie.split(";");
		for(var i = 0; i < aValues.length; i++) {
			var sValue = aValues[i];
			while (sValue.charAt(0) == " ") sValue = sValue.substring(1, sValue.length);
			if (sValue.indexOf(sNameEQ) == 0) {
				return sValue.substring(sNameEQ.length, sValue.length);
			};
		};
		return null;
	},
	changeSize : function() {
		for(var i = 0; i < oFontsize.aLinks.length; i++) {
			var oLink = document.getElementById(oFontsize.aLinks[i]);
			oLink.onclick = function() {
				oFontsize.setActiveSize(this.id);
			};
		};
	},
	setActiveSize : function(sFontsize) {
		var oPage = document.getElementById(oFontsize.sContainerId);
		if(oPage) {	
			oPage.className = sFontsize;
		};
		return null;
	},
	onunload : function() {
		var oPage = document.getElementById(oFontsize.sContainerId);
		if(oPage) {	
			oFontsize.createCookie("style", oPage.className, 365);	
		};
	},
	onload : function() {
		var sCookie = oFontsize.readCookie("style");
		if(sCookie) {
			oFontsize.setActiveSize(sCookie);	
		};
		oFontsize.changeSize();
	}	
};
		
attachEvent(oFontsize.onload, "onload");
attachEvent(oFontsize.onunload, "onunload");





