/* 	NavSet returns these values for you to work with:
	Object.isOneSet
	Object.navs (array of menus if you need them) */
NavSet = function(par,el,aOff,aOn,def) // create Object w/ two navigation class states
{
	this.par = par;			// parent set ID
	this.el = el;			// element to use
	this.aOff = aOff;		// link offClass
	this.aOn = aOn;			// link onClass
	this.def = def;			// default menu substring
}
NavSet.prototype.getClassEls = function(elParent,elementName,className)
{
	if (document.getElementsByTagName(elParent))
	{	
		var allElements = document.getElementById(elParent).getElementsByTagName(elementName);
		var elemColl = new Array();
		var i = 0;
		while (i < allElements.length)
		{
			if (allElements[i].className == className) elemColl[elemColl.length] = allElements[i];
			i++;
		}
		return elemColl;
	} else return;
}
NavSet.prototype.stripSlash = function(x) //gecko gives a "/" preceding a.pathname & location.pathname rest not
{
	if (x.substring(0,1) == "/") return x.substring(1,x.length)
	else return x;
}
NavSet.prototype.set = function()
{
	if (document.getElementsByTagName)
	{
		var path = this.stripSlash(document.location.pathname.toLowerCase());
			path = path.replace("index.html","");
		this.navs = this.getClassEls(this.par,this.el,this.aOff);
		this.isOneSet = false;
		var c = 0;
		while (c < this.navs.length)
		{
			var x = this.stripSlash(this.navs[c].pathname.toLowerCase());
				x = x.replace("index.html","");
			if (x == "") ; // do nothing
			else if (x == path)
			{
				this.navs[c].className = this.aOn;
				this.isOneSet = true;
			}
			else if ((x.length < path.length) && path.indexOf(x) != -1)
			{
				this.navs[c].className = this.aOn;
				this.isOneSet = true;
			}
		c++;
		}
	} else return;
}
var Set = new NavSet("leftnav","a","","subon");
var SetA= new NavSet("topmenu","a","","current");
function doSetUp()
{
	if (document.getElementById("leftnav")) Set.set();
	if (document.getElementById("topmenu")) SetA.set();
	var subs = document.getElementById("subnav");
	if (subs)
	{
		if (subs.parentNode.firstChild.nodeName == "A") 
			subs.parentNode.firstChild.className = "subon";
	}
}
window.onload = doSetUp;
