// minimum width and height of the page in [em]
var pageWidth = 64.5;
var pageHeight = 48.5;

// http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
 } else {
   return false;
 }
}

addEvent(window, 'load', fontSizeZoom);
addEvent(window, 'resize', fontSizeZoom);

function fontSizeZoom() {
	//http://www.quirksmode.org/viewport/compatibility.html#link2
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
	         x = self.innerWidth;
	         y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	         // Explorer 6 Strict Mode
	{
	         x = document.documentElement.clientWidth;
	         y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
	         x = document.body.clientWidth;
	         y = document.body.clientHeight;
	}

	var winHeight = y;
	var winWidth = x;
         var winRatio = winHeight/winWidth;
         var pageRatio = pageHeight/pageWidth;
         if (winRatio>pageRatio) {
         	// 12pt equals 16px on a standard screen
         	var fontSize = (winWidth/pageWidth)*(12/16);
         } else {
         	var fontSize = (winHeight/pageHeight)*(12/16);
         }
//	alert(winHeight+'\n'+winWidth+'\n'+winRatio+'\n'+pageRatio+'\n'+fontSize);
	document.getElementsByTagName('body')[0].style.fontSize = fontSize+'pt';
	document.getElementsByTagName('body')[0].style.display = 'block';
	document.getElementsByTagName('body')[0].style.visibility = 'visible';
}