function mostraMenu(menuId) {
 	menuId.style.visibility = "visible";
	var bona = menuId.parentNode;
	bona.style.zIndex=4;

}

function nascondiMenu(menuId) {
  menuId.style.visibility = "hidden";

	var bona = menuId.parentNode;
	bona.style.zIndex=-1;

}

function sottomenu() {
  if (!document.getElementById) return false;
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById("sottoMenu")) return false;
	
	// recupera lo spazio sottomenu e lo nasconde
	var sm = document.getElementById("sottoMenu");
	sm.style.visibility= "hidden";
	// recupera le singole voci nello spazio sottomenu
	var voci = sm.getElementsByTagName("div");
	// cicla su tutte le voci 
	
	var appo=0;
 var oki = 0;
		 for (i=0;i<voci.length;i++) {
  // verifico che siano effettivamente voci di menu
	  if ((voci[i].getAttribute("class") == "allinea8")|| (voci[i].className == "allinea8") || (voci[i].getAttribute("class") == "NOallinea")|| (voci[i].className == "NOallinea")){
		     voci[i].id = "v"+appo;
				 voci[i].style.position= "absolute";
				  voci[i].style.visibility ="hidden";
				  if ((voci[i].getAttribute("class") == "allinea8")|| (voci[i].className == "allinea8")) {voci[i].style.left=75*oki+11;  oki++; };
		     appo++;
				voci[i].onmouseover = function() {
				 mostraMenu(this);
				 };
				 voci[i].onmouseout = function() {
				 nascondiMenu(this);
				 };
				 //recupera le sottovoci 
	       var sottovoci = voci[i].getElementsByTagName("div");
				 	   
				 // cicla su tutte le sottovoci 
		     for (j=0;j<sottovoci.length;j++) {
	           // verifico che siano effettivamente sottovoci di menu
				 		 if ((sottovoci[j].getAttribute("class") == "sottovoce")|| (sottovoci[j].className == "sottovoce")){
								 
						    // modifico la grafica (poi classe) al passaggio del mouse
			       		sottovoci[j].onMouseOver = function() { 
						 		    this.setAttribute("class","sottovoceON");
										this.className = "sottovoceON";
						 		    this.firstChild.setAttribute("class","sottovoceON");
										this.firstChild.className = "sottovoceON";
										};										
						 		 sottovoci[j].onMouseOut = function() { 
						 		    this.setAttribute("class", "sottovoce");
										this.className =  "sottovoce";
										this.firstChild.setAttribute("class","sottovoce");
										this.firstChild.className = "sottovoce";
										};
						 		 sottovoci[j].onclick = function() { 
						 		   location.href = this.firstChild.href;
										};

	     			} // end if sottovoce
			   } // end for j
			} // end if allinea8
	} //end for i
	
	// recupera la barra dei menu
	var barra = document.getElementById("altoSx");
	
  var links = barra.getElementsByTagName("div");
	// cicla su tutte le voci 
	   for (k=0;k<links.length;k++) {
    // verifico che siano effettivamente voci di menu
		if ((links[k].getAttribute("class") == "allinea8")|| (links[k].className == "allinea8")){
		    links[k].id = k; 
				    links[k].onmouseover = function() {
				 	  var target = document.getElementById("v"+this.id);
						target.style.visibility = "visible";
						//target.style.zIndex = -1;
						//window.alert(target.parentNode.id);
						var bono = target.parentNode;
						bono.style.zIndex=4;
						bono.style.visibility ="visible";
						};
				   links[k].onmouseout = function() {
				 		var target = document.getElementById("v"+this.id);
						target.style.visibility = "hidden";
					var bono = target.parentNode;
					bono.style.zIndex=-1;

				 		};
				   /*links[k].onclick = function()  { var target = document.getElementById("v"+this.id);
						window.alert(target.firstChild.hasChildNodes+"QQ"); return false;};
						*/
						// se per la voce compare il sottomenu disabilito la voce nella barra
						
				 } // end if allinea8
	  } //end for k
		
} //end function


