<!--

function valida_serravalle(FormRegistrazione) { 

	
	// cognome
	if (document.getElementById("cognome").value=="") {
		alert("\n NOVARESE:\n indicare il cognome!");
		document.getElementById("cognome").style.backgroundColor="#FFFF99";
		document.getElementById("cognome").style.color="#000";
		document.getElementById("cognome").focus();
		return false;
	}
	filtro_cognome = /^[a-zA-Z\s]+[a-zA-Z]+$/;
	if (!filtro_cognome.test(!document.getElementById("cognome").value)) {
		alert("\n NOVARESE:\n Cognome non valido\n\n Valide solo lettere e spazi centrali\n\n Non può iniziare o terminare con lo spazio");
		document.getElementById("cognome").focus();
		return false;
	}	
	// nome
	if (document.getElementById("nome").value=="") {
		alert("\n NOVARESE:\n Nome?");
		document.getElementById("nome").style.backgroundColor="#FFFF99";
		document.getElementById("nome").style.color="#000";
		document.getElementById("nome").focus();
		return false;
	}
	filtro_nome = /^[a-zA-Z\s]+[a-zA-Z]+$/;
	if (!filtro_nome.test(!document.getElementById("nome").value)) {
		alert("\n NOVARESE:\n Nome non valido\n\n Valide solo lettere e spazi\n\n Non può iniziare o terminare con lo spazio");
		document.getElementById("nome").focus();
		return false;
	}
	
	if (document.getElementById("posta").value!="") {
		// e-mail
		filtro_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
		if (!filtro_mail.test(document.getElementById("posta").value)) {
			alert("\n NOVARESE:\n Indirizzo E-mail non valido");
			document.getElementById("posta").style.backgroundColor="#FFFF99";
			document.getElementById("posta").style.color="#000";
			document.getElementById("posta").focus();
			return false;
		}	
	}	
	
	// data_nascita
	if (document.getElementById("data_nascita").value=="") {
		alert("\n NOVARESE:\n Data di nascita del viaggiatore?");
		document.getElementById("data_nascita").style.backgroundColor="#FFFF99";
		document.getElementById("data_nascita").style.color="#000";
		document.getElementById("data_nascita").focus();
		return false;
	}
	
	// data_viaggio
	if (document.getElementById("data_viaggio").value=="") {
		alert("\n NOVARESE:\n Data del viaggio?");
		document.getElementById("data_viaggio").style.backgroundColor="#FFFF99";
		document.getElementById("data_viaggio").style.color="#000";
		document.getElementById("data_viaggio").focus();
		return false;
	}
	

		if (document.getElementById("data_nascita").value.substring(2,3) != "/" ||
           document.getElementById("data_nascita").value.substring(5,6) != "/" ||
           isNaN(document.getElementById("data_nascita").value.substring(0,2)) ||
           isNaN(document.getElementById("data_nascita").value.substring(3,5)) ||
           isNaN(document.getElementById("data_nascita").value.substring(6,10))) {
             alert("Inserire data di nascita in formato gg/mm/aaaa");
              document.getElementById("data_nascita").focus();
              return false;
        }
        else if (document.getElementById("data_nascita").value.substring(0,2) > 31) {
           alert("DATA DI NASCITA /n Impossibile utilizzare un valore superiore a 31 per i giorni");
           document.getElementById("data_nascita").select();
           return false;
        }
        else if (document.getElementById("data_nascita").value.substring(3,5) > 12) {
           alert("DATA DI NASCITA /n Impossibile utilizzare un valore superiore a 12 per i mesi");
           document.getElementById("data_nascita").focus();
           return false;
        }
        else if (document.getElementById("data_nascita").value.substring(6,10) > 2010) {
           alert("DATA DI NASCITA /n Impossibile utilizzare un valore superiore a 2010 per l'anno");
           document.getElementById("data_nascita").focus();
           return false;
        }  



	if (document.getElementById("data_viaggio").value.substring(2,3) != "/" ||
           document.getElementById("data_viaggio").value.substring(5,6) != "/" ||
           isNaN(document.getElementById("data_viaggio").value.substring(0,2)) ||
           isNaN(document.getElementById("data_viaggio").value.substring(3,5)) ||
           isNaN(document.getElementById("data_viaggio").value.substring(6,10))) {
             alert("Inserire data di viaggio in formato gg/mm/aaaa");
	 		document.getElementById("data_viaggio").style.backgroundColor="#FFFF99";
			document.getElementById("data_viaggio").style.color="#000";
              document.getElementById("data_viaggio").focus();
              return false;
        }
        else if (document.getElementById("data_viaggio").value.substring(0,2) > 31) {
           alert("DATA VIAGGIO /n Impossibile utilizzare un valore superiore a 31 per i giorni");
			document.getElementById("data_viaggio").style.backgroundColor="#FFFF99";
			document.getElementById("data_viaggio").style.color="#000";
           document.getElementById("data_viaggio").select();
           return false;
        }
        else if (document.getElementById("data_viaggio").value.substring(3,5) > 12) {
           alert("DATA VIAGGIO /n Impossibile utilizzare un valore superiore a 12 per i mesi");
			document.getElementById("data_viaggio").style.backgroundColor="#FFFF99";
			document.getElementById("data_viaggio").style.color="#000";
           document.getElementById("data_viaggio").focus();
           return false;
        }
        else if (document.getElementById("data_viaggio").value.substring(6,10) < 2010) {
           alert("DATA VIAGGIO /n mpossibile utilizzare un valore inferiore a 2010 per l'anno");
			document.getElementById("data_viaggio").style.backgroundColor="#FFFF99";
			document.getElementById("data_viaggio").style.color="#000";
           document.getElementById("data_viaggio").focus();
           return false;
        }  
	
	
	
	/////////////////////////////////////////////////////////////////////////////
	//////////////////////////////////  DATA ////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////
	//controllo la data del viaggio
	//alert(date());
	today = new Date();
	
		anno_oggi=today.getFullYear();
		mese_oggi=today.getMonth()+1;
		if (mese_oggi<10) {mese_oggi="0"+mese_oggi;}
		giorno_oggi=today.getDate();
		if (giorno_oggi<10) {giorno_oggi="0"+giorno_oggi;}
	
	data_oggi_formattata=giorno_oggi+"/"+mese_oggi+"/"+anno_oggi;

	data_viaggio = document.getElementById("data_viaggio").value;
	//scompongo per calcolare i millisecondi e fare i conti per il week-end
	giorno_viaggio=data_viaggio.substring(0,2);
	//alert(giorno_viaggio);
	mese_viaggio=data_viaggio.substring(3,5);
	//alert(mese_viaggio);
	anno_viaggio=data_viaggio.substring(6,10);
	//alert(anno_viaggio);
	
	oggetto_data_viaggio =  new Date(anno_viaggio,mese_viaggio-1,giorno_viaggio);
	//alert("data_vaggio: "+oggetto_data_viaggio);
	var millisecondi_viaggio = oggetto_data_viaggio.getTime();
	//alert(millisecondi_viaggio);
		
	
	var millisecondi_oggi = today.getTime();
	//alert(millisecondi_oggi);
	var millisecondi_domani = millisecondi_oggi + (60*60*24*1000);
	var oggetto_data_domani = new Date(millisecondi_domani);
	//alert("domani: "+oggetto_data_domani);
	
	differenza_millisecondi=millisecondi_viaggio-millisecondi_oggi;
	//alert("differenza: "+(millisecondi_viaggio-millisecondi_oggi));
	ora_attuale=today.getHours();
	//alert("ora attuale: "+ora_attuale);
	giorno_della_settimana = today.getDay();
	
	giorno_della_settimana_viaggio = oggetto_data_viaggio.getDay();
	//alert("giorno della settimana: "+giorno_della_settimana_viaggio);
	

	//fine settimana dal 1° novembre
	oggetto_data_fine_servizio =  new Date(2010,10,1);
	//alert("data_fine: "+oggetto_data_fine_servizio);
	var millisecondi_fine_servizio = oggetto_data_fine_servizio.getTime();
	//alert("millisecondi viaggio: " + millisecondi_viaggio);
	//alert("millisecondi fine: " + millisecondi_fine_servizio);
	
	//alert("differenza: "+(millisecondi_viaggio-millisecondi_fine_servizio));
	
	//if ( (giorno_della_settimana_viaggio>0 && giorno_della_settimana_viaggio<6 ) && (millisecondi_viaggio-millisecondi_fine_servizio)>0 ) {
		//alert("A PARTIRE DAL 1° NOVEMBRE, \n è possibile prenotare SOLO per per il FINE SETTIMANA");
		//return false;	
	//}
	
	/*
	//controllo se è sabato e siamo dopo le 12
	if (giorno_della_settimana>5 && ora_attuale>=12 && differenza_millisecondi<(86400000*2)) {
		alert("è possibile prenotare solo per martedì o successivi");
		document.getElementById("data_viaggio").style.backgroundColor="#FFFF99";
		document.getElementById("data_viaggio").style.color="#000";
		document.getElementById("data_viaggio").focus();
		return false;
	}
	*/
	
}
//-->
