var menuids=["tree"]

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i])
			ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px"
		else
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px"
			// Center the submenu within the parent menu no matter what the parent height -- uncomment to implement
			// ultags[t].style.top=-((ultags[t].offsetHeight/2)-ultags[t].parentNode.offsetHeight)+"px"
			
			// Any child with the id of "up" will have the menu display upwards from the parent, to avoid scrolling for menu items
			if(ultags[t].id=="up") { ultags[t].style.top=-(ultags[t].offsetHeight-ultags[t].parentNode.offsetHeight)+"px" }
			
	    ultags[t].parentNode.onmouseover=function() { this.getElementsByTagName("ul")[0].style.display="block" }
			ultags[t].parentNode.onmouseout=function() { this.getElementsByTagName("ul")[0].style.display="none" }
    }
		for (var t=ultags.length-1; t>-1; t--){
		ultags[t].style.visibility="visible"
		ultags[t].style.display="none"
		}
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)