/*
	Expandable Listmenu Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
If you want a menu to appear already expanded on document load then you will need to change the class="treenode" attribute to class="treenodeopen".
*/


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.nextSibling;
											
						while (1) {


							if (node != null) {
								if (node.tagName == "UL") {
									var d = (node.style.display == "none")
									node.style.display = (d) ? "block" : "none";
									this.className = (d) ? "treeopen" : "treeclosed";
									return false;



								}
								node = node.nextSibling;
							} else {
								return false;
							}
						}
						return false;
					}
					
					submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
				}
				
				if (submenu[j].tagName == "UL")

					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}

window.onload = initMenus;


/*
	<!--  ****************  EJEMPLO A TRES NIVELES DE SUBMENUS 
				<li class="treenode">
					<a href="">Software</a>
					<ul>
						<li class="treenodeopen">
						<a href="http://play.game.net/apps/default.asp">Home</a>
						<ul>
							<li>Sample</li>
							<li>Wobble</li>
						</ul>					
						</li>
						<li><a href="http://play.game.net/apps/gamebar/default.asp">GAMEbar</a></li>
						<li><a href="http://play.game.net/apps/gamelogon/default.asp">GAMElogon</a></li>
					</ul>
				</li>
	
	<!--  FIN DE   EJEMPLO A TRES NIVELES DE SUBMENUS  ********************************-->



**********  PARA QUE SE MUESTRE ABIERTO **********
 			<li class="treenodeopen">  
			en luguar de:
			<li class="treenode">



*/