/* Perform image-swapping on menu buttons */

function createButtons() {
	//Check for script compatibility
	if (!document.getElementsByTagName("img")) return false;
	var myButtons = document.getElementsByTagName("img");
	for (var i =0; i < myButtons.length; i++) {
		//Find all the 'menuButton' images and assign mouseover behaviors to them
		if (myButtons[i].getAttribute("class") == 'menuButton'||myButtons[i].getAttribute("class") == 'menuButton floatRight') {
			createMouseOver(myButtons[i], "images/" + myButtons[i].getAttribute("name") + "_ov.jpg", "images/" + myButtons[i].getAttribute("name") + ".jpg");
		}
		//If it's the current page, keep it in the mouseover image state
		if (myButtons[i].getAttribute("class") == 'activeButton') {
			myButtons[i].setAttribute("src", "images/" + myButtons[i].getAttribute("name") + "_ov.jpg");
		}
	}
}

function createMouseOver(button, newButton, originalButton) {
	button.onmouseover = function() {
		swapImage(button, newButton);	
	}
	button.onmouseout = function() {
		swapImage(button, originalButton);
	}
}

function swapImage(button, newButton) {
	button.setAttribute("src", newButton);
}

addLoadEvent(createButtons);

