function formSubmit(){
	var firstName		= document.getElementById("nome");
	var lastName		= document.getElementById("cognome");
	var guests			= document.getElementById("guests");
	var email	 		= document.getElementById("email");
	var from			= document.getElementById("anno1").value+document.getElementById("mese1").value+document.getElementById("giorno1").value;
	var to				= document.getElementById("anno2").value+document.getElementById("mese2").value+document.getElementById("giorno2").value;

	var email_reg_exp 	= /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	var colorKO			= "#FFAD00";
	
	if (firstName.value == "" || firstName.value == "undefined"){
		alert ("Field NAME is empty");
		firstName.style.backgroundColor = colorKO;
		firstName.focus();
	}
	else if (lastName.value == "" || lastName.value == "undefined"){
		alert ("Field SURNAME is empty");
		lastName.style.backgroundColor = colorKO;
		lastName.focus();
	}
	else if (email.value == "" || email.value == "undefined"){
		alert("Field EMAIL is empty");
		email.style.backgroundColor = colorKO;
		email.focus();
	}
	else if (email.value != "" && !email_reg_exp.test(email.value)){
		alert("Field EMAIL is not correct");
		email.style.backgroundColor = colorKO;
		email.value = '';
		email.focus();
	}
	else if (guests.value == "" || guests.value == "undefined"){
		alert ("Field NUMBER OF GUESTS is empty");
		guests.style.backgroundColor = colorKO;
		guests.focus();
	}
	else if (to < from){
		alert ("ARRIVAL DATE have to be follow DEPARTURE DATE");
		giorno1.style.backgroundColor = colorKO;
		giorno1.focus();
	}

	else{
		//document.getElementById("contatti").action = "form.php";
		document.getElementById("contatti").submit();
	}
}


function formReset(){
	document.contatti.firm.value 		= "";
	document.contatti.firstName.value 	= "";
	document.contatti.lastName.value 	= "";
	document.contatti.phone.value 		= "";
	document.contatti.email.value 		= "";
	document.contatti.note.value 		= "";
	document.contatti.privacy.checked 	= false;
	document.contatti.firstName.focus();
}


function colorOK(field){
	var colorOK	= "#FFFFFF";
	if (field == "nome")
		document.getElementById("nome").style.backgroundColor 	= colorOK;
	if (field == "cognome")
		document.getElementById("cognome").style.backgroundColor 	= colorOK;
	if (field == "guests")
		document.getElementById("guests").style.backgroundColor		= colorOK;
	if (field == "email")
		document.getElementById("email").style.backgroundColor 		= colorOK;
}