var ron="#456789"; // Colore al MouseOver dello sfondo
var roff="#010101"; // Colore dello sfondo
var font_color="#ffffff"; // Colore del testo
var font_family="verdana,sans-serif"; // Font utilizzato
var font_size="10px"; // Dimensioni font
var padding_top="3px"; // Padding-top scritte
var padding_left="5px"; // Padding-left scritte
var border_color="#345678";

var leftmargin=2; // Distanza dal margine sinistro della pagina
var topmargin=100; // Distanza dal margine superiore della pagina
var largo=84; // Larghezza dei layers, quindi dei bottoni del menu
var alto=20; // Altezza dei layers, quindi distanza (verticale) fra le voci del menu

/* 
L'array seguente contiene i testi che verranno visualizzati dal menu.
Nell'esempio (il menu di JsDir) trovate quattro elementi dell'array "voci" corrispondenti alle quattro voci del menu principale
Il primo elemento degli array e' il nome del menu, gli elementi successivi sono i links contenuti nel singolo menu.
*/
var voci=new Array();
voci[0]=new Array("Home");
voci[1]=new Array("News");
voci[2]=new Array("Live","Concerti","Eventi","Report","Highlights");
voci[3]=new Array("Band","Biografia","Gabriele","Paolo","Luca","Marco","Manuel","Fulvio");
voci[4]=new Array("Photo Gallery","A-live","On the road","Real Iron","Guest star","Somewhere","Other bands","Friends");
voci[5]=new Array("Guest area","Guestbook","Sondaggio","Mailing list");
voci[6]=new Array("Download");
voci[7]=new Array("Links","Iron Maiden","Bands","Clubs","Friends");
voci[8]=new Array("Contact us");

/* 
Questo array contiene invece i links che saranno aperti dalle singole voci dei sottomenu.
Da notare che il primo elemento degli array dev'essere una stringa vuota, infatti corrisponde non ad un link
da aprire, ma al titolo del sottomenu, cioe' al primo elemento dell'array "voci".
*/

var links=new Array();
links[0]=new Array("home.htm");
links[1]=new Array("news.htm");
links[2]=new Array("#","concerti.htm","eventi.htm","report.htm","highlights.htm");
links[3]=new Array("#","bio.htm","pers-gab.htm","pers-paolo.htm","pers-luca.htm","pers-marco.htm","pers-manuel.htm","pers-fulvio.htm");
links[4]=new Array("#","pg_live.htm","pg_road.htm","pg_iron.htm","pg_star.htm","pg_world.htm","pg_bands.htm","pg_friends.htm");
links[5]=new Array("#","guestbook.asp","sondaggio.asp","mailing_list.asp");
links[6]=new Array("download.htm");
links[7]=new Array("#","links_maiden.htm","links_bands.htm","links_clubs.htm","links_friends.htm");
links[8]=new Array("contatti.htm");

/* 
Ultimo array.
Contiene i testi che saranno visualizzati nella barra di stato del browser quando il mouse e' sopra una voce del menu 
Anche in questo caso il primo elemento degli array contiene il testo relativo alla voce principale dei sottomenu 
*/

var wst=new Array();
wst[0]=new Array("Home Page");
wst[1]=new Array("News - Novità");
wst[2]=new Array("Scegli il sottomenù che ti interessa","Concerti - Live","Eventi - Event","Report","Highlights");
wst[3]=new Array("Scegli il sottomenù che ti interessa","Biografia - Biography","Gab - voce","Paolo - basso","Luca - chitarra","Marco - chitarra","Manuel - batteria","Fulvio - management");
wst[4]=new Array("Scegli il sottomenù che ti interessa","Gallery - live","Gallery - On the road","Gallery - Real Iron","Gallery - Guest Star","Gallery - Somewhere around the world","Gallery - Other bands","Gallery - Friends");
wst[5]=new Array("Scegli il sottomenù che ti interessa","Read & Sign our Guestbook","Vote our poll","Mailing list");
wst[6]=new Array("Download");
wst[7]=new Array("Scegli il sottomenù che ti interessa","Links_maiden.htm","links_bands.htm","links_clubs.htm","links_friends.htm");
wst[8]=new Array("Contact us");

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
* Fine sezione personalizzabile.
* Le righe che seguono costituiscono il menu vero e proprio.
* La personalizzazione e' consigliata solo a webmaster un po' esperti di JavaScript.
* Per la descrizione dello script si veda lo StaffScript "Menu a tendine" in JsDir.
* Questo menu differisce dall'altro "orizzontale" solo per i document.write che stampano i livelli, e per
* l'aggiunta di un rollon nelle voci principali quando il menu e aperto.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var nn=document.layers?true:false,conta=0,last=0;

if (nn)
{
  for (i=0;i<voci.length;i++)
  {
    var n=i;
    document.writeln("<LAYER NAME=mtop"+n+". position=absolute left="+leftmargin+
      " top="+eval(alto+topmargin+alto*i)+" width="+largo+" height="+alto+" clip=0,0,"+largo+
      ","+alto+" bgColor="+roff+" visibility=visible onMouseOver=MostraMenu("+i+
      ");mroll('mtop"+i+".');conta++ onMouseOut=last="+i+";unmroll('mtop"+i+
      ".');conta-->&nbsp;<A HREF=javascript:mroll('mtop"+i+".') CLASS=menuNNb>"+
      voci[i][0]+" </A></LAYER>");
    for (l=1;l<voci[i].length;l++)
      document.writeln("<LAYER NAME=mdep"+i+"."+l+" position=absolute left="+
      eval(leftmargin+largo)+" top="+eval(topmargin+alto*i+alto*l)+" width="+largo+
      " height="+alto+" clip=0,0,"+largo+","+alto+" bgColor="+roff+
      " visibility=hidden onMouseOver=mroll('mdep"+n+"."+l+
      "');conta++ onMouseOut=unmroll('mdep"+n+"."+l+
      "');conta-->&nbsp;<A HREF=javascript:mroll('mdep"+n+"."+l+
      "') onClick=vai('"+links[i][l]+"',"+i+","+l+") CLASS=menuNN>"+voci[i][l]+
      "</A></LAYER>");
  }
}
else
{
  for (i=0;i<voci.length;i++)
  {
    var n=i;
    document.writeln("<DIV ID=mtop"+n+". STYLE=\"position:absolute;left:"+eval(leftmargin+largo*i)+
      ";top:"+topmargin+";width:"+largo+"; height:"+alto+";visibility:visible;cursor:hand;color:"+font_color+";font-size:"+font_size+
      ";font-family:"+font_family+";padding-top:"+padding_top+";background-color:"+roff+";border: "+border_color+" 1px outset;text-align:center;\" onMouseOver=MostraMenu("+n+");mroll('mtop"+n+
      ".');conta++ onMouseOut=last="+n+";unmroll('mtop"+n+
      ".');conta-- CLASS=menuIE onClick=vai('"+links[i][0]+"',"+i+",0)>"+voci[i][0]+"</DIV>");
    for (l=1;l<voci[i].length;l++)
    {
      document.writeln("<DIV ID=mdep"+i+"."+l+" STYLE=\"position:absolute;left:"+
      eval(leftmargin+largo*i)+"; top:"+eval(topmargin+alto*l)+";width:"+largo+
      ";height:"+alto+";visibility:hidden; cursor:hand;color:"+font_color+
      ";font-size:"+font_size+";font-family:"+font_family+";padding-top:"+padding_top+
      ";border: "+border_color+" 1px outset;background-color:"+roff+";text-align:center;\" onMouseOver=;mroll('mdep"+n+"."+l+"');conta++ onMouseOut=unmroll('mdep"+n+
      "."+l+"');conta-- CLASS=menuIE onClick=vai('"+links[i][l]+"',"+i+","+l+
      ")>"+voci[i][l]+"</DIV>");
    }
  }
}

timer=setInterval("NascondiMenu()",1000)

function NascondiMenu()
{
  if (conta==0)
  {
    coloratutti(true)
    timer=setTimeout("coloratutti(false)",200);
    timer=setTimeout("showdeps(last,false)",250);
  }
}

function coloratutti(col)
{
  colore=col?ron:roff;
  for (i=0;i<voci.length;i++)
  for (j=1;j<voci[i].length;j++)
  {
    if (nn)
      document.layers["mdep"+i+"."+j].bgColor=colore;
    else
      if(document.all)
        document.all["mdep"+i+"."+j].style.background=colore;
    else
      document.getElementById('mdep'+i+"."+j).style.background=colore;
    }
}

function MostraMenu(n)
{
  showdeps(last,false);
  showdeps(n,true);
  last=n;
}

function showdeps(n,act)
{
  if (conta==0)
  {
    act?stat="visible":stat="hidden";
    if (nn)
      for (i=1;i<voci[n].length;i++)
        document.layers["mdep"+n+"."+i].visibility=stat;
    else
      for (i=1;i<voci[n].length;i++)
        if(document.all)
          document.all["mdep"+n+"."+i].style.visibility=stat;
        else
          document.getElementById('mdep'+n+"."+i).style.visibility=stat;
  }
}

function vai(dove,r,c)
{
  if(dove=="")
  {
    return;
  }
  if (c==0)
  {
    lev=nn ? document.layers["mtop"+r+"."] : (document.all) ? document.all["mtop"+r+"."].style : document.getElementById("mtop"+r+".").style;
  }
  else
  {
    lev=nn ? document.layers["mdep"+r+"."+c] : (document.all) ? document.all["mdep"+r+"."+c].style : document.getElementById("mdep"+r+"."+c).style;
  }
  if (nn)
  {
    lev.bgColor=roff;
    timer=setTimeout("lev.bgColor=ron",50)
    timer=setTimeout("lev.bgColor=roff",100)
    timer=setTimeout("lev.bgColor=ron",150)
    timer=setTimeout("lev.bgColor=roff",200)
    timer=setTimeout("lev.bgColor=ron",250)
  }
  else
  {
    lev.background=roff;
    timer=setTimeout("lev.background=ron",50)
    timer=setTimeout("lev.background=roff",100)
    timer=setTimeout("lev.background=ron",150)
    timer=setTimeout("lev.background=roff",200)
    timer=setTimeout("lev.background=ron",250)
  }
  if (r == 5 && c == 3) {
    timer=setTimeout("window.open(links[5][3])",350)
  } else {
    timer=setTimeout("self.location.href='"+dove+"'",350)
  }
}

function mroll(l)
{
  toplayer="mtop"+l.substring(4,l.indexOf(".")+1);
  nn ? document.layers[l].bgColor=ron : (document.all) ? document.all[l].style.background=ron : document.getElementById(l).style.background=ron;
  nn ? document.layers[toplayer].bgColor=ron : (document.all) ? document.all[toplayer].style.background=ron : document.getElementById(toplayer).style.background=ron;
  document.getElementById ? document.getElementById(l).style.cursor=document.all?'hand' : 'pointer':'void(0)';
  if (l.substr(0,4)=="mdep")
    stringa=wst[l.substr(4,l.indexOf(".")-4)][l.substring(l.indexOf(".")+1,l.length)];
  else if (l.length>5)
    stringa=wst[l.substr(4,l.indexOf(".")-4)][0];
  else stringa="Home Page"; 
    window.status=stringa;
  timer=setTimeout("window.status=stringa",20);
}

function unmroll(l)
{
  toplayer="mtop"+l.substring(4,l.indexOf(".")+1);
  nn ? document.layers[l].bgColor=roff:(document.all) ? document.all[l].style.background=roff : document.getElementById(l).style.background=roff;
  nn ? document.layers[toplayer].bgColor=roff:(document.all) ? document.all[toplayer].style.background=roff : document.getElementById(toplayer).style.background=roff;
  nn ? document.layers[l].bgColor=roff:(document.all) ? document.all[l].style.background=roff : document.getElementById(l).style.background=roff;
  nn ? document.layers[toplayer].bgColor=roff:(document.all) ? document.all[toplayer].style.background=roff : document.getElementById(toplayer).style.background=roff;
  window.status="";
}
