// Javascript setting presentation styles, mangled beyond recognition from
// developer.netscape.com/docs/technote/javascript/prestemp/prestemp.html

// Slides should load slide.js in the <head> section, header.js at the
// beginning of the <body> section, and footer.js at the end of the <body>
// section.

// base size (multiply by scale for other sizes)
var baseWidth = 1024;
var baseHeight= 768;
var baseFontSize = 50;
var baseFontUnits = 'px';
var bodyMargin = 108;
var titleHeight = 175;

// derived values
var xsize = baseWidth;
var ysize = baseHeight;
var xscale = xsize/baseWidth;
var yscale = ysize/baseHeight;
var scale = yscale;

// put up slide title
document.write('<title>',slidetitle,'</title>\n');

//////////////////////////////////////////////////////////////////////
// browser type
// 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();

//////////////////////////////////////////////////////////////////////
// general scaling
function setStyle()
{
    // determine appropriate font scaling factor
    xsize = window && window.innerWidth ? window.innerWidth :
	document.body && document.body.clientWidth ? document.body.clientWidth:
	screen && screen.width ? screen.width :
	baseWidth;
    ysize = window && window.innerHeight ? window.innerHeight :
	document.body && document.body.clientHeight?document.body.clientHeight:
	screen && screen.height ? screen.height :
	baseHeight;
	
    xscale = xsize/baseWidth;
    yscale = ysize/baseHeight;
    scale = yscale;
    if (xscale < yscale) scale = xscale;

    // modify sizes with scale
    baseFontSize = parseInt(baseFontSize*scale);
    bodyMargin = xscale*bodyMargin;
    titleHeight = yscale*titleHeight;

    //////////////////////////////////////////////////////////////////////
    // set style

    // document.write seems more portable than javascript access for this
    document.write('<style type=text/css>\n');

    document.write('							   \
/* layers */								   \
#bodylayer		{position:absolute;				   \
			 top:0; left:',bodyMargin,'px; 			   \
			 width:',xsize-bodyMargin,'px; height:',ysize,'px} \
#bgndlayer		{position:absolute; top:0; left:0;		   \
			 width:',xsize,'px; height:',ysize,'px}		   \
#navlayer		{position:absolute; top:0; left:0}		   \
									   \
/* basic text stuff inherited by most everyone */			   \
BODY			{font-family:helvetica,arial,sans-serif;	   \
		  	 font-size:',baseFontSize,baseFontUnits,';	   \
			 color:black; background:white}			   \
									   \
H1,H2,H3,H4,H5,H6 	{font-size:100%;				   \
			 color:black}					   \
EM			{color:#ff4000}					   \
A:link			{text-decoration:none;				   \
			 color:blue}					   \
A:visited		{text-decoration:none;				   \
			 color:magenta}					   \
									   \
/* outline styles */							   \
P		  	{font-size:100%}				   \
UL,OL,DL	 	{font-size:100%; font-style:bold}		   \
UL UL, OL OL, DL DL 	{font-size: 85%; font-style:normal}		   \
UL UL UL, OL OL OL 	{font-size: 85%}				   \
UL			{list-style: none}				   \
UL UL			{list-style: square}				   \
									   \
									   \
/* preformatted text */							   \
INPUT		  	{font-family:courier,monospace}			   \
PRE,TT			{font-family:courier,monospace;			   \
			 font-size:',.45*baseFontSize,baseFontUnits,';	   \
			 font-weight: bold}				   \
									   \
/* tables */								   \
TD,TH   		{font-family:helvetica,arial,sans-serif;	   \
			 font-size:',baseFontSize,baseFontUnits,'}	   \
TD			{color:black}					   \
TH			{color:#ff4000}					   \
TD H1			{color:black}	/* slide title */		   \
									   \
/* specific styles */							   \
TABLE.small TD,TABLE.small TH{font-size:',.6*baseFontSize,baseFontUnits,'} \
.title			{height:',titleHeight,'px}			   \
.titlepage H2	  	{font-size:100%;				   \
			 font-wieght: bold; line-height:200%;		   \
			 text-align: center}				   \
.titlepage H3  		{font-size: 60%;				   \
			 text-align: center}				   \
.copyright	  	{font-family:helvetica,arial,sans-serif;	   \
			 font-size: 30%; color:black;			   \
			 text-align: center}				   \
.ref		  	{font-family:courier,monospace;			   \
			 font-size: 50%; line-height: 50%}		   \
.index		  	{font-family:courier,monospace;			   \
			 font-weight: normal; font-style: normal;	   \
			 font-size: 12pt}				   \
.right		  	{float:right}					   \
.center		  	{float:none}					   \
.left		  	{float:left}					   \
');

    //////////////////////////////
    // platform-specific overrides

    // netscape: sizes of nested list elements
    if (is.nav)
	document.write('						\
/* nav: sizes of nested list elements */				\
UL UL, OL OL{font-size:', .85*baseFontSize,baseFontUnits,'}	\
UL UL UL, OL OL OL{font-size:',.7*baseFontSize,baseFontUnits,'}	\
								\
/* nav: excessive spacing before outer list elements */		\
UL, OL, PRE 	{margin-top: -2ex}				\
UL UL, OL OL	{margin-top: 0}					\
UL LI   	{margin-left: 1px}				\
UL UL LI	{margin-left: 0}				\
UL 	  	{margin-left: -1ex}				\
UL UL		{margin-left:  1ex}				\
');

    // done with styles
    document.write('</style>\n');
}

// IE: no size info til body, but (incorrectly) can set styles there
if (! is.ie) setStyle();

