
var hdanz = {

	/*
	 * contains reference to the admin menu ul element that the script uses
	 * to show or hide on mouse over for IE because of not supporting the 
	 * :hover pesudoclass properly.
	 */
	adminMenu : null,

	startList : function() {
		if (document.getElementById("nav-second")) {
			navRoot = document.getElementById("nav-second");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					for (x=0; x<node.childNodes.length; x++) {
						y = node.childNodes[x];
						if (y.nodeName=="SPAN") {
							y.onmousedown=function() {
								hdanz.collapseAll();
								this.parentNode.className+=" over active";
							}
						}
					}
				}
			}
		}
	},

	collapseAll : function() {
		if (document.getElementById("nav-second")) {
			navRoot = document.getElementById("nav-second");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.className=node.className.replace(" over", "");
					node.className=node.className.replace(" active", "");
				}
			}
		}
	},

	/*
	 * Add the event handlers that show and hide the admin menu when the user
	 * moves the mouse over the "client login" button.
	 */
	adminMenu : function() {
		if (document.getElementById('nav-first')) {
			var menuItems = document.getElementById('nav-first').getElementsByTagName('li');
			for (var i = 0; i < menuItems.length; i++) {
				if (menuItems[i].className == 'login') {
					var adminMenu = menuItems[i].getElementsByTagName('ul');
					if (adminMenu.length == 1) {
						hdanz.adminMenu = adminMenu[0];
						menuItems[i].onmouseover = function() {
							hdanz.adminMenu.style.display = 'block';
						}
						menuItems[i].onmouseout = function() {
							hdanz.adminMenu.style.display = 'none';
						}
					}
				}
			}
		}
	}

}

window.onload = function() {
	hdanz.startList();
	hdanz.adminMenu();
}
