//# PB Toolbox Expanding UL/LI Menus
//# Usage
//# menu = new toolbox_listmenu(<ID OF ROOT LIST>);
//# menu.init();

			function  toolbox_listmenu(rootID) {
			this.rootID = rootID;
			this.rootElement = document.getElementById(rootID);
			this.init = toolbox_listmenu_init;
			this.expandParents = toolbox_listmenu_expandParents;
			this.expandSubElements = toolbox_listmenu_expandSubElements
			this.collapseSubElements = toolbox_listmenu_collapseSubElements
			this.activateLink = toolbox_listmenu_activateLink
			}
			
			function toolbox_listmenu_activateLink() {
				var active = toolbox_nodes_getActiveLink(this.rootElement,document.location);
				if (active) {
				active.className = "active";
				this.expandParents(active);
				this.expandSubElements(active.parentNode,"ul");
				}
			}
			
			
			
			function toolbox_listmenu_collapseSubElements(obj,coltype) {
			var i=0;
			var checkName = new String(coltype);
			var colObj = obj.childNodes;
			while(colObj[i]) {
			colName = new String(colObj[i].nodeName);
			if (colName.toLowerCase() == checkName.toLowerCase()) {
			colObj[i].style.display="none";
			}
			i++;
			}
			}
			
			function toolbox_listmenu_expandSubElements(obj,coltype) {
			var i=0;
			var checkName = new String(coltype);
			var colObj = obj.childNodes;
			while(colObj[i]) {
			colName = new String(colObj[i].nodeName);
			if (colName.toLowerCase() == checkName.toLowerCase()) {
			colObj[i].style.display="";
			}
			i++;
			}
			}
			
			function toolbox_listmenu_toggleSubElements(obj,coltype) {
			var i=0;
			var checkName = new String(coltype);
			var colObj = obj.childNodes;
			while(colObj[i]) {
			colName = new String(colObj[i].nodeName);
			if (colName.toLowerCase() == checkName.toLowerCase()) {
			toolbox_style_toggleDisplay(colObj[i]);
			}
			i++;
			}
			}
			
			function toolbox_listmenu_expandParents(obj) {
			while(obj.parentNode) {
			if (obj.parentNode.id == this.rootID) { 
			return; 
			} else {
			obj.parentNode.style.display='';
			obj = obj.parentNode;
			}
			}
			
			}
			
			function toolbox_listmenu_init() {
			ulObj = this.rootElement;
			liObj = ulObj.getElementsByTagName("li");
			var i=0
			while(liObj[i]) {
			this.collapseSubElements(liObj[i],"ul");
			myLink = toolbox_nodes_getFirstOf(liObj[i],"a");
			toolbox_listmenu_attachEvent(myLink);
			i++;
			}
			
			this.activateLink();
			
			}
			

			
			function toolbox_listmenu_attachEvent(obj) {
			if (obj){
			obj.onclick = function() { toolbox_listmenu_toggleSubElements(this.parentNode,"ul") }
			}
			}
			
			
			
			
			