function checkCR(evt) {
    var evt  = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
  }
document.onkeypress = checkCR;



function trim(stringa) {
		while (stringa.substring(0,1) == ' ') {
			stringa = stringa.substring(1, stringa.length);
		}
		while (stringa.substring(stringa.length-1, stringa.length) == ' ') {
			stringa = stringa.substring(0,stringa.length-1);
		}
	return stringa;
}



function Validator_iscrizione() {
	var email = document.getElementById("indirizzo_iscrizione").value;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
		alert("Inserire un indirizzo email corretto!!");
		document.getElementById("indirizzo_iscrizione").select();
	return false;
	}

document.iscrizione.submit();
}



function Validator_contattaci() {	
	var nome = trim(document.contattaci.nome.value);
	var cognome = trim(document.contattaci.cognome.value);
	var cellulare = trim(document.contattaci.cellulare.value);
	var email = trim(document.contattaci.email.value);
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
	if ((nome == "") || (nome == "undefined")) {
	   alert("I campi contrassegnati da * sono obbligatori!!");
	   document.contattaci.nome.focus();
	return false;
	}
	
	if ((cognome == "") || (cognome == "undefined")) {
	   alert("I campi contrassegnati da * sono obbligatori!!");
	   document.contattaci.cognome.focus();
	return false;
	}
	
	if ((cellulare == "") || (cellulare == "undefined")) {
	   alert("I campi contrassegnati da * sono obbligatori!!");
	   document.contattaci.cellulare.focus();
	return false;
	}
	
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
		alert("Inserire un indirizzo email corretto!!");
		document.contattaci.email.select();
	return false;
	}

return (true);
}



function Validator_consulenza() {
	var nome      = document.consulenza.nome.value;
	var cognome   = document.consulenza.cognome.value;
	var indirizzo = document.consulenza.indirizzo.value;
	var citta     = document.consulenza.citta.value;
	var email     = document.consulenza.email.value;
	var domanda   = document.consulenza.domanda.value;
	var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;

	if ((nome == "") || (nome == "undefined")) {
	   alert("Tutti i campi sono obbligatori!!");
		document.consulenza.nome.focus();
	return false;
	}
	
	if ((cognome == "") || (cognome == "undefined")) {
	   alert("Tutti i campi sono obbligatori!!");
		document.consulenza.cognome.focus();
	return false;
	}
	
	if ((indirizzo == "") || (indirizzo == "undefined")) {
	   alert("Tutti i campi sono obbligatori!!");
		document.consulenza.indirizzo.focus();
	return false;
	}
	
	if ((citta == "") || (citta == "undefined")) {
	   alert("Tutti i campi sono obbligatori!!");
		document.consulenza.citta.focus();
	return false;
	}
	
	if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) {
		alert("Inserire un indirizzo email corretto!!");
		document.consulenza.email.select();
	return false;
	}
	
	if ((domanda == "") || (domanda == "undefined")) {
	   alert("Tutti i campi sono obbligatori!!");
		document.consulenza.domanda.focus();
	return false;
	}

return true;
}