function Is() {
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns4up = (this.ns && (this.major >= 4));
	this.ns6up = (this.ns && (this.major >= 6));
	this.ie   = (agent.indexOf("msie") != -1);
	this.ie4up  = (this.ie && (this.major >= 4));
	this.win   = (agent.indexOf("win")!=-1);
	this.mac   = (agent.indexOf("mac")!=-1);
	this.unix  = (agent.indexOf("x11")!=-1);
}

var is = new Is();

function onerror() {
	document.location.href = "javascript:";
}
//20

function positionLayers() {
	
	TitleBarObj = document.getElementById("TitleBarLyr").style;
	TitleBarObj.left = 15;
	TitleBarObj.top = 5;
	TitleBarObj.width = 1000;
	TitleBarObj.height = 38;

	Text1Obj = document.getElementById("Text1Lyr").style;
	Text1Obj.left = 72;
	Text1Obj.top = 80;
	Text1Obj.width = available_width - 250;
		
	WorldMapObj = document.getElementById("WorldMapLyr");
	if (WorldMapObj){
		WorldMapObj.style.left = 118;
		WorldMapObj.style.top = 85;
		WorldMapObj.style.width = 473;
		WorldMapObj.style.height = 300;
		if ( available_width < 800 ){
			WorldMapObj.style.left = 10;
		}
	}
// 45
	TocObj = document.getElementById("TocLyr").style;
	TocObj.left = 648;
	TocObj.top = 75;
	TocObj.width = 300;
	TocObj.height = 300;
	if ( available_width < 800 ){
		TocObj.left = 480;
	}

	//Width of main text table ( to avoid writing on map )
	MapFormObj = document.getElementById("map_form");
	if (MapFormObj){
		MapFormObj.width = 580;
		if ( available_width < 800 ){
			MapFormObj.width = 480;
		}
	}
	noMapObj = document.getElementById("no_map");
	if (noMapObj){
// 65		
		// Position Spiel obj as if there was NO map
		SpielObj = document.getElementById("SpielLyr").style;
		SpielObj.left = 85;
		SpielObj.top = 110;
		SpielObj.width = 860;
		noMapObj.style.width = 555;
		if ( available_width < 800 ){
			SpielObj.left = 5;
			SpielObj.top = 115;
			SpielObj.width = 770;
			noMapObj.style.width = 455;
		}
	}
	else{
		// Position as if there IS a map
		SpielObj = document.getElementById("SpielLyr");
		if (SpielObj){
			SpielObj.style.left = 85;
			SpielObj.style.top = 265;
			SpielObj.style.width = 860;
			if ( available_width < 800 ){
				SpielObj.style.left = 5;
				SpielObj.style.top = 245;
				SpielObj.style.width = 765;
			}
		}
	}
// 91
	FooterObj = document.getElementById("FooterLyr").style;
	FooterObj.left = 35;
	FooterObj.top = 475;
	FooterObj.width = 800;
	if ( available_width < 800 ){
		FooterObj.top = 505;
		FooterObj.left = 10;
	}
	
	// check for long vertical screens
	LongObj = document.getElementById("LongLyr");
	if ( LongObj ){
		if ( available_width < 800 )
			FooterObj.top = 920;
		else
			FooterObj.top = 750;
	}


 	TitleBarObj.visibility = "visible";
	Text1Obj.visibility = "visible";
	TocObj.visibility = "visible";
	FooterObj.visibility = "visible";
	if ( available_width < 800 )
		document.getElementById("BorderLyr").style.visibility = "hidden";
	if ( WorldMapObj )
		WorldMapObj.style.visibility = "visible";
}
//115

// COLOUR FADER
frame=19;
hex=255; // Start colour ( white )
function colorfade()
{
	// 20 frames fading process
	if(frame>0) {
		hex-=6; // increase color value
		var allFonts = document.getElementsByTagName("font");
		for(i=0;i<allFonts.length-1;i++)
			allFonts[i].style.color="rgb("+hex+","+hex+","+hex+")"; // Set color value.
		frame--;
		setTimeout("colorfade()",10);
	}
	else{
		hex=0;
		var allFonts = document.getElementsByTagName("font");
		for(i=0;i<allFonts.length-1;i++)
			allFonts[i].style.color="rgb("+hex+","+hex+","+hex+")"; // Set color value.
		frame=20;
	}
}

function bodyLoad(){
    if( is.ns4up ) {
        available_width=document.body.clientWidth; 
	available_height=document.body.clientHeight;
        positionLayers();
	colorfade();
    } else if( is.ie4up ) {
        available_width=document.body.clientWidth;
        available_height=document.body.clientHeight;
        positionLayers();
	colorfade();
    }
}
