function onloadFunctions() {
	initFontSize();
}

window.onload = onloadFunctions;

var objContentDiv, objNavDiv, intFontSizeSm, intFontSizeLg, objLinkSm, objLinkLg, strCookieFontSize

function initFontSize() {
	intFontSizeSm = 1;
	intFontSizeLg = 1.4;
	intFontSize = intFontSizeSm;
	if (getCookieFontSize()) intFontSize = getCookieFontSize();
	objContentDiv = document.getElementById('content');
	objNavDiv = document.getElementById('nav');
	objLinkSm = document.getElementById('header_aSm');
	objLinkLg = document.getElementById('header_aLg');
	if(intFontSize == intFontSizeSm) changeFont('sm');
	else changeFont('lg');
	behavChangeFont();
}

function toggleFontSize(size) {
	//intFontSize = (intFontSize == intFontSizeSm ? intFontSizeLg : intFontSizeSm);
	if (size == 'sm') {intFontSize = intFontSizeSm;}
	if (size == 'lg') {intFontSize = intFontSizeLg;}
	changeFont(size);
	setCookie();
}

function changeFont(size) {
	objContentDiv.style.fontSize = intFontSize + 'em';
	objNavDiv.style.fontSize = intFontSize + 'em';
	var arrTables = objContentDiv.getElementsByTagName('table');
	for (i=0;i<arrTables.length;i++) {arrTables[i].style.fontSize = '1.3em';}
	if (size == 'sm') {objLinkSm.style.textDecoration = 'none';objLinkSm.style.backgroundColor = '#80bbea';objLinkLg.style.textDecoration = 'underline';objLinkLg.style.backgroundColor = 'transparent';}
	if (size == 'lg') {objLinkLg.style.textDecoration = 'none';objLinkLg.style.backgroundColor = '#80bbea';objLinkSm.style.textDecoration = 'underline';objLinkSm.style.backgroundColor = 'transparent';}
}

function behavChangeFont(){
	var objButtonSm = document.getElementById('header_aSm');
	var objButtonLg = document.getElementById('header_aLg');
	objButtonSm.onclick = function(){toggleFontSize('sm');}
	objButtonLg.onclick = function(){toggleFontSize('lg');}
}

function setCookie() {
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	document.cookie = 'fontSize=' + escape(intFontSize) + '; expires=' + nextyear.toGMTString() + '; path=/'
}

function getCookieFontSize() {
	var allCookies = document.cookie;
	var pos = allCookies.indexOf('fontSize=');
	if (pos != -1) {
		var start = pos + 9;
		var end = allCookies.indexOf(';',start);
		if (end == -1) end = allCookies.length;
		var value = allCookies.substring(start,end);
		value = unescape(value);
		return value;
	}
	else return false;
}
