var currentMenu = null; if (!document.getElementById) document.getElementById = function() { return null; } function showImage(image) { image.defaultsrc = image.src; index = image.src.indexOf(".jpg"); image.src = image.src.substring(0,index)+"_over.jpg" } function hideImage(image) { image.src = image.defaultsrc; } function initializeMenu(menuId, actuatorId, imageId) { var menu = document.getElementById(menuId); var actuator = document.getElementById(actuatorId); var image = document.getElementById(imageId); if (actuator == null) return; actuator.onmouseover = function() { if (currentMenu == null) { this.showMenu(); } else { currentMenu.style.visibility = "hidden"; currentMenu = null; this.showMenu(); } } actuator.onmouseout = function() { if (currentMenu != null) { currentMenu.style.visibility = "hidden"; currentMenu = null; } if (image!=null) image.style.visibility = "hidden"; } if (menu!=null) { menu.onmouseout = function() { if (currentMenu != null) { currentMenu.style.visibility = "hidden"; currentMenu = null; } if (image!=null) image.style.visibility = "hidden"; } } actuator.showMenu = function() { if (menu!=null) { menu.style.left = this.getRealLeft()-1+"px"; menu.style.top = this.getRealTop() + this.offsetHeight + "px"; menu.style.visibility = "visible"; currentMenu = menu; } if (image!=null) { image.style.left = this.getRealLeft()+"px"; image.style.top = this.getRealTop() + "px"; image.style.visibility = "visible"; } } actuator.getRealLeft = function() { xPos = this.offsetLeft; tempEl = this.offsetParent; while (tempEl != null) { xPos += tempEl.offsetLeft; tempEl = tempEl.offsetParent; } return xPos; } actuator.getRealTop = function() { xPos = this.offsetTop; tempEl = this.offsetParent; while (tempEl != null) { xPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; } return xPos; } }