// Initialize the arrays containing our size info.
var min=8;
var max=17;
var initSize = 12; // default size of inital font size

function fontSizer(inc) {

	var size = readCookie('size');
	size = parseInt(inc)+parseInt(size);
	
	if (size < min ){ size = min;}	
	if (size > max){ size = max;}
	
	doFontSizing(size);	
	createCookie("size", size, 365);
}

function fontSizerOnLoad(preferredSize) {	
	var size = readCookie('size');	
	if (size < min ) { size = min; }
	if (size > max) { size = max; }
	
	doFontSizing(size);
}

function doFontSizing(theFontSize) {
	
	//aTables = document.getElementsByTagName('table');
	//	for(i = 0; i < aTables.length; i++){
	//		aTables[i].style.fontSize = theFontSize + "px";
	//	}

	
	var p = document.getElementsByTagName('BODY')[0];
	p.style.fontSize = theFontSize +"px"
	
	
	//var myElem = document.getElementById("tb_double");
 	//alert (myElem.style.width);	
	//myElem.style.width = "675px";

	
}

function normalSize() {
	var size = 12;
	doFontSizing(size);	
	createCookie("size", size, 365);
}

function normalSizePrint() {
	var size = 12;
	doFontSizing(size);	
}

function createCookie(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=/';
}

function readCookie(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 initSize;
}

window.onload = function(e) {
	fontSizerOnLoad(readCookie("size"));
}
