/* * * * */
// <LINK name="author" HREF="http://www.holderness.eu/js.htm">
// <LINK name="license" TYPE="free to nonprofit organisations; others make an offer - see:" HREF="http://www.poptel.org.uk/nuj/mike/java.htm">
// <META name="warning" content="I am actively looking for test cases to prosecute!">
// Gutted of game components, leaving shell functions for safety *
/* * * * */
		// assume all pages have same {nav} bar, for the moment
		// different script version required for each directory level w.r.t. /gif
		// version required for left & right nav-bar - see menuX in GetWindowSize()

var debugging= false; /*NOTA BENE debugging alert()s seem to crash Opera*/
var imgOn, imgOff, homeOn;
var version="veryplain";
var subversion="ok";
var ready=false;
var MenuInt=null;
var mX =		120;	/* size of #nav - er, empirically set*/
var mY =		454;	
var MsgWidth =		200;	/* see in .css*/
var ContentWidth=	600;	/* empirical browser compromise!*/
var menuX=	 540;	/* pixels right*/
var mMargin=	  10;	/* pixels down*/
var thisgame=0;
var formOK=true;
var highlightColor="yellow";
var visitedColor="#CCCC99";
var tagged="";

function NUJinit() {
	init(0);
}

function init(game) {
	thisgame=game;
	GetVersion();
	
	if (version=="ECMA") {
		document.getElementById("JSwarn").style.visibility="hidden";
	}
	else if (version=="Nav4") {
		document.JSwarn.visibility="hide";
	}
	else if (version=="IE5") {
		document.all.JSwarn.style.visibility="hidden";
	}
	if (typeof(homeOn)=="undefined" 
	&& version!="veryplain" 
	&& version!="nostyle") { 

		homeOff= new Image(mX,mY);	homeOff.src= "gif/fl2.gif";
		homeOn=  new Image(mX,mY); 	homeOn.src=  "gif/fl2.gif";
		RefrT=	40;

		if (MenuInt==null) {
			MenuInt = setInterval("MenuRefresh(false)",RefrT);
			window.onUnload=stopscript;
		} 
		ready=true;
	}
	if (debugging) {window.alert("Init: ready="+ready+" window: "+Wwidth+" * "+Wheight);}
}

function GetVersion() {
var OperaVer="0";
	vernum=navigator.appVersion.charAt(0);
	isMac=navigator.appVersion.indexOf("Mac") > 1;
	OperaPos=navigator.userAgent.indexOf("Opera");
	if (OperaPos>=0) {OperaVer = navigator.userAgent.substr(OperaPos+6,4)}
	if (vernum >= "4") {
		if (navigator.appName == "Microsoft Internet Explorer") {
			if ((navigator.appVersion.indexOf("MSIE 4.5") > 1 && isMac)
			 || navigator.appVersion.indexOf("MSIE 5") > 1 
			 || navigator.appVersion.indexOf("MSIE 6") > 1) {
				version="IE5";
				if (navigator.appVersion.indexOf("MSIE 6") > 1 && navigator.appVersion.indexOf("Windows")>1) {
					subversion="billGSucks6Toads"
				}
			}
			else {
				version="veryplain";
			}
		}
		else if (navigator.appName=="Netscape" && vernum=="4") {
			version="Nav4";
		}
		else {
			version="ECMA";
		}
	}
	if (version=="ECMA") {
		if (OperaVer>"0" && OperaVer<"5.11") {
			version="veryplain";
		}
		else if (typeof(document.getElementById("nav").style)=="undefined") {
			version="veryplain";
		}
		else {
			window.onresize=resizer;
		}
	}
	else if (version=="Nav4") {
		if (typeof(document.nav)=="undefined" || isMac || OperaVer!="0") {
			version="veryplain";
		}
		else {
			window.onresize=resizer;
		}
	}
	else if (version=="IE5") {
		if (typeof(document.all.nav.style)=="undefined" || OperaVer!="0") {
			version="veryplain"; 
		}
		else {
			self.window.onresize=resizer;
		}
	}
	GetWindowSize();
	if (debugging) {window.alert(" ver="+version+": '"+navigator.appName+"|"+navigator.userAgent+"'")}
//	window.status = " ver="+version+": '"+navigator.appName+"|"+navigator.userAgent+"'";
}

function resizer() {
	GetWindowSize();
	MenuRefresh(true);
};

function stopscript() {
	clearInterval(MenuInt);
};

function GetWindowSize() { /* menu on right */
	if (version=="IE5") {
		if (subversion=="billGSucks6Toads") {
			Wwidth=document.documentElement.clientWidth;
			Wheight=document.documentElement.clientHeight;
		}
		else {
			Wwidth=document.body.clientWidth;
			Wheight=document.body.clientHeight;
		}
		menuX=ContentWidth+(Wwidth-ContentWidth)/2-mX;
	}
	else if (version=="Nav4" || version=="ECMA") {
		Wwidth=window.innerWidth;
		Wheight=window.innerHeight;
		menuX=ContentWidth+(Wwidth-ContentWidth)/2-mX;
	}
	window.status = "W:"+Wwidth+" H:"+Wheight+" "+version;
};

function MenuRefresh(forced) {
if (Wheight>mY || forced) {
	if (version=="ECMA") {
		with (document.getElementById("nav").style) {
			left 	= menuX + pageXOffset;
			top 	= mMargin + pageYOffset;
		}
	}
	else if (version=="Nav4") {
		with (document.nav) {
			left	= menuX + pageXOffset;
			top	= mMargin + pageYOffset;
		}
	}
	else if (version=="IE5") {
		with (document.all.nav.style) {
			if (subversion=="billGSucks6Toads") {
				left  = menuX + document.documentElement.scrollLeft;
				top = mMargin + document.documentElement.scrollTop;
			}
			else {
				left	= menuX + document.body.scrollLeft;
				top	= mMargin + document.body.scrollTop;
			}
		}
	}
}
};

function setCellBG(tag,what) {
	if (version=="ECMA") {
		document.getElementById(tag).style.background=what;
	}
	else if (version=="Nav4") { /* TO TEST! */
		document.tag.document.bgColor=what;
	}
	else { if (version=="IE5") {
		document.all[tag].style.backgroundColor = what;
		}
	}
};

function FlagTag(tag) {
	if (tagged > "") {
		setCellBG(tagged,visitedColor);
	}
	tag="z"+tag; /* broken IE5 restrictions - NB in HTML <TD id="zthing"><A NAME="thing">...! */
	setCellBG(tag,highlightColor);
	tagged=tag;
};

function FlagTarget() {
	tag=window.location.hash.slice(1);
	if (tag>"") {
		FlagTag(tag);
	}
};

function offerChanges(what) { /* no option shewn for browsers that won't do it, I hope... */
	what1="<A HREF=\"javascript:"+what+"Changes()\">"+what+"&nbsp;changes</A>";
	if (version=="ECMA") {
		with (document.getElementById("changes")) {
			style.display="block";
			style.width="100%";
			innerHTML=what1;
						
		}
	}
	else if (version=="IE5") {
		with (document.all.changes) {
			style.display="block";
			style.width="100%";
			innerHTML=what1;
		}
	
	}
};

function hideChanges() {
	if (version=="ECMA") {
		with (document.styleSheets[0].cssRules[2].style) { /* INS */
			color="black";
			textDecoration="none";
		}
		with (document.styleSheets[0].cssRules[3].style) { /* DEL */
			display="none";
		}
	}
	else if (version=="IE5") {
		with (document.styleSheets[0].rules[2].style) {
			color="black";
			textDecoration="none";
		}
		with (document.styleSheets[0].rules[3].style) {
			display="none";
		}
	}
	offerChanges("show");
};

function showChanges() {
	if (version=="ECMA") {
		with (document.styleSheets[0].cssRules[2].style) { /* INS */
			color="red";
			textDecoration="underline";
		}
		with (document.styleSheets[0].cssRules[3].style) { /* DEL */
			color="red";
			textDecoration="strikeout";
			display="inline";
		}
	}
	else if (version=="IE5") {
		with (document.styleSheets[0].rules[2].style) {
			color="red";
			textDecoration="underline";
		}
		with (document.styleSheets[0].rules[3].style) {
			color="red";
			textDecoration="strikeout";
			display="inline";
		}
	}
	offerChanges("hide");
};

function advance(thing) {
};

function retreat(thing) {
};

function a(thing) {
	advance(thing);
};

function r(thing) {
	retreat(thing);
};

function play() {
};

//ENDS