/*=================================================================== Author: Matt Kruse View documentation, examples, and source code at: http://www.JavascriptToolbox.com/ NOTICE: You may use this code for any purpose, commercial or private, without any further permission from the author. You may remove this notice from your final code if you wish, however it is appreciated by the author if at least the web site address is kept. This code may NOT be distributed for download from script sites, open source CDs or sites, or any other distribution method. If you wish you share this code with others, please direct them to the web site above. Pleae do not link directly to the .js files on the server above. Copy the files to your own server for use with your site or webapp. ===================================================================*/ /* This code is inspired by and extended from Stuart Langridge's aqlist code: http://www.kryogenix.org/code/browser/aqlists/ Stuart Langridge, November 2002 sil@kryogenix.org Inspired by Aaron's labels.js (http://youngpup.net/demos/labels/) and Dave Lindquist's menuDropDown.js (http://www.gazingus.org/dhtml/?id=109) */ // Automatically attach a listener to the window onload, to convert the trees addEvent(window,"load",convertTrees); // Utility function to add an event listener function addEvent(o,e,f){ if (o.addEventListener){ o.addEventListener(e,f,false); return true; } else if (o.attachEvent){ return o.attachEvent("on"+e,f); } else { return false; } } // utility function to set a global variable if it is not already set function setDefault(name,val) { if (typeof(window[name])=="undefined" || window[name]==null) { window[name]=val; } } // Full expands a tree with a given ID function expandTree(treeId) { var ul = document.getElementById(treeId); if (ul == null) { return false; } expandCollapseList(ul,nodeOpenClass); } // Fully collapses a tree with a given ID function collapseTree(treeId) { var ul = document.getElementById(treeId); if (ul == null) { return false; } expandCollapseList(ul,nodeClosedClass); } // Expands enough nodes to expose an LI with a given ID function expandToItem(treeId,itemId) { var ul = document.getElementById(treeId); if (ul == null) { return false; } var ret = expandCollapseList(ul,nodeOpenClass,itemId); if (ret) { var o = document.getElementById(itemId); if (o.scrollIntoView) { o.scrollIntoView(false); } } } /* Start added by Rudy Gnodde */ // Expands 1 item function expandItem(itemId) { var el = document.getElementById(itemId); if (el == null) { return false; } el.className = nodeOpenClass; } /* End added by Rudy Gnodde */ // Performs 3 functions: // a) Expand all nodes // b) Collapse all nodes // c) Expand all nodes to reach a certain ID function expandCollapseList(ul,cName,itemId) { if (!ul.childNodes || ul.childNodes.length==0) { return false; } // Iterate LIs for (var itemi=0;itemi