//---------------------------------
//--fabiano@jsdir.com-------
//--http://www.jsdir.com--------
//--copyright © 2001-------

//-------browser sniff--------------
var nome=(navigator.appName=="Microsoft Internet Explorer")?true:false;
var wt=nome?(navigator.appVersion.split(';').toString().split(" ").toString().split(',')[4] ):null;
var isie5=((wt)>=5 && nome)?true:false;
var isie4=((wt <5 && wt >=4) && nome)?true:false;
var isNS4=(document.layers)?true:false;
var isNS6=document.getElementById && (navigator.appName=="Netscape")?true:false;
mm=(isNS4)?'show':'visible';
nn=(isNS4)?'hide':'hidden';


//-------------------Stabilisce livelli da nascondere---------------------------
function n_all(){
 VisualizzaSfondo();
 snt=(isie4)?document.all['titolo'].style:(isNS4)?document.layers['princ'].layers['titolo']:document.getElementById('titolo').style; 
 snt.visibility=nn
 if(isie4 || isie5 || isNS6){
  snh=(isie4)?document.all['start'].style:document.getElementById('start').style;
  snh.border="outset";  
 }
 for(r=0; r<pr.length; r++){
   iddd=""+"a"+r
   snf=(isie4)?document.all[iddd].style:(isNS4)?document.layers['princ'].layers[iddd]:document.getElementById(iddd).style;
   snf.visibility=nn;
 }
 if(isNS6)self.location.reload();
}
//------------
ae=new Array();
ae_n=0;
for(d=0; d<pr.length; d++){
 if(d>0 && pr[d][3]=='0'){
  ae_n=ae_n+1;
 }
 ae[d]=""+"z"+ae_n
 pr[d][6]=ae[d];
}

aj="";
aw=new Array();
for(d=0; d<pr.length; d++){
 if(pr[d][3]==0){
  aj+=""+d+",";
 }
 aw[d]='';
 if(pr[d][2]=="c"){
  for(y=0; y<pr.length; y++){
   if(y<d && pr[y][6]==pr[d][6] && pr[y][3]<=pr[d][3]){
    
    aw[d]=''+aw[d]+y+',';
   }
   else if(y>=d && pr[y][6]==pr[d][6]){
     
     aw[d]=''+aw[d]+y+',';
   }
   if(y>d && pr[y][3]<=pr[d][3]){
     break;
   }
  }
  for(s=y; s<pr.length; s++){
   if(pr[s][6]==pr[d][6] && pr[s][3]<=pr[d][3]){
       
       aw[d]=''+aw[d]+s+',';
   }
  }  
 }
 pr[d][7]=aw[d].substring(0,aw[d].length-1)
}
pr_t=aj.substring(0,aj.length-1)
rty=pr_t.split(',').length;



//-------------------Stabilisce livelli da mostrare-----
az=new Array();
for(df=0; df<pr.length; df++){
 az[df]='';
 if(pr[df][2]=="c"){
  for(yf=0; yf<pr.length; yf++){
    if((yf>df && pr[yf][6]==pr[df][6]) && pr[yf][3]==(eval(pr[df][3])+eval(pr_left))){
     az[df]=''+az[df]+yf+',';
    }
    if(yf>df && pr[yf][3]<=pr[df][3]){
       break;
    }
   }
   pr[df][4]=az[df].substring(0,az[df].length-1)
  }
}



//------------------------------------------------------------------
//----------------calcola top livelli------------------------------

ak=new Array();
for(df=0; df<pr.length; df++){
 //-----------------------------
 if(df==0){
 		ak[0]=25; // --- =======================================
	//ak[0]=pr_height;
 }
 if(df>0 && pr[df][3]>pr[df-1][3]){
  ak[df]=ak[df-1];
 }
 else if(df>0 && pr[df][3]==pr[df-1][3]){
    //ak[df]=ak[df-1]+20;
		ak[df]=ak[df-1]+eval(pr_height)+1;
 }
 else if(df>0 && pr[df][3]<pr[df-1][3]){
  for(po=df-1; po>=0; po--){
    if(pr[df][3]==pr[po][3]){
     //ak[df]=ak[po]+20;
		 ak[df]=ak[po]+eval(pr_height)+1;
     break;
    }
  }
 }
 pr[df][8]=ak[df]
}

//-------------------------------------------------------------------

 document.write('<div id="princ" style="position:absolute;left:0;"></div>') //Posizione Tasto di avvio
 document.close()

//----------------scrivi menu----------------------
but="";
lev="";





function wrt(){
  hh=-40;//(isNS4)?(window.innerHeight-10):(isNS6)?(window.innerHeight):100;//document.body.clientHeight-25;
  ww=(isNS4 || isNS6)?window.innerWidth:document.body.clientWidth;
  but='<div id="start" style="position:absolute;border:outset;height:20;width:'+ (10*text_but.length) +';background:silver;top:'+(hh+25)+';left:0;"><a href="javascript:apri(\''+pr_t+'\',\'start\',\'M\',\''+pr_t+'\',0)"   style="text-decoration:none;"><img src=\"'+imm6.src+'\" height="20" width="20" border="0"><b><font color=\"'+fc+'\" size=\"'+fs+'\" face=\"'+ff+'\">'+text_but+'</font></b></a></div><div id="titolo"><\div>'
//-----------
   for(i=0; i<pr.length; i++){
     id_pra=""+"a"+i;
     img_name=""+"v"+i;
     id_span=""+"s"+i;
		 switch (pr[i][2]) {
  case "c" : // Sotto Menu;
 		        lev+='<div id=\"'+id_pra+'\" style="position:absolute;background:#000080;visibility:'+nn+'; top:'+((hh+25)+pr[i][8])+';left:'+pr[i][3]+';height:20;width:'+pr_left+';"><table cellpadding="0" cellspacing="0" width=\"'+pr_left+'\" height=\"'+pr_height+'\"><tr><td align="left" valign="middle" ><a href="javascript:void(0)" onMouseOver="NascondiSfondo();apri(\''+pr[i][4]+'\',\''+id_pra+'\',\'M\',\''+pr[i][7]+'\','+i+');color_div(\''+id_pra+'\',\'White\',\''+id_span+'\',\'Navy\')"  style="text-decoration:none;" onMouseOut="color_div(\''+id_pra+'\',\'Navy\',\''+id_span+'\',\'White\')">&nbsp;<span id=\"'+id_span+'\" style=\"position:relative;color:'+fc_liv+';font-Size:'+fs_liv+';font-Family:'+ff_liv+'\"><b>'+pr[i][1]+'</b></span></a></td></tr></table></div>';
            break;
  case "l" : // Chiama Pagina;
 		        lev+='<div id=\"'+id_pra+'\" style="position:absolute;background:#000080;visibility:'+nn+'; top:'+((hh+25)+pr[i][8])+';left:'+pr[i][3]+'; height:20; width:'+pr_left+';"><table cellpadding="0" cellspacing="0" width=\"'+pr_left+'\" height=\"'+pr_height+'\"><tr><td align="left" valign="middle" ><a href="javascript:dove(\''+pr[i][4]+'\')" style="text-decoration:none;" onMouseOver="NascondiSfondo();Nascondi('+pr[i][3]+');color_div(\''+id_pra+'\',\'White\',\''+id_span+'\',\'Navy\')" onMouseOut="color_div(\''+id_pra+'\',\'#000080\',\''+id_span+'\',\'White\')">&nbsp;<span id=\"'+id_span+'\" style=\"position:relative;color:'+fc_liv+';font-Size:'+fs_liv+';font-Family:'+ff_liv+'\"><b>'+pr[i][1]+'</b></span></a></td></tr></table></div>';       
            break;
  case "p" : // Chiama Pagina con Parametro GET;
	          lev+='<div id=\"'+id_pra+'\" style="position:absolute;background:#000080;visibility:'+nn+'; top:'+((hh+25)+pr[i][8])+';left:'+pr[i][3]+'; height:20; width:'+pr_left+';"><table cellpadding="0" cellspacing="0" width=\"'+pr_left+'\" height=\"'+pr_height+'\"><tr><td align="left" valign="middle" ><a href="javascript:dove(\''+pr[i][4]+'&'+pr[i][5]+'\')" style="text-decoration:none;" onMouseOver="NascondiSfondo();Nascondi('+pr[i][3]+');color_div(\''+id_pra+'\',\'White\',\''+id_span+'\',\'Navy\')" onMouseOut="color_div(\''+id_pra+'\',\'#000080\',\''+id_span+'\',\'White\')">&nbsp;<span id=\"'+id_span+'\" style=\"position:relative;color:'+fc_liv+';font-Size:'+fs_liv+';font-Family:'+ff_liv+'\"><b>'+pr[i][1]+'</b></span></a></td></tr></table></div>';
}

   }

  //-----------
  if(isie4 || isie5 || isNS6){
     snu=(isie4)?document.all['princ']:document.getElementById('princ');
		 snu.innerHTML=but+lev
  }
  else{
   document.layers['princ'].document.write(but+lev);
   document.layers['princ'].document.close();
   for(tt=0; tt<pr.length; tt++){
     id_pra=""+"a"+tt;
     document.layers['princ'].layers[id_pra].bgColor="White";
   }
  }
setInterval("riposiziona()",50)
}
onload=wrt

function riposiziona()
	{
	isNS4?document.layers.princ.top=window.pageYOffset+5:isNS6?document.getElementById("princ").style.top=window.scrollY+15:document.all.princ.style.top=document.body.scrollTop+15
	}

//---------------------
fj=pr_t.split(',')
fd=0;

function apri(dd,ii,ss,yk,tg){

 snt=(isie4)?document.all['titolo'].style:(isNS4)?document.layers['princ'].layers['titolo']:document.getElementById('titolo').style; 
 snt.visibility=mm;
 if(isNS4){
  snt.clip.width=20
  snt.clip.height=rty*20
 }
 if(isie4 || isie5 || isNS6){
  snh=(isie4)?document.all['start'].style:document.getElementById('start').style;
  snh.border="inset";  
 }
 qq=dd.split(',')
 
 if(ss=="M"){
   
   for(j=0; j<qq.length; j++){
     iddd=""+"a"+qq[j]
     snf=(isie4)?document.all[iddd].style:(isNS4)?document.layers['princ'].layers[iddd]:document.getElementById(iddd).style;
     snf.visibility=mm;
   }
 }
 //----------------------
 fj=yk.split(',')
 //----------------------
  for(j=0; j<pr.length; j++){
     iddd=""+"a"+j
     snf=(isie4)?document.all[iddd].style:(isNS4)?document.layers['princ'].layers[iddd]:document.getElementById(iddd).style;
       ma=0;
       for(sz=0; sz<fj.length; sz++){
         if(fj[sz]==j){
           ma=1;
         }
       }
       
       if(pr[j][3]>0 && ma==0){
         snf.visibility=nn;
       }
     
   }
 
 
}
//-----------
function color_div(id,colore,spn,tst){
  sncol=(isie4)?document.all[id].style:(isNS4)?document.layers['princ'].layers[id]:document.getElementById(id).style;
  sncolt=(isie4)?document.all[spn].style:(isNS4)?document.layers['princ'].layers[id].layers[spn]:document.getElementById(spn).style;
  if(isie4 || isie5 || isNS6){
    sncol.background=colore
    sncolt.color=tst
  }
  else{
   if(tst=="black")tst="#e0e0e0";
   if(tst=="white")tst="#e0e0e0";
   sncol.bgColor=colore
   sncolt.bgColor=tst
  }
}



function Nascondi(Posizione)
{
 snt=(isie4)?document.all['titolo'].style:(isNS4)?document.layers['princ'].layers['titolo']:document.getElementById('titolo').style; 
 snt.visibility=mm;
 if(isNS4){
  snt.clip.width=20
  snt.clip.height=rty*20
 }
 if(isie4 || isie5 || isNS6){
  snh=(isie4)?document.all['start'].style:document.getElementById('start').style;
  snh.border="inset";  
 }

  for(j=0; j<pr.length; j++){
     iddd=""+"a"+j
     snf=(isie4)?document.all[iddd].style:(isNS4)?document.layers['princ'].layers[iddd]:document.getElementById(iddd).style;
		 if (pr[j][3]>Posizione){
		     snf.visibility=nn;
		 }     
   }
}


function NascondiSfondo ()
{
     snf=document.getElementById('sotto').style;
		 snf.visibility=nn;

}

function VisualizzaSfondo ()
{
     snf=document.getElementById('sotto').style;
		 snf.visibility=mm;

}

//------------------target-------
function dove(url){
 self.location=url;
}
//---------------------------------------

function open_new_window(url,window_name)
{ 
		new_window = window.open(url,window_name,'scrollbars,toolbar=0,menubar=0,resizable=1,dependent=1,status=1,width=800,height=350,left=25,top=5');
		new_window.close();
		new_window = window.open(url,window_name,'scrollbars,toolbar=0,menubar=0,resizable=1,dependent=1,status=1,width=800,height=350,left=25,top=5');
}
// New window attributes
// url - the variable for the url of the page in the new window
//     that is passed by placing it single-quoted in either the link or form
// window_name - the name of the new window being opened
// width - width of the new window in pixels
// height - height of the new window in pixels
// top - the new widow top will appear xx number of pixels from the top of the screen
// left - the new widow left margin will appear xx number of pixels from the left of the screen

// The following attributes will suppress the respective window elements
// when the value is set to zero or if omitted.  When listed or equal to one
// the window attribute will appear
// toolbar,menubar,resizable,dependent,status
// -->


