function settaOra()
   {
   var ora = new Date();
   var oo = ora.getHours();
   var mn = ora.getMinutes();
   var sec = ora.getSeconds();
   var oo2  = ((oo < 10) ? "0" : "");
   var mn2  = ((mn < 10) ? ":0" : ":");
   var sec2  = ((sec < 10) ? ":0" : ":");
   var hh = oo2 + oo + mn2 + mn + sec2 + sec;

	//document.ora.rome.value = hh;
	document.getElementById("oraRome").innerHTML = hh;
		document.getElementById("oraRomeU").innerHTML = hh;
		
   window.setTimeout("settaOra()",1000);
   }
   
function changeBanner() {
	document.getElementById("iframeBanner").src="inc.banner.asp";
	 window.setTimeout("changeBanner()",20000);
}
 
onload=settaOra;

function ctrlSearch()
{
	ok = 0;
	ff = document.cerca;
	
	if (ok==0 && ff.searchTxt.value=="") { alert("Inserire il testo da cercare"); ok = 1 }
	if (ok==0 && ff.searchTxt.value.length < 3) { alert("Testo troppo breve, si prega di inserire almeno 3 lettere."); ok = 1 }
	
	if (ok==0) { return true } else { return false }
}

function sendSearcResult(link)
{
	document.searcResult.action = link;	
	document.searcResult.submit()
}

function goBack()
{
	window.history.back()
}

function printPage()
{
	window.print();

}

function ctrlContatti()
{
	ok = 0;
	ff = document.contatti;
	
	if (ok==0 && ff.nome.value=="") { alert("Inserire il nome."); ok = 1 }
	if (ok==0 && ff.mail.value=="") { alert("Inserire l'indirizzo e-mail."); ok = 1 }
	if (ok==0 && ff.mail.value.indexOf("@")==-1) { alert("L'indirizzo e-mail non è valido."); ok = 1 }
	if (ok==0 && ff.mail.value.indexOf(".")==-1) { alert("L'indirizzo e-mail non è valido."); ok = 1 }
	if (ok==0 && ff.testo.value=="") { alert("Inserire il testo del messaggio."); ok = 1 }
	
	if (ok==0) { return true } else { return false }
}

function ctrlNewsletter()
{
	ok = 0;
	ff = document.newsletter;
	
	if (ok==0 && ff.nome.value=="") { alert("Inserire il nome."); ok = 1 }
	if (ok==0 && ff.mail.value=="") { alert("Inserire l'indirizzo e-mail."); ok = 1 }
	if (ok==0 && ff.mail.value.indexOf("@")==-1) { alert("L'indirizzo e-mail non è valido."); ok = 1 }
	if (ok==0 && ff.mail.value.indexOf(".")==-1) { alert("L'indirizzo e-mail non è valido."); ok = 1 }	
	
	if (ok==0) { return true } else { return false }
}

function ctrlArchivio()
{
	ok = 0;
	ff = document.form1;	
	
	if (ff.daData.value=="gg-mm-aaaa") { ff.daData.value = "" }
	if (ff.aData.value=="gg-mm-aaaa") { ff.aData.value = "" }
	
	if (ff.searchTxt.value=="" && ff.daData.value=="" && ff.aData.value=="") { alert("Per continuare inserire almeno un campo di ricerca."); ok=1 }
	
	if (ok==0 && ff.daData.value!="")
	{
		splitta(ff.daData.value)
			ffDaG = nomi[0];
			ffDaM = nomi[1];
			ffDaA = nomi[2];
		
		splitta(ff.aData.value)
			ffAG = nomi[0];
			ffAM = nomi[1];
			ffAA = nomi[2];
		
		var dataDa = new Date(ffDaA, ffDaM-1, ffDaG);
		var dataA = new Date(ffAA, ffAM-1, ffAG);
		
			// The number of milliseconds in one day
		var ONE_DAY = 1000 * 60 * 60 * 24

		// Convert both dates to milliseconds
		var date1_ms = dataDa.getTime()
		var date2_ms = dataA.getTime()

		// Calculate the difference in milliseconds
		var difference_ms = Math.abs(date1_ms - date2_ms)
		
		// Convert back to days and return
		ggTot = Math.round(difference_ms/ONE_DAY)
						
		if (ok==0 && date1_ms > date2_ms) {alert("La data di inizio ricerca non può essere\nsuperiore alla data di fine ricerca."); ok=1 }
		if (ok==0 && ggTot > 30) {alert("Non è possibile selezionare un periodo \ndi ricerca maggiore di un mese."); ok=1 }	
		
		if (ok==0 && ff.daData.value=="") {alert("Inserire una data di inizio ricerca."); ok=1 }
		if (ok==0 && ff.aData.value=="") {alert("Inserire una data di fine ricerca."); ok=1 }
		
	}

	if (ok==0) { return true } else { return false }
}