/** Animated TreeMenu script by Garrett Smith * * URL:http://dhtmlkitchen.com/ * email:admin@dhtmlkitchen.com * * Usage: see http://dhtmlkitchen.com/ * * [11/29/02] * TreeGlobals.browser has been replaced with * Browser utils.js */ TreeGlobals = { // don't change inited : false }; if(typeof window.TreeParams == "undefined") TreeParams = { // You will probably have to change these. /** TreeParams: * OPEN_MULTIPLE_MENUS -- Boolean. * if true, more than one menu can * be open at a time. Otherwise, * opening a new menu closes any * open menu. * * * * TIME_DELAY -- int. * How slowly a menuNode collapses * in milliseconds. (0 to 100). * * OPEN_WHILE_CLOSING -- Boolean. * If either OPEN_MULTIPLE_MENUS or * OPEN_WHILE_CLOSING will simultaneously * open a new menu while closing the * currently open menu. */ OPEN_MULTIPLE_MENUS : false, TIME_DELAY : 10, OPEN_WHILE_CLOSING : true, OPEN_MENU_ICON : "../images/open-menu.gif", CLOSED_MENU_ICON : "../images/closed-menu.gif" }; // Unless you really know what you are doing, // don't change anything below this line! //_________________________________________________________________________ /////////////////////////////////////////////////////////////////////////// function toggleMenu(el) { if(Browser.id.OP5 || Browser.id.NS4) return; var label = TreeFunctions.getLabel(el); if(label.menu.blocked) return; if(label.menu.container.menuToOpen != null) return; if(label.isDepressed) { if (TreeParams.OPEN_MULTIPLE_MENUS || label.menu.container.activeMenu == label.menu) { TreeFunctions.closeMenu(label.menu); label.menu.container.activeMenu = null; } } else{ // push it in. if(label.icon != null) label.icon.src = TreeParams.OPEN_MENU_ICON; label.menu.container.menuToOpen = label.menu; if(TreeParams.OPEN_MULTIPLE_MENUS || label.menu.container.activeMenu == null ) { TreeFunctions.openMenu(label.menu); } else { TreeFunctions.closeMenu(label.menu.container.activeMenu); if(TreeParams.OPEN_WHILE_CLOSING) TreeFunctions.openMenu(label.menu); else label.menu.container.activeMenu.menuInCue = label.menu; } label.menu.container.activeMenu = label.menu; } } /** Opens a menu. * Usually called with body onload handler. */ function activateMenu(sButtonId){ if(!window.toggleMenu || Browser.id.OP5) return; var button = document.getElementById(sButtonId); if(!button) return; var parentMenuEl = findAncestorWithClass(button, "menu"); if(parentMenuEl != null){ var bId = parentMenuEl.id.substring(0, parentMenuEl.id.indexOf("Menu")); activateMenu(bId); } var label = TreeFunctions.getLabel(getElementsWithClass(button, "*", "buttonlabel")[0]); if(!label.isDepressed) toggleMenu(label.el); } /** Button mouseover event handler. * Called with onmouseover handler. */ function buttonOver(el){ window.status = el.parentNode.id; label = TreeFunctions.getLabel(el); if(hasToken(label.el.className, "labelHover")) return; label.el.className += " labelHover"; } /** Button mouseover event handler. * Called with onmouseout handler. */ function buttonOff(label){ window.status = window.defaultStatus; removeClass(label, "labelHover"); } if(typeof document.getElementsByTagName == "undefined" || Browser.id.OP5) buttonOver = buttonOff = function(){}; /** Button constructor to be used privately. */ Button = function(el, category){ this.el = el; this.category = category; this.menu = new Menu(document.getElementById(this.category +"Menu"), this); var icons = el.getElementsByTagName("img"); this.icon = (icons.length > 0) ? icons[0] : null; this.isIcon = false; if(el.tagName == "IMG"){ this.isIcon = true; this.icon = el; } this.isDepressed = false; }; /** Menu constructor to be used privately. */ Menu = function(el, label) { this.ownerButton = label; this.id = label.category; // a short-cut reference to this.ownerButton.category. this.el = el; this.items = getChildNodesWithClass(el, "menuNode"); this.allItems = getElementsWithClass(el, "*", "menuNode"); this.cur = 0; this.blocked = false; this._root = null; // look for ancestor with class menu. // get that element's id minus "Menu" this.container = this.getContainer(); this.menuToOpen = null; this.activeMenu = null; this.menuInCue = null; }; /** Stupid debug function. */ function debug(s, obj){ var rv = ""; for(var x in obj) rv += s+"."+x+ " = "+ obj[x]; document.write("