/** * copyright (c)2005-2009 matt kruse (javascripttoolbox.com) * * dual licensed under the mit and gpl licenses. * this basically means you can use this code however you want for * free, but don't claim to have written it yourself! * donations always accepted: http://www.javascripttoolbox.com/donate/ * * please do not link to the .js files on javascripttoolbox.com from * your site. copy the files locally to your server instead. * */ /* 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); } } } // 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