
// set functions here will unplug the ones declared in the doc
// window.onload=init;
/*
var bugRiddenCrashPronePieceOfJunk = (
	navigator.userAgent.indexOf('MSIE 5') != -1
	&&
	navigator.userAgent.indexOf('Mac') != -1
);
*/
/*
get properties of an object
for debug
*/
function props(o) {
   var result = ""
   var a=new Array();
   var i=0
   for (var prop in o) {
      a[i]= prop  + "\t"; // + " = " + o[prop]
      i++;
   }
   a.sort();
   return a;
}






/*
Maintain a fixed number of character on the width of the window

*/

// normal pixel height
var fontSizeNormal=14;
// mini pixel height
var fontSizeMini=10;
var widthDefault=80;
if ( document.getElementById && !document.all ) var fontSizeNormal=14; // may be mozilla

function fit(ex) {

  // fit char size  
  var width;
  if (false);
  else if (document.body && document.body.offsetWidth) width=document.body.offsetWidth;
  else if (document.body && document.body.clientWidth) width=document.body.clientWidth;
  else if (window.innerWidth) width= window.innerWidth;
  else return false;


  if (!ex) var ex=widthDefault;
  // default ratio between ex and em 
  fontSizeFit=Math.floor((width/ex)*1.2);
  // set a minimum ratio under which the page may be unreadable
  fontSizeFit=(fontSizeFit < fontSizeMini)?fontSizeMini:fontSizeFit;
  if(document && document.body && document.body.style) document.body.style.fontSize=fontSizeFit+"px";
  else if (!document.getElementById) return true;
  // work around for moz in case of XML transformed
  else if(document.getElementById("body")) { 
    o=document.getElementById("body");
    if(!o.style) return false;
    o.style.fontSize=fontSizeFit;
  }
}


