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");	
		if (Lang=="fr") alert("Adresse e-mail pas valide");		
		if (Lang=="de") alert("E-mail unzulässig");	
		if (Lang=="es") alert("Correo e-mail inválido");		
	}
	return esito
}

function ValidateFeedback(){
var Lang = frmFeedback.ver.value;

	with (document.frmFeedback) {
		var errori = (txtNominativo.value.length < 3 ||
					  txtMail.value.length < 6 ||
					  txtMessaggio.value.length < 1);
	}
	
	if (errori)
	{
		if (Lang=="it") alert("E' necessario compilare correttamente i dati richiesti");
		if (Lang=="en") alert("It is necessary to correctly fill out the requested data");
		if (Lang=="fr") alert("Il est nécessaire de remplir correctement les champs demandés ");
		if (Lang=="de") alert("Es ist notwendig, die verlangten Daten korrekt einzutragen");
		if (Lang=="es") alert("Es necesario rellenar correctamente los campos que se piden");
	}
	return emailValidation(frmFeedback) && (! errori);
}

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 esistita
		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))));

			  if ( resto==0 || (resto1!=0 && resto2==0)) {
				if (!(g <= 29)) esito = false;
			  } 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");}
	}
return esito;
}

function PopUpPhoto(id,w,h,lang){
	hh = h+85;
	ww = w+20;
	var win2 = window.open('photo.asp?id=' + id + '&ver='+ lang,"PopUpPhoto","toolbar=no,directories=no,menubar=0,scrollbars=0,width="+ww+",height="+hh+",top=50,left=50");
	win2.focus();
}

function NewWindow(oggetto,w,h,scroll){
	var win2 = window.open(oggetto,"NewWindow","status=0,resizable=0,toolbar=no,directories=no,menubar=0,scrollbars="+scroll+",width="+w+",height="+h+",top=50,left=50")
}

