<!--Decomment this to force a non-JavaScript environment. Why does MSIE insist on not letting me turn it off!-->

// This is to make sure the update directory is reset whenever this JavaScript is loaded.
// To use the sidebar in pages that are not in the 18242/ root directory, make the link to
// this file, *THEN* use <script> tags to set updatedir to the string that takes URL back
// to the 18242/ directory. For example, if you have something in a child directory of
// 18242/, updatedir should be "../"...all the links and images will load/link correctly.
var updatedir = "";

// This function writes the heading, just saves space, since we'll use the code a lot.
function WriteHeading(text) {
	document.writeln("<font color=#DB6709><B>"+text+"</font></b>");
	document.writeln("<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td bgcolor=#000000></td></tr></table>")
	document.writeln("<center><img src=\"images/1.gif\" height=5></center>")
}

function WriteHide(text) {
	document.writeln("<style>");
	document.writeln("."+text+" {display:none}</style>")
}

function WriteNews(text, name) {
	document.writeln("<table width=100% cellpadding=0 border=0 cellspacing=0><tr><td bgcolor=#EEEEEE><font size=2>")
	newsdate = new Date();
	newsdate.setTime(Date.parse(text));
	lastdate = new Date();
	lastdate.setTime(Date.parse(ReadCookie("Gen5LastVisit")));
	if (lastdate.getTime() < newsdate.getTime())
		document.writeln("<b><font class=newstitle color=red>"+text+"</font><font class=newsname> - "+name+".</font></b></td></tr>")
	else
		document.writeln("<b><span class=newstitle>"+text+"</span><font class=newsname> - "+name+"</font>.</b></td></tr>")
	document.writeln("<tr><td bgcolor=black></td></tr></table>");
}

function WriteTour(page) {
	temppage = page;
	document.writeln("<table align=right border=0 cellpadding=1 cellspacing=0><tr><td valign=top><tr><td bgcolor=black>")
	document.writeln("<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor=white>")

	var options = ReadCookie("Gen5Options");
	if (options == "" || options.substring(0,1) == '1') {
		//	Back button.
		temppage = temppage - 1;
		if (temppage < 10) tempstring = "page0" + temppage + ".shtml";
		else tempstring = "page" + temppage + ".shtml";
		if (temppage == -1 || temppage == -2) tempstring = "index.shtml"
		document.writeln("<a href=\""+tempstring+"\" title=\"Go back to the previous page.\"><img src=\"images/back.gif\" border=0></a>");
		
		document.writeln("<img src=\"images/1.gif\" border=0 width=2>")

		//	Forward button.
		temppage = temppage + 2;
		if (temppage < 10) tempstring = "page0" + temppage + ".shtml";
		else tempstring = "page" + temppage + ".shtml";
		if (page == 13) tempstring = "index.shtml"
		document.writeln("<a href=\""+tempstring+"\" title=\"Go forward to the next page.\"><img src=\"images/next.gif\" border=0></a>");
		document.writeln("</td></tr><tr><td bgcolor=black></td></tr>");
	}
	if (options.substring(2,3) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"cgi-bin/search/search.shtml\" title=\"Search the site\"><center><span class=toolbar><font size=0>Search</font></span></a></center></td></tr>")
	}
	if (options == "" || options.substring(3,4) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"options.shtml\" title=\"Customize Generation 5\"><center><span class=toolbar><font size=0>Options</font></a></span></a></center>")
	}
	if (options.substring(4,5) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"mailto:18242@advanced.org\" title=\"Please send us feedback\"><center><span class=toolbar><font size=0>Mail Us</font></span></a></center>")
	}

	document.writeln("</td></tr></table></td></tr></table>");
}

function back() { history.back() }
function next() { history.forward() }

function WriteTool(uppage) {
	document.writeln("<table align=right border=0 cellpadding=1 cellspacing=0><tr><td valign=top><tr><td bgcolor=black>")
	document.writeln("<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor=white>")

	var options = ReadCookie("Gen5Options");
	if (options == "" || options.substring(0,1) == '1') {
		//	Back button.
		document.writeln("<img src=\"images/back.gif\" border=0 onClick=\"back()\" alt=\"Back\">");
		
		if (options.substring(5,6) == '1') document.writeln("<a href=\""+uppage+"\" title=\"Up to "+uppage+".\"><img src=\"images/up.gif\" border=0></a>")
		else document.writeln("<img src=\"images/1.gif\" border=0 width=2>")
		
		//	Forward button.
		document.writeln("<img src=\"images/next.gif\" border=0 onClick=\"next()\" alt=\"Forward\">");
		document.writeln("</td></tr><tr><td bgcolor=black></td></tr>");
	}
	if (options.substring(1,2) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"index.shtml\" title=\"Return to the home screen\"><center><span class=toolbar><font size=0>Home</font></span></a></center></td></tr>")
	}
	if (options.substring(2,3) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"cgi-bin\search\search.shtml\" title=\"Search the site\"><center><span class=toolbar><font size=0 >Search</font></span></a></center></td></tr>")
	}
	if (options == "" || options.substring(3,4) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"options.shtml\" title=\"Customize Generation 5\"><center><span class=toolbar><font size=0>Options</font></span></a></center>")
	}
	if (options.substring(4,5) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"mailto:18242@advanced.org\" title=\"Please send us feedback\"><center><span class=toolbar><font size=0>Mail Us</font></span></a></center>")
	}

	document.writeln("</td></tr></table></td></tr></table>");
}

function WriteToolDir(uppage, dir) {
	document.writeln("<table align=right border=0 cellpadding=1 cellspacing=0><tr><td valign=top><tr><td bgcolor=black>")
	document.writeln("<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor=white>")

	var options = ReadCookie("Gen5Options");
	if (options == "" || options.substring(0,1) == '1') {
		//	Back button.
		document.writeln("<img src=\""+dir+"images/back.gif\" border=0 onClick=\"back()\" alt=\"Back\">");
		
		if (options.substring(5,6) == '1') document.writeln("<a href=\""+uppage+"\" title=\"Up to "+uppage+".\"><img src=\""+dir+"images/up.gif\" border=0></a>")
		else document.writeln("<img src=\""+dir+"images/1.gif\" border=0 width=2>")
		
		//	Forward button.
		document.writeln("<img src=\""+dir+"images/next.gif\" border=0 onClick=\"next()\" alt=\"Forward\">");
		document.writeln("</td></tr><tr><td bgcolor=black></td></tr>");
	}
	if (options.substring(1,2) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\""+dir+"index.shtml\" title=\"Return to the home screen\"><center><span class=toolbar><font size=0>Home</font></span></a></center></td></tr>")
	}
	if (options.substring(2,3) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\""+dir+"cgi-bin\search\search.shtml\" title=\"Search the site\"><center><span class=toolbar><font size=0 >Search</font></span></a></center></td></tr>")
	}
	if (options == "" || options.substring(3,4) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\""+dir+"options.shtml\" title=\"Customize Generation 5\"><center><span class=toolbar><font size=0>Options</font></span></a></center>")
	}
	if (options.substring(4,5) == '1') {
		document.writeln("<tr><td bgcolor=eeeeee><a href=\"mailto:18242@advanced.org\" title=\"Please send us feedback\"><center><span class=toolbar><font size=0>Mail Us</font></span></a></center>")
	}

	document.writeln("</td></tr></table></td></tr></table>");
}

// Prints a image with caption.
function PrintImage(url, align, courtesy, width, textalign) {
	document.writeln("<table border=0 cellpadding=1 cellspacing=0 align="+align+"><tr><td bgcolor=black>");
	document.writeln("<table border=0 cellpadding=0 cellspacing=0 align=center width="+width+"><tr><td>");
	document.writeln("<img src="+url+" border=0></td></tr>");
	if (courtesy != "none")
		document.writeln("<tr><td bgcolor=#EEEEEE><font size=0><div align="+textalign+">&nbsp;"+courtesy+"</div></font></td></tr>");

	document.writeln("</table></td></tr></table>")
}

// Highlights a link when the mouse passes over it.
function highlightLink() {
	src = event.toElement;
	if( src.tagName == "A") {
		src.oldcol = src.style.color;
		if (src.className == "lnkhd") src.style.color = "#666666"
		else src.style.color = "#DB6709";
	}
}

// Returns it to its original colour.
function unhighlightLink() {
	src=event.fromElement;
	if( src.tagName == "A" ) {
		src.style.color = src.oldcol;
		src.style.bold = false;
	}
}

// Checks for the browser.
var isIE4up = ((navigator.appName == "Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4));
if (isIE4up) {
   document.body.onmouseover = highlightLink;
   document.body.onmouseout = unhighlightLink;
}

// Flip the image.
function flipImage(url, names) {
	if(navigator.appVersion.lastIndexOf("MSIE 3") == -1) document[names].src = url;
}

function WriteCookie (cookieName, cookieValue, expiry) {
	var expDate = new Date();
	if(expiry) {
	    expDate.setTime (expDate.getTime() + expiry);
	    document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString();
	}
	else {
	    document.cookie = cookieName + "=" + escape (cookieValue);
	}
}

function ReadCookie (CookieName) {
	var CookieString = document.cookie;
	var CookieSet = CookieString.split (';');
	var SetSize = CookieSet.length;
	var CookiePieces
	var ReturnValue = "";
	var x = 0;
	
	for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) {
		
		CookiePieces = CookieSet[x].split ('=');
		
		if (CookiePieces[0].substring (0,1) == ' ') {
			CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length);
		}
		
		if (CookiePieces[0] == CookieName) {
			ReturnValue = CookiePieces[1];
		}
	}

	return unescape(ReturnValue)
}