function DateValidation(frm){
var esito=true;
with (frm){
	//se non inserisco alcuna data il form viene validato comunque
	if (selGG.value == "none" && selMM.value == "none" && selAA.value == "none" ) {
		esito=true;
	}
	else {
		esito = true;
		// se inserisco una data in cui mancano il giorno o il mese o l'anno il form non viene validato
		if (selGG.value == "none" || selMM.value == "none" || selAA.value == "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(selGG.value);
			m=eval(selMM.value);
			y=eval(selAA.value);
			
			if (g > monthDays[m-1]) {
				esito=false
			}
			if(m == 2) {
			  esito = true;
			  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) {
			alert("Data non valida");
			selGG.focus();
		}

	}
}
return esito;
}


function emailValidation(frm){
var esito = true;
with (frm){
 	if (txtMail.value.length > 0){
		apos = txtMail.value.indexOf("@"); 
		dotpos = txtMail.value.lastIndexOf(".");
		lastpos = txtMail.value.length-1;
		spacepos = txtMail.value.indexOf(" ");
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2 || spacepos>-1) {
			esito = false;
			alert("Indirizzo e-mail non valido");
			txtMail.focus();
		}
	}
}
return esito
}

function NewWindow(oggetto,w,h,scroll){
	var win2 = window.open(oggetto,"NewWindow","toolbar=no,location=no,status=no,menubar=no,scrollbars="+scroll+",width="+w+",height="+h+",top=50,left=50,resizable=yes")
	win2.focus()
}

function LoginValidation(frm){
var errori=false;

	with (frm){
		if (txtMail.value == "" || txtPassword.value == "") {
		errori=true;
		}
	}
return (! errori);
}
