
asynx.event.onLoad(function() {
	initMenu();
});

var xmenu = "//div[@id='menuContainerVertical']";
var xUlsFilhos = [xmenu, "//ul//ul"].join("");
var xtemFilhos = [xmenu, "//li//a[@isPai='true']"].join("");
var intMenu = 0, intMenuFilhos = 0, lastMenu = "", zIndexMenu=999;

var initMenu = function () {
	asynx(xtemFilhos).mouseover(function(e,a){
		var li = e.target.parentNode;
		asynx('//ul', li).css({display:'block', zIndex:zIndexMenu++});
		asynx('//ul', li).mouseover(function(e,a){
			clearInterval(intMenu);
		});
		asynx('//ul', li).mouseout(function(e){
			//mouseOutMenu(e);
		});
	});
	
	asynx(xtemFilhos).mouseout(mouseOutMenu);
	
	asynx('//body').click(function() {
		hideAllMenus();
	});
}

var mouseOutMenu = function(e,a){	
	if (e) {
		intMenu = asynx.executeOn(function() {
			lastMenu = asynx('//ul', e.target.parentNode);
			lastMenu.css({display:'none'});
		}, 1000);
	}
}

var hideAllMenus = function() {
	asynx(xUlsFilhos).each(function(ul) {
		asynx(ul).css({display:'none'});
	});
	clearInterval(intMenu);
}



/*
startList = function() {
var lis = document.getElementsByTagName("UL")
for (i in lis) {
	if (lis[i].style)
	lis[i].style.zIndex = "999";
	//childs[i].innerHTML = 'ddddddwwwwwwwwwwwwwwwd';
	//document.write( childs[i]+'<br>');
}


if (document.getElementById) {
	navRoot = document.getElementById("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
	
		if (node.nodeName=="LI") {
			
			node.onmouseover=function() {
				var obj = { ref: this };
				this.className+=" over";
				this.style.zIndex = 9999;
	
			
				var ul = obj.ref.getElementsByTagName('ul')[0];
				if (obj.ref.tagName == "LI") ul.style.display = 'block';
			}
		
			node.onmouseout=function() {
				var obj = { ref: this };
				var time = setInterval( function() { 
										 
					var t = setInterval(function(){
						var ul = obj.ref.getElementsByTagName('ul')[0];
						if (obj.ref.tagName == "LI") ul.style.display = 'none';	
						clearInterval(t);
					}, 500);
				
					obj.ref.className=obj.ref.className.replace(" over", "");
					clearInterval(time);
			}, 500 );
			
		}
	
   }
  }
 }
}
window.onload=startList;

*/
