//# 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
			this.attachEvent = toolbox_listmenu_attachEvent
			}
			
			function toolbox_listmenu_activateLink() {
				var checkloc = stripQueryString(document.location);
				var active = toolbox_nodes_getActiveLink(this.rootElement,checkloc);
				if (active) {
				active.className += " active";
				this.expandParents(active);
				this.expandSubElements(active.parentNode,"UL");
				}
			}
			
			function toolbox_listmenu_show(obj) {
				obj.folderOpen = true;
				obj.style.display='block';
				par = toolbox_nodes_getFirstParentByType(obj,'LI');
				para = toolbox_nodes_getFirstOf(par,'A');
				if (para.className=='folderClosed') {
				para.className = 'folderOpen';
				}

			}
			
			function toolbox_listmenu_hide(obj) {
				obj.folderOpen = false;
				obj.style.display='none';
				par = toolbox_nodes_getFirstParentByType(obj,'LI');
				para = toolbox_nodes_getFirstOf(par,'A');
				if (para.className=='folderOpen') {
				para.className = 'folderClosed';
				}

			}
			
			
			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()) {

			toolbox_listmenu_hide(colObj[i]);
			}
			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="";
			toolbox_listmenu_show(colObj[i]);
			}
			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_listmenu_toggleDisplay(colObj[i]);
			}
			i++;
			}
			}
			
			function toolbox_listmenu_expandParents(obj) {
			while(obj.parentNode) {
			if (obj.parentNode.id == this.rootID) { 
			return; 
			} else {
			//obj.parentNode.style.display='';
			toolbox_listmenu_show(obj.parentNode);
			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");
			this.attachEvent(myLink);
			i++;
			}
			
			this.activateLink();
			
			}
			

			
			function toolbox_listmenu_attachEvent(obj) {
			if (obj){
			var p =  toolbox_nodes_getFirstParentByType(obj,'LI');
			obj.onclick = function() { 
				toolbox_listmenu_toggleSubElements(p,"UL") 
			}
			}
			}
			
			
			function toolbox_listmenu_toggleDisplay(obj) {
	
			
			if (obj.folderOpen==false || obj.style.display=='none') {
				toolbox_listmenu_show(obj);
			} else {
				toolbox_listmenu_hide(obj);
			}
			}
			
			

			
			
			
			
			
			function toolbox_style_toggleDisplay(obj) {
			
			if (obj.style.display=='none') {
			obj.style.display = 'block';
			return true;
			} else {
			obj.style.display='none';
			return false;
			}
			}
			
			
					
			
			
