// Javascript by Micky Hulse micky@ambiguism.com

startList = function() {
	if (document.all&&document.getElementById) {
		var node1 = document.getElementById("nav");
		var node2 = document.getElementById("snav");
		if(node1) { AssignMenuEvents(node1); }
		if(node2) { AssignMenuEvents(node2); }
	}
};

//onload function
generic = function() { /* alert('Generic onload function'); */ }; 

AssignMenuEvents = function(pObject) {
	var node;
	var vPreviousIndex;

	for (i=0; i<pObject.childNodes.length; i++) {
		node = pObject.childNodes[i];

		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className+=(this.className.length>0? " ": "") + "over";
			}
			node.onmouseout=function() {
				this.className=this.className.replace(new RegExp("( ?|^)over\\b"), "");
			}
			node.onclick=function() {
				this.className=this.className.replace(new RegExp("( ?|^)over\\b"), "");
			}
		}

		if (node.childNodes.length>0) {
			vPreviousIndex = i;
			AssignMenuEvents(node);
			i = vPreviousIndex;
		}
	}
};

// Only IE needs the hover script
if(window.addEventListener) window.addEventListener('load', generic, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', generic, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', startList);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			startList();
		}
	} else {
		window.onload = function() {
			startList();
		}
	}
}

