/* * dropdown menu * ============= * based on code from: * Dave Lindquist (http://www.gazingus.org) * http://www.jessett.com */ var currentActuator = null; var currentMenu = null; var timerID = null; var timecount = 500; if (!document.getElementById) document.getElementById = function() { return null; } function initializeMenu(barType, menuId, actuatorId) { var menu = document.getElementById(menuId); var actuator = document.getElementById(actuatorId); if (menu == null || actuator == null) return; menu.barType = barType; if (menu.barType == "top") { menu.style.left = actuator.offsetLeft + "px"; menu.style.top = actuator.offsetTop + actuator.offsetHeight + "px"; } else { menu.style.width = "150px"; } menu.onmouseover = function() { if (currentMenu.barType == "left") { currentActuator.style.borderTop = "1px solid #800080"; currentActuator.style.borderBottom = "1px solid #800080"; currentActuator.style.backgroundColor = "#FFFFFF"; currentActuator.style.padding = "1px 5px 0px 5px"; } stopTimer(); } menu.onmouseout = function() { startTimer(); } actuator.onmouseover = function() { hideMenu(); this.className = "hand"; this.showMenu(); stopTimer(); } actuator.onmouseout = function() { startTimer(); } actuator.showMenu = function() { if (menu.barType == "left") { actuator.style.borderTop = "1px solid #800080"; actuator.style.borderBottom = "1px solid #800080"; actuator.style.backgroundColor = "#FFFFFF"; actuator.style.padding = "1px 5px 0px 5px"; menu.style.left = getLeft(actuator) + actuator.offsetWidth + "px"; menu.style.top = getTop(actuator) + "px"; } menu.style.visibility = "visible"; currentActuator = actuator; currentMenu = menu; } } function hideMenu() { if (currentMenu) { if (currentMenu.barType == "left") { currentActuator.style.border = "0px"; currentActuator.style.borderTop = "1px solid #EEEEEE"; currentActuator.style.backgroundColor = "#FFFFFF"; currentActuator.style.padding = "1px 5px"; } currentMenu.style.visibility = "hidden"; } } function startTimer() { timerID = setTimeout("hideMenu();", timecount); } function stopTimer() { if (timerID) { clearTimeout(timerID); timerID = null; } } function getLeft(obj) { if (obj == null) return 0; return getLeft(obj.offsetParent) + obj.offsetLeft; } function getTop(obj) { if (obj == null) return 0; return getTop(obj.offsetParent) + obj.offsetTop; }