/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * Sezione personalizzabile..
 * Modificare le variabili e gli array seguenti per adattare il menu al propri sito.
 * L'ultima voce di questo menu e' un link a JsDir, se credete potete toglierlo, 
 * ma in tal caso vi preghiamo di lasciare il riferimento della riga seguente... 
 * dopotutto non l'avete pagato nulla, quindi... che vi costa? :-)
 *
 * Ultimo aggiornamento: 09 - Dicembre - 2002
 *
 * Riveduto, integrato e corretto da br1@html.it 
 *
 * Questo menu e' (C)2001 ri.riccardi@agora.stm.it - 
 * Lo script originale e' reperibile al sito http://www.jsdir.com - JavaScript Directory
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var primo=true // per debug
var ron="#AA3333";	// Colore al MouseOver
var roff="#EEEEEE"; // Colore di default
var ton="#FFFFFF"; // Colore testo al MouseOver
var toff="#AA3333"; // Colore testo di default

var largo=148; // Larghezza dei layers, quindi distanza (orizzontale) fra i sottomenu
var posizione="left"; // allineamento del menu rispetto al contenitore
var leftmargin=0; // Distanza dal margine sinistro (o destro) della pagina 
var topmargin=0; // Distanza dal margine superiore della pagina

// definiti i colori, scrivo lo style
document.writeln('<STYLE type="text/css">');
document.writeln('.menuIE  {border:1px solid gray;border-top:0px;'+
	'font-family: Helvetica, Verdana, Arial, Helvetica, sans-serif;font-weight:bold;'+
	'text-decoration:none;position:absolute;height:15;visibility:hidden;cursor:hand;'+
	'font-size:10px;width:'+largo+';background:'+roff+';color:'+toff+';}');
document.writeln('.menuIEb {border:1px solid gray;text-align:center;'+
	'font-family: Helvetica, Verdana, Arial, Helvetica, sans-serif;font-weight:bold;'+
	'text-decoration:none;position:absolute;height:15;visibility:visible;cursor:hand;'+
	'font-size:11px;font-style:italic;width:'+largo+';background:'+roff+';color:'+toff+';}');
document.writeln('.menuNN  {font-family: Verdana, Arial, Helvetica, sans-serif;'+
	'font-size:11px;font-weight:bold;text-decoration:none;color:'+toff+';}');
document.writeln('.menuNNb {font-family: Verdana, Arial, Helvetica, sans-serif;'+
	'font-size:12px;font-weight:bold;font-style:italic;text-decoration:none;color:'+toff+';}');
document.writeln('</STYLE>');

var Home = false; // Settare a "false" se non si desidera il link all'homepage
var HomeLink = "/"; // URL della homepage
var HomeText = "Home"; // Testo del link alla homepage
var HomeWidth = 50; // Larghezza del livello che contiene il tasto alla homepage. (se "Home" viene impostato a "false" viene azzerato.

/* L'array seguente contiene i testi che verranno visualizzati dal menu.
 * Il primo elemento degli array e' il nome del menu, 
 * gli elementi successivi sono i links contenuti nel singolo menu.
 * Il tasto "Home" non compare in questo array perche' viene inserito di default come primo elemento */
var voci=new Array();
	voci[0]=new Array("Area PERSONALE","Area Riservata");
	voci[1]=new Array("Area GENITORI",
	"Orario Colloqui","Libri di Testo","Modelli di Orario","Calendario Scolastico","Regolamento d'Istituto");
	voci[2]=new Array("Area ALUNNI",
	"La Didattica nel Web","I nostri Contributi");
	voci[3]=new Array("INFORMAZIONI",
	"Dove Siamo","Contatti","Il Sito","News");

/* Questo array contiene invece i links che saranno aperti dalle singole voci dei sottomenu.
 * In questa nuova versione del menu ( 09 Dic 2002 ) e' possibile specificare un link 
 * anche per la voce principale del menu 
 * Se viene lasciata vuota non sara' cliccabile (c)br1 */
var lnks=new Array();
	lnks[0]=new Array("","/personale/index.asp")
	lnks[1]=new Array("","Colloqui.asp?Plesso=G","libriditesto.asp","temposcuola.asp","calendario.asp","regolamento.asp")
	lnks[2]=new Array("","/alunni/dw_00.asp","/public/gruppi/alunni/index.asp")
	lnks[3]=new Array("","","","")

/* Contiene i testi che saranno visualizzati nel tooltip e nella barra di stato del browser 
 * quando il mouse e' sopra una voce del menu  */
var wst=new Array();
	wst[0]=new Array("Servizi utili rivolti al Personale della Scuola","(accesso riservato)");
	wst[1]=new Array("Servizi utili rivolti ai Genitori",
	"Le Date e gli Orari dei Colloqui","L'elenco dei Libri di Testo adottati distinti per Corso",
	"L'orario definitivo delle lezioni","I giorni di studio e di vacanza","");
	wst[2]=new Array("Pagine dedicate agli studenti",
	"Abbiamo trovato navigando sul Web","Questo l'ho fatto io");
	wst[3]=new Array("Informazioni utili o curiose",
	"Dati Generali, Mappa","Telefono, Fax, Email, ...","Informazioni riguardanti il Sito","Il Giornalino delle Scuola","Dalla Stampa e dal Web");

/* Questo array contiene i target dei links
 * E' possibile scegliere fra "self" e "new" (o qualsiasi altro valore)
 * "self" aprira' il link nella stessa finestra d'origine, 
 * "new" o qualsiasi altro valore aprira' una nuova finestra del browser
 * come un TARGET="_new" messo in un normale link A 
 * un solo elemento vale per tutto il gruppo
 * - - - - - - - - - - - - - - - - -
 * In una prossima revisione del menu sara' possibile aprire anche delle pop-up */
var targets=new Array();
	targets[0]=new Array("self")
	targets[1]=new Array("self")
	targets[2]=new Array("self")
	targets[3]=new Array("self")

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * 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
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

// identifico browser
var nn=document.layers?true:false
var N6=navigator.userAgent.toLowerCase().indexOf("gecko")!=-1?true:false;
var op=navigator.userAgent.toLowerCase().indexOf("opera")!=-1?true:false;
var IE=document.all?true:false;
var by=document.getElementById?true:false;

var conta=0,last=0;
var HomeWidth=Home?HomeWidth:0;
var MenuLength=HomeWidth+largo*voci.length;
var BrowserWidth=nn||op?window.innerWidth:N6?document.width:document.body.clientWidth-(document.body.scroll?10:0);

/* br1 * modifica della posizione rispetto al contenitore */ 
switch (posizione) {
	case "right" : // tutto da rivedere...
		leftmargin=parseInt((BrowserWidth-MenuLength-leftmargin)); // right 
		break;
	case "center" :
		leftmargin=parseInt((BrowserWidth-MenuLength)/2); // center
		break;
	default :
		// left
}

if (nn)	{

	if (Home)
		document.write("<LAYER NAME=mtop. position=absolute left="+leftmargin+" top="+topmargin+" width="+HomeWidth+" height=15 clip=0,0,"+HomeWidth+",15 bgColor="+roff+" visibility=visible onMouseOver=showdeps(last,false);mroll('mtop.') onMouseOut=unmroll('mtop.') CLASS=menuNNb>&nbsp;<A HREF='"+HomeLink+"' CLASS=menuNNb>"+HomeText+"</A></LAYER>");

	for (i=0;i<voci.length;i++) {
		var n=i;
		document.writeln("<LAYER NAME=mtop"+n+". position=absolute left="+eval(leftmargin+HomeWidth+largo*i)+" top="+topmargin+" width="+largo+" height=15 clip=0,0,"+largo+",15 bgColor="+roff+" visibility=visible onMouseOver=MostraMenu("+i+");mroll('mtop"+i+".');conta++ onMouseOut=last="+i+";unmroll('mtop"+i+".');conta--><DIV ALIGN=center CLASS=menuNNb>&nbsp;<A HREF=javascript:mroll('mtop"+i+".') onClick=vai('"+lnks[i][0]+"',"+i+",0) CLASS=menuNNb>"+voci[i][0]+"</A></DIV></LAYER>");
		for (l=1;l<voci[i].length;l++)
			document.writeln("<LAYER NAME=mdep"+i+"."+l+" position=absolute left="+eval(leftmargin+HomeWidth+largo*i)+" top="+eval(topmargin+15*l)+" width="+largo+" height=15 clip=0,0,"+largo+",15 bgColor="+roff+" visibility=hidden onMouseOver=mroll('mdep"+n+"."+l+"');conta++ onMouseOut=unmroll('mdep"+n+"."+l+"');conta--  CLASS=menuNNb>&nbsp;<A HREF=javascript:mroll('mdep"+n+"."+l+"') onClick=vai('"+lnks[i][l]+"',"+i+","+l+") CLASS=menuNN>"+voci[i][l]+"</A></LAYER>");
	}
} else {
	
	if (Home) {
		document.write("<DIV ID=mtop. STYLE=\"position:absolute;left:"+
		leftmargin+";top:"+topmargin+";width:"+HomeWidth+
		";height:15;background:"+roff+";color:"+toff+
		";visibility:visible;cursor:hand\" "+
		"onMouseOver=showdeps(last,false);mroll('mtop.') "+
		"onMouseOut=unmroll('mtop.')>"+
		"<A HREF='"+HomeLink+"' CLASS=menuIEb onFocus=this.blur()>"
		+"&nbsp;"+HomeText+
		"</A></DIV>");
	}

	for (i=0;i<voci.length;i++)	{
		var n=i;
		riga = "<DIV title=\""+wst[i][0]+"\" ID=mtop"+n+". "+
			"CLASS=menuIEb STYLE=\"left:"+
			eval(leftmargin+HomeWidth+largo*i)+";top:"+topmargin+
			";width:"+largo+";\" "+
			"onMouseOver=\"MostraMenu("+n+");mroll('mtop"+n+".');conta++\" "+
			"onMouseOut=\"last="+n+";unmroll('mtop"+n+".');conta--\" "
		if (lnks[i][0]!="")
			riga += "onClick=\"vai('"+lnks[i][0]+"',"+i+",0)\"";
		riga += ">"+
			"&nbsp;"+voci[i][0]+
			"</DIV>";
		document.writeln(riga) 

		if (primo) {
//			alert(riga)
		}
		
		
		for (l=1;l<voci[i].length;l++) {
			riga = "<DIV ID=mdep"+i+"."+l+" "+
				"title=\""+wst[i][l]+"\" "+
				"CLASS=menuIE "+
				"STYLE=\""+
				"left:"+eval(leftmargin+HomeWidth+largo*i)+";"+
				"top:"+eval(topmargin+15*l)+";"+
				"\" "+
				"onMouseOver=\"mroll('mdep"+n+"."+l+"');conta++\" "+
				"onMouseOut=\"unmroll('mdep"+n+"."+l+"');conta--\" "
			if (lnks[i][l]!="")
				riga += "onClick=\"vai('"+lnks[i][l]+"',"+i+","+l+")\"";
		
			riga = riga + ">&nbsp;"+voci[i][l] + "</DIV>";
			document.writeln(riga) 

			if (primo) {
//				alert(riga)
				primo=false
			}
		
		}
	}
}

timer=setInterval("NascondiMenu()",1000)


function MostraMenu(n) {
	showdeps(last,false);
	showdeps(n,true);
	last=n;
}

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;
	testo=col?ton:toff;
	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(by) {
					document.getElementById('mdep'+i+"."+j).style.background=colore;
					document.getElementById('mdep'+i+"."+j).style.color=testo;
				} else {
					document.all["mdep"+i+"."+j].background=colore;
					document.all["mdep"+i+"."+j].color=testo;
				}
			}
		}
	}
}

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(by) {
					document.getElementById('mdep'+n+"."+i).style.visibility=stat;
				} else {
					document.all["mdep"+n+"."+i].style.visibility=stat;
				}
			}
		}
	}
}

function vai(dove,r,c) {
	
	if (c>0)
		lev=nn?document.layers["mdep"+r+"."+c]:(document.all)?document.all["mdep"+r+"."+c].style:document.getElementById("mdep"+r+"."+c).style;
	else
		lev=nn?document.layers["mtop"+r+"."]:(document.all)?document.all["mtop"+r+"."].style:document.getElementById("mtop"+r+".").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 (navigator.userAgent.toLowerCase().indexOf("msie")!=-1 && navigator.platform.toLowerCase().indexOf("mac")=="mac")
	   document.write("")
	trg=(targets[r][c])?targets[r][c]:targets[r][0];	
	timer=(trg=="self")?setTimeout("self.location.href='"+dove+"'",350):setTimeout("window.open('"+dove+"')",350);

}

function mroll(l) {
	LTop="mtop"+l.substr(4,l.indexOf(".")-4)+".";
	if (nn) {
//		alert("nn")
		document.layers[LTop].bgColor=ron
		document.layers[l].bgColor=ron
	} else {
		if (by) {
//			alert("by")
			document.getElementById(LTop).style.background=ron
			document.getElementById(l).style.background=ron
			document.getElementById(LTop).style.color=ton
			document.getElementById(l).style.color=ton

		} else {
//			alert("IE?")
			document.all[LTop].background=ron
			document.all[l].background=ron
			document.all[LTop].color=ton
			document.all[l].color=ton
		}
	}
	if (by) {
		document.getElementById(l).style.cursor=(IE)?'hand':'pointer';
	}
	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) { // Mouse
	LTop="mtop"+l.substr(4,l.indexOf(".")-4)+".";
	if (nn) {
		document.layers[LTop].bgColor=roff
		document.layers[l].bgColor=roff
	} else {
		if (by) {
			document.getElementById(LTop).style.background=roff
			document.getElementById(l).style.background=roff
			document.getElementById(LTop).style.color=toff
			document.getElementById(l).style.color=toff
		} else {
			document.all[LTop].background=roff
			document.all[l].background=roff
			document.all[LTop].color=toff
			document.all[l].color=toff
		}
	}
	window.status="";
}

