window.onload = rolloverInit;


function rolloverInit() {
	for (var i=0; i<document.links.length; i++) {
		var linkObj =  document.links[i];
		if (linkObj.id) {
			var imgObj = document.getElementById(linkObj.id + "Img");
			if (imgObj) {
				setupRollover(linkObj,imgObj);
			}
		}
	}
initAll();
}



function setupRollover(thisLink,thisImage) {
	thisLink.imgToChange = thisImage;
	thisLink.onmouseout = function() {
		this.imgToChange.src = this.outImage.src;
	}
	thisLink.onmouseover = function() {
		this.imgToChange.src = this.overImage.src;
	}
	
	thisLink.outImage = new Image();
	thisLink.outImage.src = thisImage.src;

	thisLink.overImage = new Image();
	thisLink.overImage.src = "../web_files/iconover.gif";
}




function initAll() {
	var allLinks = document.getElementsByTagName("a");
	
	for (var i=0; i<allLinks.length; i++) {
		if (allLinks[i].className == "menuLink") {
			allLinks[i].onmouseover = toggleMenu;
			allLinks[i].onclick = function() {
				return false;
			}
		}
	}
}

function toggleMenu() {
	var stopMenu = this.href.lastIndexOf("/");
	var startMenu = stopMenu-5;
	var thisMenuName = this.href.substring(startMenu,stopMenu);

	document.getElementById(thisMenuName).style.display = "block";

	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = function() {
		document.getElementById(this.className).style.display = "none";
	}
	this.parentNode.onmouseover = function() {
		document.getElementById(this.className).style.display = "block";
	}
}
