////////////////////////////////////////////////////////////////////////
////                                                                ////
////////////////////////////////////////////////////////////////////////


var ie = (document.all) ? 1:0;
numLink = 27;		// numero totale dei link generali
alto = 120;
lato = 5;
altLink = 27;

piu1b = true;
piu2b = true;
piu3b = true;

collegamenti = new Array(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);

sottoMenu = new Array(false, false, false);
// bottoni espandi
var bottEsp = new Array ();

bottEsp[0] = new Image ();
bottEsp[0].src = "http://www.esercizistatica.it/images/espandiGrigio.gif"; 
bottEsp[1] = new Image ();
bottEsp[1].src = "http://www.esercizistatica.it/images/espandiRosso.gif";

// bottoni chiudi
var bottChiudi = new Array ();

bottChiudi[0] = new Image ();
bottChiudi[0].src = "http://www.esercizistatica.it/images/chiudiGrigio.gif"; 
bottChiudi[1] = new Image ();
bottChiudi[1].src = "http://www.esercizistatica.it/images/chiudiRosso.gif";

// quadratini
var quadratini = new Array ();

quadratini[0] = new Image ();
quadratini[0].src = "http://www.esercizistatica.it/images/blu.gif"; 
quadratini[1] = new Image ();
quadratini[1].src = "http://www.esercizistatica.it/images/rosso.gif";

// +/-
var piumeno = new Array ();

piumeno[0] = new Image ();
piumeno[0].src = "http://www.esercizistatica.it/images/piu.gif"; 
piumeno[1] = new Image ();
piumeno[1].src = "http://www.esercizistatica.it/images/meno.gif";

chiuso = true;

// apertura o chiusura del menu ***
function apri ()
{
	if(chiuso)
	{
			sottoMenu[0] = true;
			document.piu1.src = piumeno[1].src; // meno
			piu1b = false;
			sottoMenu[1] = true;
			document.piu2.src = piumeno[1].src;
			piu2b = false;
			sottoMenu[2] = true;
			document.piu3.src = piumeno[1].src;
			piu3b = false;
			chiuso = false;
			document.espandi.src = bottChiudi[0].src; // chiudi grigio
	}
	else
	{
			sottoMenu[0] = false;
			document.piu1.src = piumeno[0].src;
			piu1b = true;
			sottoMenu[1] = false;
			document.piu2.src = piumeno[0].src;
			piu2b = true;
			sottoMenu[2] = false;
			document.piu3.src = piumeno[0].src;
			piu3b = true;
			chiuso = true;		
			document.espandi.src = bottEsp[0].src;	
	}
	posiziona();
}

// 
function espandi_chiudi (sopra)
{
	if(chiuso)
	{
		if(sopra)
		{
			document.bott27.src = quadratini[1].src;
			document.espandi.src = bottEsp[1].src;
		}
		else
		{
			document.bott27.src = quadratini[0].src;
			document.espandi.src = bottEsp[0].src;
		}
	}
	else
	{
		if(sopra)
		{
			document.bott27.src = quadratini[1].src;
			document.espandi.src = bottChiudi[1].src;
		}
		else
		{
			document.bott27.src = quadratini[0].src;
			document.espandi.src = bottChiudi[0].src;
		}
	}
}


div = new Array();

// cambia lo stato del sottomenu n
function sottoM(n)
{
	if(!sottoMenu[n])
	{
		sottoMenu[n] = true;
	}
	else
	{
		sottoMenu[n] = false;
	}
	posiziona();
}

// apre il sottomenu n
function sottoMA(n)
{
	sottoMenu[n] = true;
	posiziona();
}

// crea la stringa di stato per ogni link
function generaDiv()
{
	if(ie)
	{
		for(c = 0;c < numLink; c++)
		{
			div[c] = "document.all.link"+(c+1)+".style";
		}
	}
	else
	{
		for(c = 0;c < numLink; c++)
		{
			div[c] = "document.link"+(c+1);
		}
	}
}

// setta lo stato dei collegamenti dipendentemente dallo stato dei menu
// esegue un loop e mostra o meno i collegamenti stessi  ***
function posiziona()
{
	if(!sottoMenu[0])
	{
		collegamenti[5] = false;
		collegamenti[6] = false;
		collegamenti[7] = false;
		collegamenti[8] = false;
		collegamenti[9] = false;
		collegamenti[10] = false;
		collegamenti[11] = false;
		collegamenti[12] = false;
		collegamenti[13] = false;
		collegamenti[14] = false;
		collegamenti[15] = false;
		collegamenti[16] = false;
	}
	else
	{
		collegamenti[5] = true;
		collegamenti[6] = true;
		collegamenti[7] = true;
		collegamenti[8] = true;
		collegamenti[9] = true;
		collegamenti[10] = true;
		collegamenti[11] = true;
		collegamenti[12] = true;
		collegamenti[13] = true;
		collegamenti[14] = true;
		collegamenti[15] = true;
		collegamenti[16] = true;
	}
	if(!sottoMenu[1])
	{
		collegamenti[18] = false;
		collegamenti[19] = false;
	}
	else
	{
		collegamenti[18] = true;
		collegamenti[19] = true;
	}
	if(!sottoMenu[2])
	{
		collegamenti[21] = false;
		collegamenti[22] = false;
		collegamenti[23] = false;
	}
	else
	{
		collegamenti[21] = true;
		collegamenti[22] = true;
		collegamenti[23] = true;
	}
	cc = 0;
	for(c = 0;c < numLink; c++)
	{
		if(collegamenti[c])
		{
			cc++;
			posiz = alto + altLink * cc;
			eval(div[c] + ".top = posiz");
			eval(div[c] + ".left = lato");
			mostra = "visible";
		}
		else
		{
			mostra = "hidden";
		}
		eval(div[c]+".visibility = mostra");
	}
}

// crea la stringa oggiE
giorni = new Array("domenica",
						 "lunedì",
						 "martedì",
						 "mercoledì",
						 "giovedì",
						 "venerdì",
						 "sabato");

mesi = new Array("gennaio", 
					  "febbraio",
					  "marzo",
					  "aprile",
					  "maggio",
					  "giugno",
					  "luglio",
					  "agosto",
					  "settembre",
					  "ottobre",
					  "novembre",
					  "dicembre");
orario = new Date();
ggCifra = orario.getDate();
ggNumero = orario.getDay();
ggNome = giorni[ggNumero];
mmCifra = orario.getMonth();
mmNome = mesi[mmCifra];

oggiE = "&nbsp;" + ggNome + " " + ggCifra +" " + mmNome +
         " " + orario.getFullYear() +
			" - Ultimo aggiornamento: 1/10/2005"+
			" - <a href = 'mailto:staff@esercizistatica.it' id = mail>staff@esercizistatica.it</a>";

// impostazioni dello schermo
var larghezzaSchermo = screen.availWidth;	
var altezzaSchermo = screen.availHeight;
var larghezzaNuovaFin;
var altezzaNuovaFin;

// apertura di una finestra
function apriFinestra(url, target, larghezzaNuovaFin,  altezzaNuovaFin) 
{
	centroX = larghezzaSchermo / 2 - larghezzaNuovaFin / 2;
	centroY = altezzaSchermo / 2 - altezzaNuovaFin / 2;
	window.open(url, target, "width = "+larghezzaNuovaFin+", height = "+altezzaNuovaFin+", screenX = "+centroX+", screenY = "+centroY+", left = "+centroX+", top = "+centroY)
}
