//<script>
/*-----------------------------------------*/
function apriFinestra(name, larghezza, altezza){
	var x = (screen.width - larghezza)/2;
	var y = (screen.height - altezza)/2;
	var finestra = window.open(name, 'ingrandimento', 'width=' + larghezza +',height=' + altezza + ', toolbar=no, directories=no, location=no, status=no, menubar=no, copyhistory=no, scrollbars=no, resizable=no');
	finestra.moveTo(x,y);
	finestra.focus();
}// fine funzione
/*-----------------------------------------*/
function login_accedi(){
	with(document.forms['entrata']){
		if(UNAME.value.length<=2){
			alert('Username non valido!');
			UNAME.focus();
			return;
		}//fine if
		if(PASSWD.value.length<=2){
			alert('Password non valida!');
			PASSWD.focus();
			return;
		}//fine if
		submit();
	}// fine with
}// fine funzione
/*-----------------------------------------*/
function step00(lingua){
	var msg
	switch(lingua){
		case 2:
		msg='Select a Accreditation Type!';
		break;
		default:
		msg='Selezionare una tipologia!';
		break;
	}
	with(document.forms['tipologia']){

		if(serialeTipo.selectedIndex == 0){
			alert(msg);
			serialeTipo.focus();
			return;
		}//fine if
		descrizione.value = serialeTipo.options[serialeTipo.selectedIndex].text;
		op2.value = 'step01';
		submit();
	}// fine with
}// fine funzione
/*-----------------------------------------*/
function step01(lingua){
	var msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,msg10
	switch(lingua){
		case 2:
		msg1='Choose country!';
		msg2='Add surname!';
		msg3='Add name!';
		msg4='Add passport!';
		msg5="Email address not correct!";
		msg6='Choose nationality';
		msg7='Date not correct';
		msg8='Add sport!';
		msg9='Insert text in another field!';
		msg10='Add your role!';
		break;
		default:
		msg1='Selezionare una nazione!';
		msg2='Inserire cognome!';
		msg3='Inserire nome!';
		msg4='Inserire passaporto!';
		msg5="L'indirizzo di e-mail deve essere nel formato nome@dominio.";
		msg6='Selezionare una nazionalità';
		msg7='Inserire la data correttamente!';
		msg8='Non è stata specificato alcun Sport!';
		msg9='Campo Altro obbligatorio';
		msg10='Non è stata specificato alcun Ruolo!';
		break;
	}
	with(document.forms['tipologia']){

		if(adm.value == 1 && serialeNazione.selectedIndex == 0){
			alert(msg1);
			serialeNazione.focus();
			return;
		}//fine if

		if(cognome.value == ''){
			alert(msg2);
			cognome.focus();
			return;
		}//fine if

		if(nome.value == ''){
			alert(msg3);
			nome.focus();
			return;
		}//fine if

		if(numeroPassaporto.value == ''){
			alert(msg4);
			numeroPassaporto.focus();
			return;
		}//fine if

		if(email.value != ''){
			if (email.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
				alert(msg5);
				email.focus();
				return;
			}// fine if
		}// fine if

		if(nazionalita.selectedIndex == 0){
			alert(msg6);
			nazionalita.focus();
			return;
		}//fine if

		if(!VerificaData(dataNascita.value)){
			alert(msg7);
			dataNascita.focus();
			return;
		}//fine if

		//alert(eval('document.forms[\'tipologia\'].chksport'));
		if(eval('document.forms[\'tipologia\'].chksport') != undefined){
			// controllo che venga selezionata almeno un gruppo
			var selezionatoSport = false;
			for (i=0;i<document.forms['tipologia'].elements.length;i++){
				if (document.forms['tipologia'].elements[i].name.substring(0,5)=="sport" && document.forms['tipologia'].elements[i].checked){
					selezionatoSport = true;
				}// fine if
			}// fine for
			if (selezionatoSport == false) {
				alert(msg8);
				return;
			}//fine if
		}// fine if

		//alert(eval('document.forms[\'tipologia\'].chkruolo'));
		if(eval('document.forms[\'tipologia\'].chkruolo') != undefined){
			// controllo che venga selezionata almeno un gruppo
			var selezionatoRuolo = false;
			for (i=0;i<document.forms['tipologia'].elements.length;i++){
				if (document.forms['tipologia'].elements[i].name.substring(0,5)=="ruolo" && document.forms['tipologia'].elements[i].checked){
					selezionatoRuolo = true;
					// controllo campo other
					if((document.forms['tipologia'].elements[i].value == 9 || document.forms['tipologia'].elements[i].value == 3) && altriRuoli.value ==''){
						alert(msg9);
						altriRuoli.focus();
						return;
					}// fine if
				}// fine if
			}// fine for
			if (selezionatoRuolo == false) {
				alert(msg10);
				return;
			}//fine if
		}// fine if

		op2.value = 'step03';
		submit();
	}// fine with
}// fine funzione
/*-----------------------------------------*/
function VerificaData(Valore) {
	var ValoriData;
	var Giorni = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var iData = new RegExp("^((3[0-1])|([1-2][0-9])|(0[1-9]))\/((1[0-2])|(0[1-9]))\/((19|20)[0-9][0-9])$");
	// verifica la validita' della data

	if(iData.test(Valore) == true){
		//	if (Valore.search(/^(3[01]|[0-2]\d)\/(1[0-2]|0\d)\/(19|20)\d\d$/) != -1 && Valore.lenght == 10) {
		// imposta il vettore dei valori
		ValoriData = Valore.split("/");
		// verifica se l'anno e' bisestile aggiungo 1 a febbraio
		if (ValoriData[2] % 4 == 0){
			Giorni[1]++;
		}// fine if
		//		alert(ValoriData[0] + '---|' + (ValoriData[1] - 1) + '|---' + Giorni[ValoriData[1] - 1] + '///' + (ValoriData[0] <= Giorni[ValoriData[1] - 1]) );
		return (ValoriData[0] <= Giorni[ValoriData[1] - 1]);
	}// fine if
	// in caso di errore ritorna false
	return false;
}//end function
/*-----------------------------------------*/
function eliminaRiga(seriale,lingua){
	var msg
	switch(lingua){
		case '2':
		msg='Delete the Row! Are you sure?';
		break;
		default:
		msg='Sei sicuro di volere eliminare questa riga?';
		break;
	}
	with (document.forms[0]) {
		if(!confirm(msg)){
			return;
		}
		COMANDO.value="elimina";
		SERIALE.value=seriale;

		submit();
	}
}//end function
/*-----------------------------------------*/
function getTime(lingua) {
	now = new Date();
	y2k = new Date("Jul 3 2005 20:00:00");
	days = (y2k - now) / 1000 / 60 / 60 / 24;
	daysRound = Math.floor(days);
	hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
	hoursRound = Math.floor(hours);
	minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
	minutesRound = Math.floor(minutes);
	seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
	secondsRound = Math.round(seconds);
	if(lingua == 1){
		sec = (secondsRound == 1) ? " secondo a Lignano 2005" : " secondi a Lignano 2005!";
		min = (minutesRound == 1) ? " minuto" : " minuti, ";
		hr = (hoursRound == 1) ? " ora" : " ore, ";
		dy = (daysRound == 1)  ? " giorno" : " giorni, ";
		mancano = "Mancano ";
	}
	else{
		sec = (secondsRound == 1) ? " second to Lignano 2005" : " seconds to Lignano 2005!";
		min = (minutesRound == 1) ? " minute" : " minutes, ";
		hr = (hoursRound == 1) ? " hour" : " hours, ";
		dy = (daysRound == 1)  ? " day" : " days, ";
		mancano = "Still ";
	}// fine if
	//document.bannerform.input1.value = mancano + daysRound  + dy + hoursRound + hr + minutesRound + min + secondsRound + sec;

	newtime = window.setTimeout("getTime(" + lingua + ");", 1000);
}// fine funzione
/*-----------------------------------------*/
function inviaModulo(lingua){
	// Italiano
	var testi1 = new Array(
	'Devi inserire il nome',
	'Devi inserire il cognome',
	'Devi inserire la via',
	'Devi inserire il CAP in modo corretto',
	'Devi inserire il comune',
	'Devi inserire la provincia',
	'Devi inserire un numero telefonico corretto\nFormato: pref. int./pref./numero',
	'Devi inserire un numero di cell corretto\nFormato: pref. int./pref./numero',
	'Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx',
	'Devi inserire una data corretta\nFormato: gg/mm/aaaa',
	'Devi inserire il luogo di nascita',
	'Non avete dato il consenso alla Legge 196/2003',
	'Devi inserire il telefono o il cellulare'
	);
	// Inglese
	var testi2 = new Array(
	'Devi inserire il nome',
	'Devi inserire il cognome',
	'Devi inserire la via',
	'Devi inserire il CAP in modo corretto',
	'Devi inserire il comune',
	'Devi inserire la provincia',
	'Devi inserire un numero telefonico corretto\nFormato: pref. int./pref./numero',
	'Devi inserire un numero di cell corretto\nFormato: pref. int./pref./numero',
	'Devi inserire l\'indirizzo email in maniera corretta\nFormato: nome@dominio.xx',
	'Devi inserire una data corretta\nFormato: gg/mm/aaaa',
	'Devi inserire il luogo di nascita',
	'Non avete dato il consenso alla Legge 196/2003',
	'Devi inserire il telefono o il cellulare'
	);

	with(document.forms['richiedi']){

		// nome
		if(nome.value==''){
			alert(eval('testi' + lingua  + '[0]'));
			nome.focus();
			return;
		}//fine if

		// cognome
		if(cognome.value==''){
			alert(eval('testi' + lingua  + '[1]'));
			cognome.focus();
			return;
		}//fine if

		// Data nascita
		if(!VerificaData(nascita_data.value)){
			alert(eval('testi' + lingua  + '[9]'));
			nascita_data.focus();
			return;
		}//fine if

		// Luogo nascita
		if(nascita_luogo.value==''){
			alert(eval('testi' + lingua  + '[10]'));
			nascita_luogo.focus();
			return;
		}//fine if

		// Via
		if(res_via.value==''){
			alert(eval('testi' + lingua  + '[2]'));
			res_via.focus();
			return;
		}//fine if

		// Cap
		var i=new RegExp("^[0-9]{5}$");
		if(!i.test(res_cap.value)){
			alert(eval('testi' + lingua  + '[3]'));
			res_cap.focus();
			return;
		}//fine if

		// Comune
		if(res_comune.value==''){
			alert(eval('testi' + lingua  + '[4]'));
			res_comune.focus();
			return;
		}//fine if

		// Provincia
		if(res_provincia.value==''){
			alert(eval('testi' + lingua  + '[5]'));
			res_provincia.focus();
			return;
		}//fine if

		if(res_tel.value=='' && res_cell.value==''){
			alert(eval('testi' + lingua  + '[12]'));
			res_tel.focus();
			return;
		}//fine if


		// Telefono
		if(res_tel.value!=''){
			var i=new RegExp("^[\+]?([0-9]{2,})?(-| |\/)?([0-9]{2,})(-| |\/)?([0-9]{4,})$");
			if(!i.test(res_tel.value)){
				alert(eval('testi' + lingua  + '[6]'));
				res_tel.focus();
				return;
			}//fine if
		}//fine if

		// Cell
		if(res_cell.value!=''){
			var i=new RegExp("^[\+]?([0-9]{2,})?(-| |\/)?([0-9]{2,})(-| |\/)?([0-9]{4,})$");
			if(!i.test(res_cell.value)){
				alert(eval('testi' + lingua  + '[7]'));
				res_cell.focus();
				return;
			}//fine if
		}//fine if

		// Mail
		if (res_email.value.search(/^\w+([\.\-]\w+)*@\w+([\.\-]\w+)*\.\w+$/) == -1) {
			alert(eval('testi' + lingua  + '[8]'));
			res_email.focus();
			return;
		}//fine if

		// Data Documento Identità
		if(docIden_data.value != ''){
			if(!VerificaData(docIden_data.value)){
				alert(eval('testi' + lingua  + '[9]'));
				docIden_data.focus();
				return;
			}//fine if
		}//fine if

		// Data Patente
		if(patente_data.value != ''){
			if(!VerificaData(patente_data.value)){
				alert(eval('testi' + lingua  + '[9]'));
				patente_data.focus();
				return;
			}//fine if
		}//fine if

		// Legge
		if(!legge.checked && lingua == 1 ){
			alert(eval('testi' + lingua  + '[11]'));
			legge.focus();
			return;
		}// fine if

		op2.value='ok';
		submit();
	}// fine with
}// fine funzione

/*-----------------------------------------
funzione applicata al modulo ricerca
-----------------------------------------*/
function ricerca(lingua) {
	
	// Italiano
	var testi1 = new Array(
	'Devi inserire una stringa per la ricerca' // 0
	);
	// Inglese
	var testi2 = new Array(
	'Devi inserire una stringa per la ricerca'
	);

	//with(document.forms[0]){
	with(document.forms['ricercaForm']){
		if(l_stRicerca.value==''){
			alert(eval('testi' + lingua  + '[0]'));
			l_stRicerca.focus();
			return;
		}//fine if
		submit();
	}// fine with
}// fine funzione

/* DETTAGLIO PER PHOTOGALLERY */

function apriDettaglio(id){

	var pagina = 'gallery.php?pgSeriale=' + id;

	var larghezza = 580;
	var altezza = 450;

	var x = (screen.width -larghezza)/2;
	var y = (screen.height - altezza)/2;

	var finestra = window.open(pagina, 'ingrandimento', 'width=' + larghezza +',height=' + altezza + ', toolbar=no, directories=no, location=no, status=no, menubar=no, copyhistory=no, scrollbars=yes, resizable=yes');

	finestra.moveTo(x,y);

	finestra.focus();

}// fine funzione