var percorsiAction = new Array(); //Serve per la barra dei percorsi a tenere in memoria l'ultima azioni da compiere
	//Inizializzo con ABOUT US al livello 0
	percorsiAction[0] = new Array();
	percorsiAction[0][0] = 0;    //MI dice il tipo di azione da Compiere (0=apri2L 1=apri3L 2=evidenzia2L 3=evidenzia3L)
	percorsiAction[0][1] = 'menu_about';  //Due argomenti dell'azione sopra;
	percorsiAction[0][2] = 'menu_about_2l';
	percorsiAction[0][3] = 'siamo/siamosommario.php';   //Percorso della pagina da aprire
var Npercorsi=1;	//indica quanti elementi dell'array percorsiAction sono presenti.


var pageEmail='';	//indica quale pagina e' attualmente caricata. usata per richaimare le pagine pasando i valori come get agli script sul server. Vedi anche onload.js. 


//INDIVIDUAZIONE DEL BROWSER USATO
var ns4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? 1 : 0; 
var ie4 = (document.all && !document.getElementById)? 1 : 0;
var ie5 = (document.getElementById && document.all)? 1 : 0;			//IE 7
var ns6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? 1: 0; //FIREFOX
var w3c = (document.getElementById)? 1 : 0;

//FUNZIONI -  GENERAL PURPOSES
function getObject(name) {
   if (w3c) return document.getElementById(name);
   if (ns4) return eval('document.' + name);
   if (ns6) return document.getElementById(name);
   if (ie4) return eval('document.all.' + name);
   if (ie5) return document.getElementById(name);
   return false
}

function mailpage()
{
	soggetto='Link to EICAS website';
	coll="www.eicas.it/mainpage.php?page="+pageEmail+"";
	messaggio='I thought you might be interested in this:%0A'+coll;
	str='mailto:?subject='+soggetto+'&body='+messaggio+'@@@@'+lan;
	window.location.href=str;
}

function changeLang(desiredlan)
{
	if(desiredlan=='it')
	{
		window.location='mainpage.php?lan=it&page='+pageEmail+'';
	}
	else
	{
		window.location='mainpage.php?lan=en&page='+pageEmail+'';
	}
}

function updateSection(IDsection, url)
{	
	if(url.replace(''+pagespath+'','')!='')
	{
		new Ajax.Updater(IDsection, url, {evalScripts:true, encoding:'iso-8859-1', contentType:'application/x-www-form-urlencoded'});

//		new Ajax.Updater(IDsection, url, {evalScripts:true, encoding:'iso-8859-1'});  //RAFF 22 Maggio 2009
	}
// 	new Ajax.Updater(IDsection, url, {evalScripts:true, parameters: { "Mario":"7", "Gianni":"4", "Monica":"4" } });

}



function researchForm(IDsection, url)
{
var query=getObject('query').value;
	
	//Cambio Logo
	getObject(objlogo).src=''+pathlogos+'searchico.gif';

	//Cambio Menu
	table=getObject('menu_right');

		//svuoto il menu precedente
		len=table.rows.length;
		for(i=len-1;i>=0;i--) table.deleteRow(i);

		//azzero al barra dei percorsi	table=getObject('percorsi');
		tablePercorsi=getObject('percorsi');

		while(Npercorsi>1)
		{
			tablePercorsi.rows[0].deleteCell(Npercorsi-1);
			Npercorsi--;	
		}
	
	table.style.width='210px';
	table.style.marginLeft='2mm';
	table.insertRow(0);
	table.rows[0].insertCell(0);
	table.rows[0].cells[0].innerHTML="<tr><td style=\"vertical-align: middle; text-align: center;\"><div id=\"calendar\" style=\"width:210px;\"></div></td></tr>";
	show_calendar('calendar',lan,'#FFFFFF');
	
	getObject(objmenudx_bg).style.backgroundImage='url("'+pathmenudx_bg+'search.gif")';

	new Ajax.Updater(IDsection, url, { method: 'post', evalScripts:false, encoding:'iso-8859-1', parameters: { "s": ''+query+'' } });
}


function Stampa() {
	
var newwin=window.open('','','');
newwin.document.write("<html>"+
	"<head>"+
	 "<title>Print EICAS Automazione S.p.A.</title>"+
 	 "<link href=\"css/main.css\" rel=\"Stylesheet\" type=\"text/css\" />"+
	"</head>"+
	"<body>"+
	getObject('principale').innerHTML+
	"</body>"+
	"</html>");
	newwin.print();
// 	newwin.close();
}



function incrementaPercorso( livello, azione, item1, item2, url, testo)
{
	table=getObject('percorsi');
	while(Npercorsi>livello)
	{
		table.rows[0].deleteCell(Npercorsi-1);
		Npercorsi--;	
	}
	
	//Aggiorno i collegamenti visualizzati
	table.rows[0].insertCell(livello);
	table.rows[0].cells[livello].style.fontSize='7pt';
	table.rows[0].cells[livello].style.fontWeight='bold';
	table.rows[0].cells[livello].style.fontStyle='italic';
	table.rows[0].cells[livello].innerHTML='<a href="javascript:void(0)" onclick="backDaPercorsi('+livello+');return false"><u>'+testo+' >&nbsp;</u></a>';
	
	
	
	//Aggiorno il database deli collegamenti
	percorsiAction[livello] = new Array();
	percorsiAction[livello][0] = azione;    //MI dice il tipo di azione da Compiere (0=apri2L 1=apri2L 2=evidenzia2L 3=evidenzia3L)
	percorsiAction[livello][1] = item1;  //Due argomenti dell'azione sopra;
	percorsiAction[livello][2] = item2;
	percorsiAction[livello][3] = url;   //Percorso della pagina da aprire

	Npercorsi++;
}

function backDaPercorsi(liv)
{
	

	table=getObject('percorsi');
	while(Npercorsi>liv+1)
	{
		table.rows[0].deleteCell(Npercorsi-1);
		Npercorsi--;	
	}

	switch(percorsiAction[liv][0])
	{
		case 0:
			closeALL();
			apri2L(percorsiAction[liv][1],percorsiAction[liv][2]);
		break;
		
		case 1:
			close3L();
			apri3L(percorsiAction[liv][1],percorsiAction[liv][2]);
		break;
		
		case 2:
			evidenzia2L(percorsiAction[liv][1],percorsiAction[liv][2]);
		break;
		
		case 3:
			evidenzia3L(percorsiAction[liv][1],percorsiAction[liv][2]);
		break;
	}

	updateSection('principale', pagespath+percorsiAction[liv][3]);
}


function blink( id, delay ) {
	this.obj = "blinkObj" + blink.count++;
	eval( this.obj + " = this " );
	this.css = ( document.getElementById? document.getElementById( id ).style : (document.all? document.all.fooImg.style : document.layers.fooImg ) );
	if( !this.css && !document.layers ) alert( 'Errore: non trovo il DIV con id="' + id + '"' );
	this.delay = delay || 1000;
	this.blinking = false;
	
	this.setDelay = function( delay ) { this.delay = delay; }
	
	this.isBlinking = function() { return this.blinking; }

	this.start = function() { if( this.isBlinking() ) return false; else this.go(); return true; }
	
	this.go = function() {
		this.blinking = true;
		if( this.isVisible() ) this.hide();
		else this.show();
		this.timer = setTimeout( this.obj + ".go()", this.delay );
	}
	
	this.isVisible = function() { return ( this.css.visibility == "visible" || this.css.visibility == "show" ); }
	
	this.hide = function() { this.css.visibility = ( document.layers? "hide" : "hidden" );  }
	
	this.show = function() { this.css.visibility = ( document.layers? "show" : "visible" ); }

	this.stop = function() {
		this.show();
		this.blinking = false;
		clearTimeout( this.timer );
	}
	return this;
}
blink.count = 0;
