/*CDO monthly statistics tables javascript. Last modified:19/06/2008 */

var maxtable="98%";
var maxfont="1.1em";
var normaltable="995px";
var normalfont="0.9em";


//Toggle table width and font size. Set a cookie to last session only
function tablesize (magnify) { 
	if (magnify == "normal") {
		document.getElementById("table-container").style.width = normaltable;
		document.getElementById("table-container").style.fontSize = normalfont;
	}
	else{
		document.getElementById("table-container").style.width =maxtable;
		document.getElementById("table-container").style.fontSize = maxfont;
	} 
 	setCookie('CDOTABLESIZE',document.getElementById("table-container").style.width);
}


function setCookie(c_name,value)
{
	document.cookie=c_name+"="+escape(value);
}


function getCookie(c_name)
{
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}


//Read in the preferred table and font size when loading new page.
function setpreference(){
	tablewidth=getCookie("CDOTABLESIZE");
	document.getElementById("table-container").style.width=tablewidth; 
	if (tablewidth == maxtable) { 
		document.getElementById("table-container").style.fontSize = maxfont;
		document.selection.tablesizebutt[0].checked = false;
		document.selection.tablesizebutt[1].checked = true;
	}
	else{
		document.getElementById("table-container").style.fontSize = normalfont;
		document.getElementById("table-container").style.width=normaltable;
		document.selection.tablesizebutt[0].checked = true;
		document.selection.tablesizebutt[1].checked = false;
	}
}


//function to swap class properties
function changecss(theClass,element,value) {
	//documentation for this script at http://www.shawnolson.net/a/503/
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	}
	else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	for (var S = 0; S < document.styleSheets.length; S++){
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
				document.styleSheets[S][cssRules][R].style[element] = value;
			}
		}
	}	
}


//Where is this function being used??
/*
function setKey(tablestate) {
	if (tablestate == "highest") { 
		document.getElementById("tablekey2").style.display = "none";
		document.getElementById("tablekey1").style.display = "block";
	}
	else {
		document.getElementById("tablekey1").style.display = "none";
		document.getElementById("tablekey2").style.display = "block";
	}
}*/
	