

tags = new Array( 'div', 'td', 'tr', 'p', 'b', 'table', 'strong', 'em', 'a', 'h1', 'h2', 'h3', 'pre', 'sub', 'sup', 'i', 'th', 'cp', 'ul', 'ol', 'li', 'dt', 'dd', 'a', 'font' );
defaultSize = 18;
resizeCounter = 0;
increment = 2;


function getStyle(el,styleProp)
{
       var x = el;
       if (x.currentStyle){
	   		   if (styleProp == 'font-size') styleProp = 'fontSize';
               var y = x.currentStyle[styleProp];
			   }
       else if (window.getComputedStyle)
               var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	   return y;
}



function FWresizeFont(resize) {
	if (!document.getElementById) {
		return;
	}

		
	docBody = document.getElementById('corposite');
			
	for (i = 0 ; i < tags.length ; i++ ) {		
		allTags = docBody.getElementsByTagName(tags[i]);
		
		
		if (resize > 0) {
		
			for (k = 0 ; k < allTags.length ; k++) {
				//var size = parseInt(allTags[k].style.fontSize.substring(0,allTags[k].style.fontSize.length-2));
				var size = getStyle(allTags[k], 'font-size').substring(0, getStyle(allTags[k], 'font-size').length-2);
				size -= 0;
				if (size) {
					allTags[k].style.fontSize = (size + increment) + 'px';
				} else {
					allTags[k].style.fontSize = defaultSize + 'px';
				}
			}			
		} else {
			for (k = 0 ; k < allTags.length ; k++) {
				//var size = parseInt(allTags[k].style.fontSize.substring(0,allTags[k].style.fontSize.length-2));
				var size = getStyle(allTags[k], 'font-size').substring(0, getStyle(allTags[k], 'font-size').length-2);
				size -= 0;
				if (size) {
					allTags[k].style.fontSize = (size - increment) + 'px';
				} else {
					allTags[k].style.fontSize = defaultSize + 'px';
				}
			}			
		}
	}
	
	resize > 0 ? resizeCounter++ : resizeCounter--;
}

function setFontSize(resizeCounter) {
	docBody = document.getElementsByTagName('body')[0];
	for (i = 0 ; i < tags.length ; i++ ) {		
		allTags = docBody.getElementsByTagName(tags[i]);		
		for (k = 0 ; k < allTags.length ; k++) {
			//var size = parseInt(allTags[k].style.fontSize.substring(0,allTags[k].style.fontSize.length-2));
			var size = getStyle(allTags[k], 'font-size').substring(0, getStyle(allTags[k], 'font-size').length-2);
			size -= 0;
			var resize = size + resizeCounter;			
			if (!size) {
				allTags[k].style.fontSize = (parseInt(defaultSize) + parseInt(resizeCounter)) + 'px';
			} else if (size && resize > 0) {
				allTags[k].style.fontSize = resize + 'px';
			}
		}
	}
}

function resetFontSize() {
	/*
	docBody = document.getElementsByTagName('body')[0];
	for (i = 0 ; i < tags.length ; i++ ) {		
		allTags = docBody.getElementsByTagName(tags[i]);		
		for (k = 0 ; k < allTags.length ; k++) {
			allTags[k].style.fontSize = defaultSize + 'px';
		}
	}
	*/
	window.location.reload();
	resizeCounter = 0;
}
//cookie functions for remember the font sizes across pages
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 null;
}

function setUserOptions(){
	cookie = readCookie("FWresizeFont");
	if (cookie) {
		resizeCounter = cookie;
	} else {
		return null;
	}
	
	setFontSize(resizeCounter);
}

function saveSettings()
{
  createCookie("FWresizeFont", resizeCounter, 365);
}

//window.onload = setUserOptions;
window.onunload = saveSettings;