var eOpenMenu = null; var item; document.onmouseover = mOver; // handle the mouseover event document.mouseover function mOver(e) { if(!e) { var e = window.event; } var eSrc = e.srcElement ? e.srcElement : e.target; // is the current element a menu bar item if (eSrc.id.substr(0,13) == "tdMenuBarItem") { // load the DIV menu that corresponds our current element var eMenu = document.all[eSrc.id.replace("tdMenuBarItem","divMenu")]; // if a menu is displayed (not null) and it is not our current menu if (eOpenMenu && eOpenMenu != eMenu) { CloseMenu(eOpenMenu); } // if we got a menu, display it if (eMenu) { OpenMenu(eSrc,eMenu); } } // if a menu open and the current element not a menu item close menu else if (eOpenMenu && !contains(eOpenMenu, eSrc) && (eSrc.className == "clsMenuLink" || !contains(divMenuBar, eSrc))) { CloseMenu(eOpenMenu); } } // paint the menu function OpenMenu(eSrc,eMenu) { var left = 0; var top = eSrc.offsetHeight; // figure menu location by adding all parents corners for (item = eSrc; item; item = item.offsetParent){ left += item.offsetLeft; top += item.offsetTop; } // have new menu set to right location and turn it on eMenu.style.left = left; eMenu.style.top = top; eMenu.style.visibility = "visible"; eOpenMenu = eMenu; } // remove the menu function CloseMenu(eMenu) { eMenu.style.visibility = "hidden"; eOpenMenu = null; } function contains(a, b) { // we climb through b parents // till we find a while(b && (a!=b) && (b!=null)) b = b.parentNode; return a == b; }