// script to set base body font size

// base size (good for 800x600)
var baseWidth = 1024;
var baseHeight= 768;
var baseFontSize = 50;
var baseFontUnits = 'px';
var scale = 1;

// This is a simplified version of the JavaScript Client Sniffer code 
// (http://developer.nextscape.com/docs/examples/javascript/browser_type.html)

function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()

    // --- BROWSER VERSION ---
    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)

    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major == 4))

    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = (this.ie && (this.major == 4))

    this.opera = (agt.indexOf("opera") != -1)
     
    this.nav4up = this.nav && (this.major >= 4)
    this.ie4up  = this.ie  && (this.major >= 4)
}

var is = new Is();


// determine appropriate font scaling factor
xscale = 1; yscale = 1;
if (is.nav4up) {
    // font size based on window width
    xscale = parent.innerWidth/baseWidth;
    yscale = parent.innerHeight/baseHeight;
}
else if (is.ie) {
    // font size based on screen width
    xscale = screen.width/baseWidth;
    yscale = screen.height/baseHeight;
}
scale = yscale;
if (xscale < yscale) scale = xscale;

baseFontSize = parseInt(baseFontSize*scale);

// spit out style line to set base font size
document.write('<style type=text/css>BODY{font-size:' + baseFontSize +
	       baseFontUnits + '}</style>\n');

// also set for table elements since they don't seem to inherit from body
// (bug?)
document.write('<style type=text/css>TD,TH{font-size:' + baseFontSize +
	       baseFontUnits + '}</style>\n');
document.write('<style type=text/css>TABLE.small TD,TABLE.small TH{font-size:'
	       + .6*baseFontSize + baseFontUnits + '}</style>\n');


