addOnload(initAll);
addOnload(rolloverInit);

function addOnload(newFunction) {
	var oldOnload = window.onload;

	if(typeof oldOnload == "function") {
		window.onload = function() {
			if(oldOnload) {
				oldOnload();
			}
			newFunction();
		}
	}
	else {
		window.onload = newFunction;
	}
}

function initAll() {
	var allLinks = document.getElementsByTagName("a");

	for (var j=0; j<allLinks.length; j++) {
		if (allLinks[j].className.indexOf("menuLink")> -1) {
			allLinks[j].onclick = function() {return false;}
			allLinks[j].onmouseover = toggleMenu;
		}
	}
}

function toggleMenu() {
	var startMenu = this.href.lastIndexOf("/")+1;
	var stopMenu = this.href.lastIndexOf(".");
	var thisMenuName = this.href.substring(startMenu,stopMenu);

	document.getElementById(thisMenuName).style.display = "block";

	this.parentNode.className = thisMenuName;
	this.parentNode.onmouseout = toggleDivOff;
	this.parentNode.onmouseover = toggleDivOn;

}

function toggleDivOn() {
	document.getElementById(this.className).style.display = "block";

}

function toggleDivOff() {
	document.getElementById(this.className).style.display = "none";

}


function rolloverInit() {
	for (var i=0;i<document.images.length; i++){
		if(document.images[i].parentNode.tagName =="A"){
			setupRollover(document.images[i]);
		}
	}
}

function setupRollover(thisImage){
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;


	thisImage.overImage = new Image();
	thisImage.overImage.src = "Graphics/" + thisImage.id + "_on.gif";
	thisImage.onmouseover = rollOver;
}

function rollOver() {
	this.src = this.overImage.src;
}

function rollOut(){
	this.src = this.outImage.src;
}
