// Utility Functions
function addListener(obj, evnt, func) {
	if(obj.addEventListener)
		obj.addEventListener(evnt, func, false);
	else if(obj.attachEvent)
		obj.attachEvent("on" + evnt, func);
}
function removeListener(obj, evnt, func) {
	if(obj.removeEventListener)
		obj.removeEventListener(evnt, func, false);
	else if(obj.detachEvent) 
		obj.detachEvent("on" + evnt, func);
}


// Tooltips
function setTipFunctions(obj) {
	for(var i = 0; i < obj.childNodes.length; i++) {
		node = obj.childNodes[i];
		if(node.nodeName == "SPAN") {
			obj.tip = node;
		}
	}
	obj.onmouseover = function() {
		this.tip.className += " over";
	}
	obj.onmouseout = function() {
		this.tip.className = this.tip.className.replace(" over", "");
	}
}
function makeTips(obj) {
	for(var i = 0; i < obj.childNodes.length; i++) {
		var node = obj.childNodes[i];
		if(node.className == "tooltip") {
			setTipFunctions(node);
		} else {
			makeTips(node);
		}
	}
}
function startList(menuId) {
	if(document.getElementById && document.getElementById(menuId) && document.getElementById(menuId).childNodes[0]) {
		navRoot = document.getElementById(menuId).childNodes[0];
		for (i = 0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					this.className += " over";
				}
				node.onmouseout = function() {
					this.className = this.className.replace(" over", "");
				}
			}
		}
	}
}

addListener(window, "load", loadTips);
			
function loadTips() {
	if(document.all) { // IE
		makeTips(document);
		startList("menu");
	}
	if(document.forms[0]) {
		var elem = document.forms[0].elements;
		for(i = 0; i < elem.length; i++) {
			if(elem[i].nodeName == "INPUT"
					 && elem[i].type == "text") {
				try {
					elem[i].focus();
					break;
				} catch(e){}
			}
		}
	}
	if(window.loadBody) window.loadBody();
}