// $Id: menu.js.php,v 1.2 2003/05/09 13:22:02 nio Exp $ var pauseBeforeShow = 100; var tmpEl, showTimeoutHandle; var menus = new Array() var menuCounter = 0; var zIndexMax = 0; var tmpArray = new Array(); var tmpCounter = 0; var roots = new Array(); // called with either an element or two or four numbers // new Boundaries(htmlElement) // new Boundaries(nLeft, nTop) // new Boundaries(nLeft, nTop, nWidth, nHeight) function Boundaries() { if (arguments.length == 1) { this.left = leftPos(arguments[0]); this.top = topPos(arguments[0]); this.width = arguments[0].offsetWidth; this.height = arguments[0].offsetHeight; } if (arguments.length >= 2) { this.left = arguments[0]; this.top = arguments[1]; this.width = 0; this.height = 0; } if (arguments.length >= 4) { this.width = arguments[2]; this.height = arguments[3]; } } //////////////////////////////////////////////////////// //The following "two" functions are needed to calculate the position function topPos(el) { return doPosLoop(el, "Top"); } function leftPos(el) { return doPosLoop(el, "Left"); } function doPosLoop(el, val) { var temp = el; var x = temp["offset" + val]; while (temp.tagName!="BODY") { temp = temp.offsetParent; x += temp["offset" + val]; } return x; } //////////////////////////////////////////////////////// // This function get the border sizes of a table for IE4 function getBorderSizes(tableEl) { var o = new Object(); if (document.getElementById) { o.top = parseInt(tableEl.currentStyle.borderTopWidth); o.left = parseInt(tableEl.currentStyle.borderLeftWidth); o.right = parseInt(tableEl.currentStyle.borderRightWidth); o.bottom = parseInt(tableEl.currentStyle.borderBottomWidth); } else { var w = 0; for (var i=0; i= document.body.scrollTop) top = boundaries.top - tableEl.offsetHeight; else if (document.body.clientHeight >= tableEl.offsetHeight + borders.top + borders.bottom) top = document.body.clientHeight + document.body.scrollTop - tableEl.offsetHeight - borders.top - borders.bottom; else top = document.body.scrollTop; if (boundaries.left + tableEl.offsetWidth <= document.body.clientWidth + document.body.scrollLeft) left = boundaries.left; else if (document.body.clientWidth >= tableEl.offsetWidth + borders.left + borders.right) left = document.body.clientWidth + document.body.scrollLeft - tableEl.offsetWidth - borders.left - borders.right; else left = document.body.scrollLeft; } else { if (boundaries.top + tableEl.offsetHeight - borders.top <= document.body.clientHeight + document.body.scrollTop) top = boundaries.top - borders.top; else if (boundaries.top + boundaries.height - tableEl.offsetHeight + borders.top >= 0) top = boundaries.top + boundaries.height - tableEl.offsetHeight + borders.top; else if (document.body.clientHeight >= tableEl.offsetHeight + borders.top + borders.bottom) top = document.body.clientHeight + document.body.scrollTop - tableEl.offsetHeight - borders.top - borders.bottom; else top = document.body.scrollTop;; if (boundaries.left + boundaries.width + tableEl.offsetWidth <= document.body.clientWidth + document.body.scrollLeft) left = boundaries.left + boundaries.width; else if (boundaries.left - tableEl.offsetWidth >= 0) left = boundaries.left - tableEl.offsetWidth; else if (document.body.clientWidth >= tableEl.offsetWidth + borders.left + borders.right) left = document.body.clientWidth + document.body.scrollLeft - tableEl.offsetWidth - borders.left - borders.right; else left = document.body.scrollLeft; } if (zIndexMax == null) { var a = document.all; var al = a.length; for (var i=0; i'; */ if (navigator.userAgent.indexOf("MSIE 6.0")>=1) {//IE6 的offHeight当设置了'; document.body.insertAdjacentHTML("BeforeEnd", str); menus[menuCounter] = tableEl; initiateMenu(menuCounter, pause); menuCounter++; } function initiateMenu(menuNumber, pause) { var el = document.all("_menu_" + menuNumber); if (el == null || el.readyState != "4") window.setTimeout("initiateMenu(" + menuNumber + ", " + pause + ")", 50); else { // el.initiateMenu(menus[menuNumber], el); tmpArray[tmpCounter] = el; window.setTimeout( "tmpArray[" + tmpCounter + "].initiateMenu(menus[" + menuNumber + "], tmpArray[" + (tmpCounter++) + "])", pause); } } function hideAllMenuScriptlets() { var objs = document.all.tags("OBJECT"); for (var i=0; i -1; } function isMenuBar(el) { return el.className == "menuBar"; } function getParent(el, f) { if (el == null) return null; else if (f(el)) return el; else return getParent(el.parentElement, f); } function go(url,newwin) { if(newwin==1) window.open(url,'',''); else top.location.href = url; } //document.onmousedown = hideAllMenuScriptlets; if (document.attachEvent) document.attachEvent("onclick", hideAllMenuScriptlets); else document.onclick = hideAllMenuScriptlets;