var minSize = 70;
var defaultSize = 100;
var maxSize = 130;
var sizeInc = 10

var tags = new Array();
tags[0] = "p";
tags[1] = "td";
tags[2] = "div";
tags[3] = "body";
	
var sizes = new Array();
	
function increaseFontSize(){
	for(var i=0; i < tags.length; i++){
		setFontSize(i,eval(eval(sizes[i])+sizeInc));
	}
}
function resetFontSize(){
	for(var i=0; i < tags.length; i++){
		setFontSize(i,defaultSize);
	}
}
function decreaseFontSize(){
	for(var i=0; i < tags.length; i++){
		setFontSize(i,eval(eval(sizes[i])-sizeInc));
	}
}
function setFontSize(tag,size){
	if( size >= minSize && size <= maxSize && size != sizes[tag]){
		sizes[tag]=size;
		createFontsizeCookie(tags[tag],sizes[tag],1);
		var currtag = document.getElementsByTagName(tags[tag]);
		for(var i=0;i<currtag.length;i++){
			currtag[i].style.fontSize = sizes[tag]+"%";
		}
	}
}
function readFontsizeCookie(){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i < ca.length;i++) {
		var c = ca[i];
		var currTag = c.split('=');
		for(var j=0; j < tags.length; j++){
			currTag[0] = stripCharacter(currTag[0],' ');
			if(tags[j] == currTag[0]){
				setFontSize(j,currTag[1]);
			}
		}		
	}

	for(var i=0; i < tags.length; i++){
		if(typeof(sizes[i]) == "undefined"){
			setFontSize(i,defaultSize);
		}
	}

}

function createFontsizeCookie( tag , size , 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 = tag+"="+size+expires+"; path=/";
}
function stripCharacter(words,character) {
	//documentation for this script at http://www.shawnolson.net/a/499/
	  var spaces = words.length;
	  for(var x = 1; x<spaces; ++x){
	   words = words.replace(character, "");   
	 }
	 return words;
}