function validEmail(mail) {
		invalidChars = " /:,;"
			
		for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
				badChar = invalidChars.charAt(i)
				if (mail.indexOf(badChar,0) > -1) {
				return false
				}
		}
		atPos = mail.indexOf("@",1)			// there must be one "@" symbol
		if (atPos == -1) {
			return false
		}
		if (mail.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
			return false
		}
		periodPos = mail.indexOf(".",atPos)
		if (periodPos == -1) {					// and at least one "." after the "@"
			return false
		}
		if (periodPos+3 > mail.length)	{		// must be at least 2 characters after the "."
			return false
		}
		return true
}
function controlla(nomeForm) {
	var email = nomeForm.elements["email"].value;
	var nome = nomeForm.elements["nome"].value;
	var cognome = nomeForm.elements["cognome"].value;
	var note = nomeForm.elements["note"].value;
	
	nomeForm.elements["nome"].style.backgroundColor=''
	nomeForm.elements["cognome"].style.backgroundColor=''
	nomeForm.elements["email"].style.backgroundColor=''
	nomeForm.elements["note"].style.backgroundColor=''
	
	if (nome.length < 3) {
		alert("Attenzione, inserire il nome");
		nomeForm.elements["nome"].style.backgroundColor='FF5555'
		return false;
	}
	if (cognome.length < 3) {
		alert("Attenzione, inserire il cognome");
		nomeForm.elements["cognome"].style.backgroundColor='FF5555'
		return false;
	}

	if (!validEmail(nomeForm.email.value)) {
		alert("Attenzione, la mail inserita non è valida");
		nomeForm.elements["email"].style.backgroundColor='FF5555'
		return false;
	}
	
	if (note.length < 3) {
		alert("Attenzione, inserire le note");
		nomeForm.elements["note"].style.backgroundColor='FF5555'
		return false;
	}
	
	else {
		return true;
	}	
}