window.onload = initAll;

function initAll() {
	var allLinks = document.getElementsByTagName("a"); //this initiates the main horizonal menu
	img = new Array();
	
	for (var i=0; i<allLinks.length; i++) {
		if (allLinks[i].className.indexOf("menuLink") > -1) {
			if (allLinks[i].className.indexOf("dropMenu") > -1) {
				allLinks[i].onmouseover = toggleMenuOn;
				allLinks[i].onmouseout = toggleMenuOff;
				thisMenuName = allLinks[i].previousSibling.id;
				document.getElementById(thisMenuName).onmouseover = keepDivOn;
				document.getElementById(thisMenuName).onmouseout = exitDiv;
			} else {
				allLinks[i].onmouseover = toggleRollOverOn;
				allLinks[i].onmouseout = toggleRollOverOff;				
			}
			//preloads the over images
			img[i] = new Image();
			img[i].src = document.getElementById(allLinks[i].children[0].id).src.replace(".gif","_over.gif");
		}
	}
}

function toggleMenuOn() {
	if (document.getElementById(this.children[0].id).src.indexOf("_over.gif") < 0 && document.getElementById(this.children[0].id).src.indexOf("_sel.gif") < 0 ) {
		document.getElementById(this.children[0].id).src = document.getElementById(this.children[0].id).src.replace(".gif","_over.gif");
	}
		document.getElementById(this.previousSibling.id).style.visibility = "visible";
}
function toggleMenuOff() {
		document.getElementById(this.children[0].id).src = document.getElementById(this.children[0].id).src.replace("_over.gif",".gif");
		document.getElementById(this.previousSibling.id).style.visibility = "hidden";
}
function keepDivOn() {
	this.style.visibility = "visible";
	if (document.getElementById(this.nextSibling.children[0].id).src.indexOf("_over.gif") < 0 && document.getElementById(this.children[0].id).src.indexOf("_sel.gif")) {
		document.getElementById(this.nextSibling.children[0].id).src = document.getElementById(this.nextSibling.children[0].id).src.replace(".gif","_over.gif");
	}
}
function exitDiv() {
	this.style.visibility = "hidden";
		document.getElementById(this.nextSibling.children[0].id).src = document.getElementById(this.nextSibling.children[0].id).src.replace("_over.gif",".gif");
}
//this is the no drop menu situation
function toggleRollOverOn() { 
	if (document.getElementById(this.children[0].id).src.indexOf("_sel.gif") < 0 ) {
		document.getElementById(this.children[0].id).src = document.getElementById(this.children[0].id).src.replace(".gif","_over.gif");
	}
}
function toggleRollOverOff() {
	document.getElementById(this.children[0].id).src = document.getElementById(this.children[0].id).src.replace("_over.gif",".gif");
}

