//change the font size on specified tags (li,p,td,th)
//also remembers setting across page views
function FontSizeAdjust(amount) {
   c_fs_amount += parseInt(amount,10);
   var min=8;
   var max=18;
   //alert (c_fs_amount);
   //if (c_fs_amount<min) c_fs_amount = min;
   //if (c_fs_amount>max) c_fs_amount = max;
   var els = new Array("li","p","td","th","a","div");
   for(i=0;i<els.length;i++) {
	   p = document.getElementsByTagName(els[i]);
	   for(j=0;j<p.length;j++) {
		  if(p[j].style.fontSize) {
			 var s = parseInt(p[j].style.fontSize.replace("pt",""));
		  } else {
			 var s = 12;
		  }
		  s += amount;
		  if ((s>=min) && (s<=max)) p[j].style.fontSize = s+"pt";
	   }
   }
   
   createCookie("dev_font_size",c_fs_amount,365);
}

//cookie helper function
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 var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
//cookie helper function
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;
}
//cookie helper function
function eraseCookie(name) {
	createCookie(name,"",-1);
}

//restore the last font size when the page refreshes
function RestoreFontPref() {
	var fs = readCookie('dev_font_size');
	c_fs_amount = 0;

	if (fs) {
		//c_fs_amount = parseInt(fs,10);
		//alert(fs);
		return FontSizeAdjust(parseInt(fs,10));
	}
}