function emailValidation(frm){
	var esito = true;
	var Lang = frm.ver.value;

	with (frm.txtMail){

		if (value.length > 0){
			apos=value.indexOf("@"); 
			dotpos=value.lastIndexOf(".");
			lastpos=value.length-1;
			spacepos=value.indexOf(" ");
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2 || spacepos>-1) {		
				esito = false;
			}
		}
	}

	if (esito==false)
	{
			if (Lang=="it") alert("Indirizzo e-mail non valido");
			if (Lang=="en") alert("E-mail address not valid");
	}

	return esito
}

function ValidateFeedback() {
	
		var errore1;
		var errore2;
		var errore3;
		var errore4;
		var errori;
		var Lang;
		
		with (document.frmFeedback) {
		Lang = ver.value;
		errore1 = (txtNominativo.value.length < 3);
		errore2 = (txtMail.value.length < 6);
		errore3 = (txtMessaggio.value.length < 1);
		errore4 = (selDestinatario.value == 'none');
		errore5 = (txtTelefono.value.length < 6);
		
		if (errore1) {
			switch (Lang) {
				case "it": alert("E' necessario compilare correttamente il campo Nome e cognome"); break;
				case "en": alert("It is necessary to correctly fill out Full name field"); break;
			}
			txtNominativo.focus();
			return(false);
		}
	
		else if (errore2) {
			switch (Lang) {
				case "it": alert("E' necessario compilare correttamente il campo e-mail"); break;
				case "en": alert("It is necessary to correctly fill out e-mail field"); break;
			}
			txtMail.focus();
			return(false);
		}
		
		else if (errore5) {
			switch (Lang) {
				case "it": alert("E' necessario compilare correttamente il campo Telefono"); break;
				case "en": alert("It is necessary to correctly fill out Phone field"); break;
			}
			txtTelefono.focus();
			return(false);
		}		
		
		else if (errore3) {
			switch (Lang) {
				case "it": alert("E' necessario specifiacare il destinatario"); break;
				case "en": alert("It is necessary to correctly fill out Message field"); break;
			}
			txtMessaggio.focus();
			return(false);
		}
		
		else if (errore4) {
			switch (Lang) {
				case "it": alert("E' necessario compilare correttamente il campo Scrivi a"); break;
				case "en": alert("It is necessary to correctly fill out Write to field"); break;
			}
			selDestinatario.focus();
			return(false);
		}
	
	}
	var errori = (errore1 || errore2 || errore3 || errore4);
	return emailValidation(document.frmFeedback) && (! errori) && checkSpam(document.frmFeedback);
}

function checkSpam(frm){
	var check_form = true;
   var EmailAddr = frm.txtMail.value;
   var Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (!Filtro.test(EmailAddr)) { check_form=false }	
   var Utente = frm.txtNominativo.value;	
	Filtro = /^([a-zA-Z0-9_\s\'\’\´\à\ä\è\é\ê\á\ñ\ù\ú\û\ü\ò\ó\ì\ô\ç\À\Á\Â\Ã\Ç\È\É\Ê\Ò\Ö\Ô\Ó\Ü\Û\Ñ])+$/;	
   if (!Filtro.test(Utente)) { check_form=false }
	
	if (frm.txtMessaggio.value.length > 0) {
	   var Messaggio = frm.txtMessaggio.value;	
		Filtro = /^([a-zA-Z0-9_\.\-\s\Ø\%\'\"\|\´\’\–\?\!\+\=\(\)\[\]\*\°\¼\½\¾\±\®\©\£\$\€\à\ä\è\é\ê\á\ñ\ù\ú\û\ü\ò\ó\ì\ô\ç\;\:\,\À\Á\Â\Ã\Ç\È\É\Ê\Ò\Ö\Ô\Ó\Ü\Û\Ñ\“\”\/])+$/;
   	if (!Filtro.test(Messaggio)) { check_form=false }  	 	
	}		
	return check_form;
}

