function checkMail(datain){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(datain))
		testresults=true
	else{
		testresults=false
	}
	return (testresults)
}

function validate_form(obj){
	//Test Nome
	if (obj.nome.value=='') {
		messaggio("Nome");
		return false;
	}
	
	//Test Cognome
	if (obj.cognome.value=='') {
		messaggio("Cognome");
		return false;
	}

/*
	
	if(!test_carattere(obj.nocache_password)){
		alert("Password: Usare solo caratteri alfanumerici A-Z, a-z, 0-9");
		return false;
	}	

	//Test Indirizzo
	if (obj.indirizzo.value=='') {
		messaggio("Indirizzo");
		return false;
	}
	
*/

	//Test CAP
	if (obj.cap.value=='') {
		messaggio("C.A.P.");
		return false;
	}

	//Test Cittą
	if (obj.citta.value=='') {
		messaggio("Cittą");
		return false;
	}

	//Test Provincia
	if (obj.provincia.value=="-1") {
		messaggio("Provincia");
		return false;
	}	
	
	//Test Telefono
	if (obj.telefono.value=='') {
		messaggio("Telefono");
		return false;
	}

	//Test Descrizione		
	if (obj.descrizione.value=='') {
		messaggio("Descrizione");
		return false;
	}
		
	//Test Email
	ret = checkMail(obj.email.value);
	if(ret == false)
		alert("Inserire un indirizzo e-mail valido");
	return ret;
}

/*
	//Test Trattamento dati personali
	if(obj.accetto.checked!=true){
		alert ("Devi accettare il \"Trattamento dei dati\" prima di continuare");
		return false;
	}
*/
	
function messaggio(txt) {
	alert("Manca un campo necessario.\nRiempire il campo '"+txt+"'");
}	

/*
function test_carattere(variab){
	var good_chars = "abcdefghijklmnopqrstuvwxyz_1234567890";
	for (i=0; i < variab.value.length; i++) {	
		var caratt = variab.value.charAt(i);		
		var lowerCaratt = caratt.toLowerCase();
		if (good_chars.indexOf(lowerCaratt) == -1) {
			return false;
		}
	}
	return true;
}

*/
