function isEmail(str) {
  var supported=0;
  
  if (window.RegExp) {
   var tempStr = "a";
   var tempReg = new RegExp(tempStr);
   if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
   return (str.indexOf(".")>2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
 }  
	

function Login(){
		if (document.login.email.value=="") {
			alert("Inserisci l'indirizzo E-mail!!")
			document.login.email.focus()
		return false }
		if (document.login.pass.value=="") {
			alert("Inserisci la tua password!!")
			document.login.pass.focus()
		return false }
	}
		
function ricerca(){
		if (document.ric.citta.value=="0") {
			alert("Select the City!!")
			document.ric.citta.focus()
		return false }
	}
	
function cercahome(){
		if (document.ch.id.value=="") {
			alert("Select the type!!")
			document.ch.id.focus()
		return false }
		if (document.ch.prov.value=="0") {
			alert("Select the Province!!")
			document.ch.prov.focus()
		return false }
		if (document.ch.citta.value=="0") {
			alert("Select the City!!")
			document.ch.citta.focus()
		return false }
	}	
	
function contatto(){
		if (document.cont.nome.value=="") {
			alert("Insert name and last name!!")
			document.cont.nome.focus()
		return false }
		if (document.cont.email.value=="") {
			alert("Insert email address!!")
			document.cont.email.focus()
		return false }
		if (document.cont.messaggio.value=="") {
			alert("Insert your message!!")
			document.cont.messaggio.focus()
		return false }
		if (!document.cont.privacy.checked) {
        alert("Approve the privacy!!");
        return (false) }
}

function richiesta(){
		if (document.rica.nome.value=="") {
			alert("Insert name and last name!!")
			document.rica.nome.focus()
		return false }
        if (document.rica.email.value=="") {
			alert("Insert email address!!")
			document.rica.email.focus()
		return false }
		if (document.rica.telefono.value=="") {
			alert("Insert telephone number!!")
			document.rica.telefono.focus()
		return false }
		if (document.rica.citta.value=="") {
			alert("Insert the city!!")
			document.rica.citta.focus()
		return false }
		
		if (document.rica.arrivo.value=="") {
			alert("Insert date of arrival!!")
			document.rica.arrivo.focus()
		return false }
		if (document.rica.partenza.value=="") {
			alert("Insert date of departure!!")
			document.rica.partenza.focus()
		return false }
		if (document.rica.adulti.value=="") {
			alert("Insert number of Guest!!")
			document.rica.adulti.focus()
		return false }
		if (document.rica.bambini.value=="") {
			alert("Insert number of children!!")
			document.rica.bambini.focus()
		return false }
		if (document.rica.messaggio.value=="") {
			alert("Insert your message!!")
			document.rica.messaggio.focus()
		return false }
		if (!document.rica.privacy.checked) {
     alert("Approve privacy!!");
     return (false) }
	 
	 var data_iniziale = document.rica.arrivo.value
	 var data_finale = document.rica.partenza.value
	 var arr1 = data_iniziale.split("/")
	 var arr2 = data_finale.split("/")
	 var d1 = new Date(arr1[2],arr1[1]-1,arr1[0])
	 var d2 = new Date(arr2[2],arr2[1]-1,arr2[0])
	 var r1 = d1.getTime();
	 var r2 = d2.getTime();
	   if (r1>r2) { 
		alert("The date of arrival is following to that of departure!!")
		document.rica.arrivo.focus()
		return false }
	   }