// JavaScript Document

window.onload = initAll;

function initAll() {

MM_preloadImages('images/menu-02_on.jpg','images/menu-03_on.jpg','images/menu-04_on.jpg','images/menu-05_on.jpg','images/menu-06_on.jpg','images/menu-07_on.jpg','images/menu-08_on.jpg');

	var allLinks = document.getElementsByTagName("a");
	
	for (var i=0;i<allLinks.length;i++) {
		if (allLinks[i].className.indexOf("menuLink") > -1) {
			allLinks[i].onclick = toggleMenu;
		}
	}
}

function toggleMenu() {
	var startMenu = this.href.lastIndexOf("/")+1; // set startMenu to equal the position of the character after the last "/" in the link that's passed into this function
	var stopMenu = this.href.lastIndexOf("."); // set stopMenu to equal the position of the last "." in that link that's passed into this function
	var thisMenuName = this.href.substring(startMenu,stopMenu); // set thisMenuName to equal everything starting at startMenu and before stopMenu, e.g., menu1.html becomes menu1
	
	var thisMenu = document.getElementById(thisMenuName).style;
	if (thisMenu.display == "block") {
		thisMenu.display = "none";
	}
	else {
		thisMenu.display = "block";
	}
	
	return false; // because we don't actually want to go to menu1.html, which is a nonexistent page
}
	