/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * 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
 *
 * Questo menu e' (C)2001 ri.riccardi@agora.stm.it - Lo script e' reperibile al sito http://www.jsdir.com - JavaScript Directory
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var ron="#E0A779"; // Colore al MouseOver
var roff="#BA6520"; // Colore di default
var leftmargin=0; // Distanza dal margine sinistro della pagina ( ---> v. commento alla riga 57)
var topmargin=124; // Distanza dal margine superiore della pagina
var largo=115; // Larghezza dei layers, quindi distanza (orizzontale) fra i sottomenu

var Home = false; // Settare a "false" se non si desidera il link all'homepage -> con le modifiche effettuate, è opportuno settare sempre a false questa variabile
var HomeLink = "http://www.textweaver.com"; // URL della homepage
var HomeText = "Textweaver"; // Testo del link alla homepage
var HomeWidth = 100; // 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, adattato per contenere le immagini con cui è costruito il menu, gli elementi successivi sono il testo dei links contenuti nel singolo menu.
 * Il tasto "Home" non compare in questo array perche' viene inserito di default come primo elemento, ad ogni modo con la modifica che ho fatto per adattare il menu alla pagina, non è mai opportuno impostare la variabile Home a true */
var voci=new Array();
    voci[0] = new Array("<IMG SRC=\"images/Adams1_02.jpg\" width='195' height='20'>"); // La prima voce del menu è semplicemente la prima immagine a sinistra (quella con l'aiuola), che non contiene nessun link.
	/*voci[1]=new Array("<IMG SRC=\"images/Adams1_03.jpg\" width='107' height='20'>","Apartments","Photographs","Location Map","5 Bedroom Home",); ECCO L'ERRORE: si tratta di una virgola che ti è sfuggita alla fine dell'array: gli elementi di un array sono separati da virgole tra loro, ma in genere, dopo l'ultimo elemento e prima della parentesi di chiusura, la virgola non ci va: Javascript, poi, è davvero una carogna come debugging: la segnalazione che fa degli errori è quantomeno criptica!!*/
	voci[1]=new Array("<IMG SRC=\"images/Adams1_03.jpg\" width='107' height='20'>","Apartments"," ","Photographs","Location Map"); // ecco la versione corretta. 
	voci[2]=new Array("<IMG SRC=\"images/Adams1_04.jpg\" width='140' height='20'>","Helpful Information","Local Destinations");
	voci[3]=new Array("<IMG SRC=\"images/Adams1_05.jpg\" width='154' height='20'>","About Bloomington","Community Links");
	voci[4]=new Array("<IMG SRC=\"images/Adams1_06.jpg\" width='121' height='20'>","Contact Us","Location Map","Apply Online");


/* Questo array contiene invece i links che saranno aperti dalle singole voci dei sottomenu.
 * inserire questo: "/" significa non inserire alcun link. In corrispondenza delle prime voci del menu, cioè delle immagini che costituiscono la barra, tutti i links sono impostati a "/" */
var links=new Array();
	links[0] = new Array("#")
	links[1]=new Array("#","apartments.html","home.html","photos.html","map.html");
	links[2]=new Array("#","information.html","destinations.html");
	links[3]=new Array("#","bloomington.html","links.html");
	links[4]=new Array("#","contact.html","map.html","http://www.apartmentsbloomington.com/leasing/index.asp");


/* 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 
 * - - - - - - - - - - - - - - - - -
 **/
var targets=new Array();
	targets[0] = new Array("self");
	targets[1]=new Array("self","self","self","self","self");
	targets[2]=new Array("self","self","self","self");
	targets[3]=new Array("self","self","self");
	targets[4]=new Array("self","self","self","self");


/* Ultimo array.
 * Contiene i testi che saranno visualizzati nella barra di stato del browser quando il mouse e' sopra una voce del menu  */
var wst=new Array();
	wst[0]=new Array("");
	wst[1]=new Array("","Adams Village Apartments","Five-Bedroom Home","Photographs","Location Map");
	wst[2]=new Array("","Information","Tips","Maintenance");
	wst[3]=new Array("","Bloomington","Links");
	wst[4]=new Array("","Contact Us","Location Map","Apply Online");
	
/*array aggiunto per adattare il menu alla pagina: consente di specificare la larghezza per ogni singolo "tasto" del menu, queste larghezze sono le stesse delle immagini che costituiscono la barra e vengono utilizzate più sotto per effettuare il posizionamento assoluto delle varie <div></div> o dei vari <layer></layer> che costituiscono il menu*/

var myWidth = new Array();
    myWidth[0] = 195;
	myWidth[1] = 107;
	myWidth[2] = 140;
	myWidth[3] = 154;
	myWidth[4] = 121;


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
 * 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, ad eccezione della riga evidenziata
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var nn=document.layers?true:false,N6=navigator.userAgent.toLowerCase().indexOf("gecko")!=-1?true:false,conta=0,last=0;
var op=navigator.userAgent.toLowerCase().indexOf("opera")!=-1?true:false
HomeWidth=Home?HomeWidth:0;
//var MenuLength=HomeWidth+largo*voci.length;
var MenuLength = HomeWidth + 717;
var BrowserWidth=nn||op?window.innerWidth:N6?document.width:document.body.clientWidth;
// Commentare la riga successiva con // all'inizio se non si desidera il menu al centro della pagina, bensi' nella posizione definita in "leftmargin"
leftmargin=parseInt((BrowserWidth-MenuLength)/2);

if (nn)
	{
	if (Home)
		document.write("<LAYER NAME=mtop. position=absolute left="+leftmargin+" top="+topmargin+" width="+HomeWidth+" height=20 clip=0,0,"+HomeWidth+",20 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;
		var myLeft;
		if(n == 0)
			{
			myLeft = 0;
			}
		else if(n == 1)
			{
			myLeft = myWidth[0];
			}
		else if(n == 2)
			{
			myLeft = myWidth[0] + myWidth[1];
			}
		else if(n == 3)
			{
			myLeft = myWidth[0] + myWidth[1] + myWidth[2];
			}
		else if(n == 4)
			{
			myLeft = myWidth[0] + myWidth[1] + myWidth[2]+ myWidth[3];
			}
		document.writeln("<LAYER NAME=mtop"+n+". position=absolute left="+eval(leftmargin+HomeWidth+myLeft)+" top="+topmargin+" width="+myWidth[i]+" height=20 clip=0,0,"+myWidth[i]+",20 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('"+links[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+myLeft)+" top="+eval(topmargin+20*l)+" width="+myWidth[i]+" height=20 clip=0,0,"+myWidth[i]+",20 bgColor="+roff+" visibility=hidden onMouseOver=mroll('mdep"+n+"."+l+"');conta++ onMouseOut=unmroll('mdep"+n+"."+l+"');conta--  CLASS=menuNNb><A HREF=javascript:mroll('mdep"+n+"."+l+"') onClick=vai('"+links[i][l]+"',"+i+","+l+") CLASS=menuNN>&nbsp;"+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+";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;
		var myLeft;
		if(n == 0)
			{
			myLeft = 0;
			}
		else if(n == 1)
			{
			myLeft = myWidth[0];
			}
		else if(n == 2)
			{
			myLeft = myWidth[0] + myWidth[1];
			}
		else if(n == 3)
			{
			myLeft = myWidth[0] + myWidth[1] + myWidth[2];
			}
		else if(n == 4)
			{
			myLeft = myWidth[0] + myWidth[1] + myWidth[2]+ myWidth[3];
			}
		document.writeln("<DIV ID=mtop"+n+". STYLE=\"position:absolute;left:"+eval(leftmargin+HomeWidth+myLeft)+";top:"+topmargin+";width:"+myWidth[i]+";height:20;background:"+roff+";visibility:visible;cursor:hand\" onMouseOver=MostraMenu("+n+");mroll('mtop"+n+".');conta++ onMouseOut=last="+n+";unmroll('mtop"+n+".');conta--><DIV ALIGN=center CLASS=menuIEb onClick=vai('"+links[i][0]+"',"+i+",0)>"+voci[i][0]+"</DIV></DIV>");
		for (l=1;l<voci[i].length;l++)
			document.writeln("<DIV ID=mdep"+i+"."+l+" STYLE=\"position:absolute;left:"+eval(leftmargin+HomeWidth+myLeft)+";top:"+eval(topmargin+20*l)+";width:"+myWidth[i]+";height:20;background:"+roff+";visibility:hidden;cursor:hand\" onMouseOver=;mroll('mdep"+n+"."+l+"');conta++ onMouseOut=unmroll('mdep"+n+"."+l+"');conta-- CLASS=menuIE onClick=vai('"+links[i][l]+"',"+i+","+l+")>&nbsp;"+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 (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("")  
	timer=targets[r][c]=="self"?setTimeout("self.location.href='"+dove+"'",350):setTimeout("window.open('"+dove+"')",350);
	}

function mroll(l)
	{
	LTop="mtop"+l.substr(4,l.indexOf(".")-4)+".";
	nn?document.layers[LTop].bgColor=ron:(document.all)?document.all[LTop].style.background=ron:document.getElementById(LTop).style.background=ron;
	nn?document.layers[l].bgColor=ron:(document.all)?document.all[l].style.background=ron:document.getElementById(l).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)
	{
	LTop="mtop"+l.substr(4,l.indexOf(".")-4)+".";
	nn?document.layers[LTop].bgColor=roff:(document.all)?document.all[LTop].style.background=roff:document.getElementById(LTop).style.background=roff;
	nn?document.layers[l].bgColor=roff:(document.all)?document.all[l].style.background=roff:document.getElementById(l).style.background=roff;
	window.status="";
	}
