function cmsMenu() { this.menuOpen = false; this.currHead = null; this.timer = null; this.menuIds = new Array(); } cmsMenu.prototype.addMenu = function(id) { this.menuIds.push(id); } cmsMenu.prototype.highlightSub = function(menuId, lineNum) { for (x = 0 ; true ; x++) { obj = cmsFindObj(menuId+"_sub"+x); if (! obj) break; obj.className = "cmsMenu_up cmsMenu_up_" + menuId; } if (lineNum != null) { cmsFindObj(menuId+"_sub"+lineNum).className = "cmsMenu_over cmsMenu_over_" + menuId; } if (this.menuTimer) clearTimeout(this.menuTimer); } // Change color of menu items when the mouse hovers over. cmsMenu.prototype.highlightMain = function(headId, menuId, state) { //Hide all the menus this.hideAll(headId); this.currHead = headId; var topOver = cmsFindObj(menuId+"_topOver"); if (topOver) { var topUp = cmsFindObj(menuId+"_topUp"); topOver.style.display = ""; topUp.style.display = "none"; } } cmsMenu.prototype.highlightNoPop = function(headId, menuId) { //Hide all the menus this.hideAll(headId, menuId); this.highlightMain(headId, menuId, 'over') if (this.menuTimer) clearTimeout(this.menuTimer); } // Find positioning for sub menus cmsMenu.prototype.getLeftOffset = function(headId, offsetHorizontal) { var obj = cmsFindObj(headId); var ret = obj.offsetLeft; if (offsetHorizontal >= 0) ret += offsetHorizontal; else ret += (obj.offsetWidth - 1); while(obj.offsetParent != null) { oPar = obj.offsetParent; ret += oPar.offsetLeft; obj = oPar; } return ret; } // Find positioning for sub menus cmsMenu.prototype.getTopOffset = function(headId, offsetVertical) { var obj = cmsFindObj(headId); var ret = obj.offsetTop; if (offsetVertical >= 0) ret += offsetVertical; else ret += (obj.offsetHeight - 1); while(obj.offsetParent != null) { oPar = obj.offsetParent; ret += oPar.offsetTop; obj = oPar; } return ret; } // Show sub menus cmsMenu.prototype.popDown = function(headId, menuId, offsetHorizontal, offsetVertical) { if (this.menuTimer) clearTimeout(this.menuTimer); var menuObj = cmsFindObj(menuId+"_menu"); if (menuObj) { //Force all the sublines into the up state this.highlightSub(menuId); //Set the menu position and make it visible. menuObj.style.left = this.getLeftOffset(headId, offsetHorizontal) + "px"; menuObj.style.top = this.getTopOffset(headId, offsetVertical) + "px"; menuObj.style.visibility = "visible"; this.menuOpen = true; } return false; } // Set timer for sub menus cmsMenu.prototype.clearMenu = function(menuId, suggestedDelay, mainDelay) { //Force all the sublines into the up state this.highlightSub(menuId); var topOver = cmsFindObj(menuId+"_topOver"); if (topOver) { var topUp = cmsFindObj(menuId+"_topUp"); topOver.style.display = "none"; topUp.style.display = ""; } //Set the menu to hide when appropriate if ((suggestedDelay == null) || this.menuOpen) suggestedDelay = mainDelay; if (suggestedDelay == 0) this.hideAll(); else this.menuTimer = setTimeout("cmsMenuObject.hideAll()", suggestedDelay * 1000); } cmsMenu.prototype.clickGo = function(url, loc) { this.hideAll(); if (loc == '_blank') cmsPopLink(url); else if (loc == 'script') eval(url); else window.location = url; } cmsMenu.prototype.hideAll = function(headId, menuId) { //de-highlight the head if (this.currHead) { if (headId != this.currHead) { menuId = false; this.highlightMain(this.currHead, menuId, 'up'); } } var origMO = this.menuOpen; this.menuOpen = false; var menuObj; var tmpMenuId; for (var i = this.menuIds.length-1 ; i >= 0 ; i--) { tmpMenuId = this.menuIds[i]; if (tmpMenuId == menuId) { //We're leaving a menu open, re-record it. this.menuOpen = origMO; } else { menuObj = cmsFindObj(tmpMenuId + "_menu"); if (menuObj) menuObj.style.visibility = "hidden"; } } } var cmsMenuObject = new cmsMenu();