function emailValidation(frm) {
var esito = true;
var Lang = frm.ver.value;

   var EmailAddr = frm.txtMail.value;
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   if (!Filtro.test(EmailAddr))
		{
		esito = false;
		alert(Locale("Indirizzo e-mail non valido","E-mail address not valid","Adresse email pas valide","E-mail unzulässig","Correo electrónico no válida","Correu electrònic no vàlida","E-post inte giltig",Lang));
		frm.txtMail.focus();
      }
	return esito		
}

function Locale(str1,str2,str3,str4,str5,str6,str7,lng) {
var Loc;
	switch (lng) {
		case "it": Loc = str1; break;
		case "en": Loc = str2; break;
		case "fr": Loc = str3; break;
		case "de": Loc = str4; break;
		case "es": Loc = str5; break;
		case "ca": Loc = str6; break;
		case "se": Loc = str7; break;		
	}
	return Loc;
}


function DataValida(gg,mm,aa,Lang){
var esito=true;
	
	//se non inserisco alcun valore la data non viene validata
	if (gg == "none" && mm == "none" && aa == "none" ) {
		esito=false;
	}
	else {
		esito = true;
		// se inserisco una data in cui mancano il giorno o il mese o l'anno il form non viene validato
		if (gg == "none" || mm == "none" || aa == "none" ) {
			esito = false;
		}
		//se ho inserito tutti i valori della data, verifico che questa esista
		else {
			var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);    
			g=eval(gg);
			m=eval(mm);
			y=eval(aa);
			
			if (g > monthDays[m-1]) {
				esito=false
			}
			if(m == 2) {
			  var resto = (y-(400*(parseInt(y/400))));
			  var resto1 = (y-(100*(parseInt(y/100))));
			  var resto2 = (y-(4*(parseInt(y/4))));

			  /* verifico che l'anno sia bisestile */
			  if (((resto2 == 0) && (resto1 != 0)) || (resto == 0)) {
					if (g <= 29) esito = true;
			  } else if (g > 28) esito = false;

			}		
		}
	}

	if (esito==false) {
		if (Lang=="it") {alert("Data non valida");}
		if (Lang=="en") {alert("Date not valid");}
		if (Lang=="fr") {alert("Date pas valide");}
		if (Lang=="de") {alert("Datum unzulässig");}
		if (Lang=="es") {alert("Fecha no válida");}
		if (Lang=="ca") {alert("Data no vàlida");}
		if (Lang=="se") {alert("Ogiltigt datum");}		
	}
return esito;
}

function NewWindow(oggetto,w,h,scroll){
	var win2 = window.open(oggetto,"NewWindow","toolbar=no,directories=no,menubar=0,scrollbars="+scroll+",width="+w+",height="+h+",top=50,left=50")
}

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;
}

