<!--
// true = piu' menu' espansi contemporaneamente
// false = solo un menu espanso alla volta
var stayFolded = false;

// Variabili per le immagini cartella chiusa/cartella aperta
var exImg = new Image(); 
exImg.src = 'img/aperta.gif'
var unImg = new Image(); 
unImg.src = 'img/chiusa.gif'

// Variabili per le immagini delle icone dei link
var ImgLinkN = new Image(); 
ImgLinkN.src = 'img/link-n.gif';
var ImgLinkOp = new Image(); 
ImgLinkOp.src = 'img/link-op.gif';
var ImgLinkMoz = new Image(); 
ImgLinkMoz.src = 'img/link-moz.gif';

// Funzione per la creazione di oggetti da inserire negli Array, riceve obj=nomeoggetto e nest=nome dell'oggetto padre
function makeMenu(obj, nest, imm){
   if (is_nav4) nest = 'document.layers.' + nest + '.';
   if (is_nav4) this.css = eval(nest+'document.layers.'+obj);
   if (is_ie4) this.css = eval('document.all.'+obj+'.style');
	if (is_mozilla || is_nav6up || is_ie5up || is_opera5up) this.css = document.getElementById(obj).style;
   if (is_nav4) this.ref = eval(nest+'document.'+obj+'.document');
   if (is_mozilla || is_nav6up || is_ie4 || is_ie5up || is_opera5up) this.ref = eval('document');
   if (is_nav4) this.height = this.ref.height; 
   if (is_ie4) this.height = this.ref.offsetHeight;
   if (is_mozilla || is_nav6up || is_ie5up) this.height = this.ref.getElementById(obj).offsetHeight;
   if (is_opera5up) this.height = this.css.pixelHeight;
   if (is_nav4 || is_nav6up || is_mozilla) {this.x = this.css.left; this.y = this.css.top;}
   if (is_ie4 || is_ie5up || is_opera5up) {this.x = this.css.pixelLeft; this.y = this.css.pixelTop;}
   this.hideIt = b_hideIt;
   this.showIt = b_showIt;
   this.vis = b_vis; 
   this.moveIt = b_moveIt;
   this.immagini = imm;
   return this;
}

function b_showIt()
{ 
   this.css.visibility = "visible"; 
}

function b_hideIt()
{ 
   (is_nav4) ? this.css.visibility = "hide" : this.css.visibility = "hidden"; 
}

function b_vis()
{  
   if (this.css.visibility.toLowerCase() == "hidden" || this.css.visibility.toLowerCase() == "hide") 
	   return true;
	else return false;
}

function b_moveIt(x,y)
{ 
   this.x = x; 
   this.y = y; 
   this.css.left = this.x; 
   this.css.top = this.y; 
}

// di primo livello 
var oTop = new Array();
// di secondo livello
var oSub = new Array();
// Funzione per inizializzare le variabili
function initMenuGerarchico(){
   // Creazione dell'array menu 

   // Creo un nuovo elemento del Menù passandogli: nome dell'oggetto, oggetto padre, numero di link interni al SubMenu (a livello oTop passo 0)
   oTop[0] = new makeMenu('divTop1', 'divCont', 0);
   oTop[1] = new makeMenu('divTop2', 'divCont', 0);
   oTop[2] = new makeMenu('divTop3', 'divCont', 0);
   oTop[3] = new makeMenu('divTop4', 'divCont', 0);
   oTop[4] = new makeMenu('divTop5', 'divCont', 0);

   // Creo un nuovo elemento del Menù passandogli: nome dell'oggetto, oggetto padre, numero di link interni al SubMenu
   oSub[0] = new makeMenu('divSub1', 'divCont.document.divTop1', 11);
   oSub[1] = new makeMenu('divSub2', 'divCont.document.divTop2', 11);
   oSub[2] = new makeMenu('divSub3', 'divCont.document.divTop3', 3);
   oSub[3] = new makeMenu('divSub4', 'divCont.document.divTop4', 2);  
   oSub[4] = new makeMenu('divSub5', 'divCont.document.divTop5', 1);  

   // Se l'utente sta utilizzando Netscape cambio l'icona dei link che di default e' settata per Internet Explorer
   if (!is_ie)
	{ 
	   for (var i = 0; i < oSub.length; i++) 
		{
		   for (var num=0; num != oSub[i].immagini; num++) 
			{
			   if (is_nav4) oSub[i].ref['I' + i + num].src = ImgLinkN.src;
				if (is_nav6up) document.getElementById('I' + i + num).src = ImgLinkN.src;
				if (is_mozilla) document.getElementById('I' + i + num).src = ImgLinkMoz.src;
				if (is_opera) document.getElementById('I' + i + num).src = ImgLinkOp.src;
			}
		}
	}

   // Nascondo i menu di secondo livello
   for( i = 0; i < oSub.length; i++) {
//      alert(oSub[i].height + "\n" + oSub[i].x + "\n" + oSub[i].y + "\n");
      oSub[i].hideIt(); 
   }

   // Posiziono correttamente i menu di primo livello
   if (is_opera5up) oTop[0].moveIt(0,0);	// Correggo un errore nel posizionamento in Opera
   for( i = 1; i < oTop.length; i++) {
//      alert(oTop[i-1].height + "\n" + oTop[i-1].x + "\n" + oTop[i-1].y + "\n");
      oTop[i].moveIt(0 , parseInt(oTop[i-1].y + oTop[i-1].height)); 
   }
	if (is_nav4) 
	{
	   document.layers['divCont'].left -= 300;
	   document.layers['divCont'].top -= 50;
	   document.layers['fondo'].top = parseInt(oTop[i-1].y + 400);
	   document.height = 1000;
	}
}

function menu(num){
   var i=0;
   if(!stayFolded)
	{
      for( i=0; i < oSub.length; i++) 
	   {
         if(i != num)
			{
            oSub[i].hideIt();
            oTop[i].ref["imgA"+i].src=unImg.src;
         }
      }
      for( i=1; i<oTop.length; i++) 
		   oTop[i].moveIt(0, parseInt(oTop[i-1].y+oTop[i-1].height));
   }
   if(oSub[num].vis()) 
	{ 	// Se il menù secondario non e' gia' visibile
      oSub[num].showIt();
      oTop[num].ref["imgA"+num].src = exImg.src;
   }
   else
	{ 			// Se il menù secondario e' gia' visibile
      oSub[num].hideIt();
      oTop[num].ref["imgA"+num].src = unImg.src;
   }
   for( i=1; i<oTop.length; i++)
	{	// Sposto i vari altri menù
      if(!oSub[i-1].vis()) 
		{
         var valore = parseInt(oTop[i-1].y + oTop[i-1].height) + oSub[i-1].height;
         oTop[i].moveIt( 0, valore);
      }
      else oTop[i].moveIt( 0, eval(oTop[i-1].y + oTop[i-1].height));
   }
}
// -->
