/*
	Expandable Listmenu Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

	function initMenus() {
		if (!document.getElementsByTagName) return;
		
		var aMenus = document.getElementsByTagName("LI");
		for (var i = 0; i < aMenus.length; i++) {
			var mclass = aMenus[i].className;
			if (mclass.indexOf("treenode") > -1) {
				var submenu = aMenus[i].childNodes;
				for (var j = 0; j < submenu.length; j++) {
					if (submenu[j].tagName == "A") {
						
						submenu[j].onclick = function() {
							var node = this;
							
							while (1) {
								if (node != null) {
									if (node.tagName == "UL" || node.tagName == "DIV" || node.tagName == "P") {
										var d = (node.style.display == "none");
										node.style.display = (d) ? "block" : "none";
										this.className = (d) ? "treeopen" : "treeclosed";
										return false;
									} else if (node.tagName == "A") {
										var w = (node.style.fontWeight == "bold");
										node.style.fontWeight = (w) ? "normal" : "bold";
									}
									node = node.nextSibling;
								} else {
									return false;
								}
							}
							return false;
						}
						
						submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
					}
					
					if (submenu[j].tagName == "UL" || submenu[j].tagName == "DIV" || submenu[j].tagName == "P")
						submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
				}
			}
		}
	}


/*
    Open all closed tree nodes
*/

	function openAll() {
		var aMenus = document.getElementsByTagName("LI");
		for (var i = 0; i < aMenus.length; i++) {
			var mclass = aMenus[i].className;
			if (mclass.indexOf("treenode") > -1) {
				var submenu = aMenus[i].childNodes;
				for (var j = 0; j < submenu.length; j++) {
					if (submenu[j].tagName == "A") {
						//var w = (submenu[j].style.fontWeight == "bold");
						//submenu[j].style.fontWeight = (w) ? "normal" : "bold";
						submenu[j].style.fontWeight = "bold";
					}
					if (submenu[j].tagName == "UL") {
						submenu[j].style.display = "block";
						this.className = "treeopen";
					}
				} 
			} 
		} 
	} 

/*
	call openAll, then print
*/	
	function printMe() {
		openAll();
		window.print();
	}

	
	window.onload = initMenus;
