// JavaScript Document

//addOnload(initRollover);
addOnload(initPage);

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

function initPage() {
var sURL = location.href;

	if (sURL.indexOf("?") > -1) {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].className.indexOf("menu") > -1) {
			if (document.images[i].parentNode.href == sURL) {
			currentPage (document.images[i]);
initRollover();
			}
		}
	}
} else {
currentPage (document.images[0]);
initRollover();
}
}

function currentPage (thisImage) {
	thisImage.src = "/assets/images/nav/" + thisImage.id + "_on.gif";
	thisImage.className = "noroll";
}

function initRollover() {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].className.indexOf("menu") > -1) {
			rolloverSetup(document.images[i]);
		}
	}
}

function rolloverSetup(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = function() {
		this.src = this.outImage.src;
	}

	thisImage.overImage = new Image();
	thisImage.overImage.src = "/assets/images/nav/" + thisImage.id + "_on.gif";
	thisImage.onmouseover = function() {
		this.src = this.overImage.src;
	}
}

