//Global Variables
colorversion = true;
resultstring = "";
debug = false;

//Functions

function printerfriendly(){
//Detect our current color or printer-friendly display.
//colorversion = (window.document.styleSheets[0].href.search("style.css") != -1);
//Detect our browser
msft = (navigator.appName.indexOf("Microsoft") != -1);
nscp = (navigator.appName.indexOf("Netscape") != -1);
aol  = (navigator.appName.indexOf("AOL") != -1);
if (aol)
	{alert("colorversion = " + colorversion + "Browser IDs: AOL =" + aol + " MSFT = " + msft + " NSCP = " + nscp);
	}
//Now we flip from one display to the other by swapping/adjusting the style sheet.
if (colorversion)
	{
	if (nscp)
		{ window.document.styleSheets[0].disabled = true;
		  window.document.fgColor = "black";
		  window.document.bgColor = "white";
		}
	else
		{ css_string = window.document.styleSheets[0].href.replace("style.css","stylebw.css");
		  window.document.styleSheets[0].href = css_string;
		  window.document.links[0].innerText = "Return to Color Version";
		}
	colorversion = false;
	alert("You should now be seeing black text on a white background.\nTo restore the colors just click the link again.");
	}
else
	{
	//Reload the entire file and reset all vars for color.
	window.location.reload();
	}
}
function hitparade() {
//Derive the current file name, then increment the hit counter.
fnstart = location.href.lastIndexOf("/") + 1;
fnend = location.href.lastIndexOf(".htm") ;
filenam = location.href.substr(fnstart,fnend-fnstart).toLowerCase();
// The hit counter is an image cgi.  Derive the string.
imagesrc = '/cgi-bin/Count.cgi?df='+filenam+'.dat&dd=C';
// Inc the hit counter either as a visible image during debug or an invisible preloaded one, otherwise.
if (debug) 
	{imagestring = '<p align="right"><IMG SRC="'+imagesrc+'" width="60" height="10 " border="0"></p>';
	//alert("document.write("+imagestring+");");
	document.write(imagestring);
	}
else	
	{
	filenam = new Image;
	filenam.src = imagesrc;
	}
}

function urlpath(wholepath) {
//Derive current location, subtract the file, and return just the path.
fnstart = location.href.lastIndexOf("/") + 1;
wholepath = location.href.substr(0,fnstart).toLowerCase();
return wholepath;
}

function urlroot(rootpath) {
//Derive current location, return just the path between dstein1 and the file.  E.g. jh/ or jakeheggie/
rtstart = location.href.lastIndexOf("dstein1") + 8;
fnstart = location.href.lastIndexOf("/") + 1;
rootpath = location.href.substr(rtstart,fnstart-rtstart).toLowerCase();
if (debug) alert(rootpath);
return rootpath;
}

function urlfile(filenam) {
//Derive and return the current xxx.htm file name.
//This routine should scout for decorated urls...but it doesn't.
fnstart = location.href.lastIndexOf("/") + 1;
fnend = location.href.length;
filenam = location.href.substr(fnstart,fnend-fnstart).toLowerCase();
if (debug) alert("Urlfile(filename)="+filenam);
return filenam;
}

function urlfilestem(filenam) {
//Derive and return the current xxx file name WITHOUT the .htm extention.
//This routine should scout for decorated urls...but it doesn't.
fnstart = location.href.lastIndexOf("/") + 1;
fnend = location.href.lastIndexOf(".");
filenam = location.href.substr(fnstart,fnend-fnstart).toLowerCase();
if (debug) alert("Urlfile(filename)="+filenam);
return filenam;
}
function toggledebug() {
debug = !debug;
alert("Debug is now " + debug);
}

//End of Javascript Routines