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

	if ((name == "") || (name == "undefined")) {
           alert("Devi inserire il nome.");
           document.modulo_contatti.nome.focus();
           return false;
        }
		else if ((surname == "") || (surname == "undefined")) {
           alert("Devi inserire il cognome.");
           document.modulo_contatti.cognome.focus();
           return false;
        }
		else if ((msg == "") || (msg == "undefined")) {
           alert("Inserire il testo del messaggio.");
           document.modulo_contatti.messaggio.focus();
           return false;
        }
		else if (!Filtro.test(email)) {
      	alert("Indirizzo mail vuoto o non corretto.");
      	document.modulo_contatti.email.focus();
	  	return false;
		}
		else if (trattamentoDati==false) {
          alert ('Per proseguire. occorre concedere il trattamento dei dati personali.');
          document.modulo_contatti.checkbox.select();
          return false;
        }

		//INVIA
        else {
           	document.modulo_contatti.action = "inviaContatti.php";
           	document.modulo_contatti.submit();
        }
}

