// Menu

function ShowField(show){
	for (var i = 0; i < document.getElementsByTagName("SELECT").length; i++)
	{
		document.getElementsByTagName("SELECT")[i].style.visibility = (show?"visible":"hidden");
	}

	/*if(show){
		if(document.getElementById("_divProduto") == "[object]")
			document.getElementById("_divProduto").style.display = "";
		
		if(document.getElementById("_divModelo") == "[object]")	
			document.getElementById("_divModelo").style.display = "";
		
		if(document.getElementById("_divFaixaDePreco") == "[object]")
			document.getElementById("_divFaixaDePreco").style.display = "";
		
	}else{
		if(document.getElementById("_divProduto") == "[object]")
			document.getElementById("_divProduto").style.display = "none";
		
		if(document.getElementById("_divModelo") == "[object]")	
			document.getElementById("_divModelo").style.display = "none";
		
		if(document.getElementById("_divFaixaDePreco") == "[object]")
			document.getElementById("_divFaixaDePreco").style.display = "none";			
	}*/
}

activateMenu = function(nav) {
    /* currentStyle restricts the Javascript to IE only */
	if (document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                   ShowField(false);
                }
                
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                   ShowField(true);
                }
            }
        }
    }
}

activateMenuMarca = function(nav, id) {
	if(document.getElementById(nav) != "[object]") return;
    /* currentStyle restricts the Javascript to IE only */
	if (document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
				if(lis[i].lastChild.id != id)
					lis[i].lastChild.style.display = "none";

				lis[i].onclick=function() {                       
					if(this.lastChild.style.display == "none"){
						this.lastChild.style.display = "";
					}else{
						this.lastChild.style.display = "none";
					}
				}				
            }
        }
    }
}

window.onload = function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
    activateMenu('subProdutos');
    activateMenu('subEmpresa');
	activateMenu('subMarcas');
    activateMenu('vertnav');
}

function loadMenu(UserControl){
	var formulario = document.forms[0];
	var cda_categoria = formulario[UserControl + "_hdnCeaCategoria"]
	var menuDiv = UserControl + "_vertsubnav";
	
	activateMenuMarca(menuDiv, parseInt(cda_categoria.value));
}