Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,4})$/;
function inviaModulo()
{
	var name 	= document.modulo.nome.value;
	var surname = document.modulo.cognome.value;
	var email 	= document.modulo.email.value;
	var email2 	= document.modulo.email2.value;
	var nomeCav = document.modulo.nomeCav.value;
	var categoria = document.modulo.categoria.value;
	var msg	 	= document.modulo.messaggio.value;
	var trattamentoDati = document.modulo.checkbox.checked;

	if ((name == "") || (name == "undefined")) {
           alert("Devi inserire il nome.");
           document.modulo.nome.focus();
           return false;
        }
		else if ((surname == "") || (surname == "undefined")) {
           alert("Devi inserire il cognome");
           document.modulo.cognome.focus();
           return false;
        }
		else if (email != email2){
           alert("Gli indirizzi E-mail non corrispondono");
           document.modulo.email.focus();
           return false;
        }
		else if (!Filtro.test(email)) {
      	alert("Indirizzo mail vuoto o non corretto.");
      	document.modulo.email.focus();
	  	return false;
		}
		else if ((nomeCav == "") || (nomeCav == "undefined")) {
           alert("Devi inserire il nome della struttura");
           document.modulo.nomeCav.focus();
           return false;
        }
		else if ((categoria == "") || (categoria == "undefined") || (categoria == "0")) {
           alert("Devi inserire la categoria");
           document.modulo.categoria.focus();
           return false;
        }
		else if ((msg == "") || (msg == "undefined") || (document.modulo.messaggio.value.length < "50")) {
           alert("Devi inserire il testo del messaggio (Almeno 50 caratteri)");
           document.modulo.messaggio.focus();
           return false;
        }
		else if (trattamentoDati==false) {
          alert ('Per proseguire. occorre concedere il trattamento dei dati personali.');
          document.modulo.checkbox.select();
          return false;
        }

		//INVIA
        else {
           	document.modulo.action = "inviaInserzioni.php";
           	document.modulo.submit();
        }
}
