// Controllo modulo


function controlla(f) {

var Cognome, Nome, Email, Via, Cap, Citta, Telefono, Email, Adulti, numerotipologie, daAnno, daGiorno, daMese, alAnno, alGiorno, alMese, Consenso;



Cognome=f.elements['cognome'].value;
Nome=f.elements['nome'].value;
Via=f.elements['via'].value;
Citta=f.elements['citta'].value;
Cap=f.elements['cap'].value;
Telefono=f.elements['telefono'].value;
Email=f.elements['email'].value;
Adulti=f.elements['adulti'].value;

 Damese=f.elements['damese'].value - 0;
  Almese=f.elements['almese'].value - 0;
  Dagiorno=f.elements['dagiorno'].value - 0;
  Algiorno=f.elements['algiorno'].value - 0;

numerotipologie=f.elements['tipo'].length;
numerotipoaccetto=f.elements['tipoaccetto'].length;



if ((Cognome.length<1)) {
   alert ('Il cognome è obbligatorio! Surname is required!')
   return false;

}

if ((Nome.length<1)) {
   alert ('Il nome è obbligatorio! First Name is required!')
   return false;

}

if ((Via.length<1)) {
   alert ('La Via è obbligatoria! Adress is required!')
   return false;

}

if ((Citta.length<1)) {
   alert ('La citta è obbligatoria! Town is required!')
   return false;

}

if ((Cap.length<1)) {
   alert ('Il cap è obbligatorio! Post Code is required!')
   return false;

}

if ((Email.length<1)) {
   alert ('L\'email è obbligatoria! Email is required!')
   return false;

}


if ((Citta.length<1)) {
   alert ('Il nome è obbligatorio! Name is required!')
   return false;

}

if ((Telefono.length<1)) {
   alert ('Il telefono/Cellulare è obbligatorio! Phone / Mobil phone is required!')
   return false;

}


//inizio controllo email
	if ((Email.length<6)) {
      alert ('Email errata! Email error!')
      return false;
	}
	if (!((navigator.appName=='Netscape') && (navigator.appVersion.split(' ')[0]<5))) {
		result=Email.match(/^[\w_-]+(\.[\w_-]+)*@[\w_-]+(\.[\w_-]+)*\.[a-z]{2,4}$/)
		   if ((result==null) || (!(result[0].length==Email.length))) {
         		alert("Errore Email! Email error!");
         		return false;
       		}
	}
//Fine controllo email

if (Damese>Almese) 
     {
        alert ('Mese di prenotazione/richiesta errato! \n Month of reservation information error!');
        return false;
     }
  
    
  if (Damese==Almese)
  	{
        if (Dagiorno > Algiorno)
           {         
             alert ('Data di prenotazione/richiesta errata! \n Date of reservation/information error!');
             return false;
           } 
   }
//fine controllo date



var tipologiachecked;
tipologiachecked=false;
for (var scorri=0; scorri<numerotipologie; scorri++) {

	if (f.elements['tipo'][scorri].checked) {
	   tipologiachecked=true;
	}

}

if (!tipologiachecked) {
   alert('Scegliere la tipologia! \n Type of Typology is required!');
   return false;
}   

if ((Adulti.length<1)) {
   alert ('Il numero di persone è necessario! Number of persons is required!')
   return false;

}


if(!(Consenso=f.elements['consenso'].checked==true)){
  alert ('Necessario dare il consenso al trattamento dei dati!')
         return false;
      }
var tipoaccettochecked;
tipoaccettochecked=false;
for (var scorri1=0; scorri1<numerotipoaccetto; scorri1++) {
	if (f.elements['tipoaccetto'][scorri1].checked) {
	   tipoaccettochecked=true;
	}

}

if (!tipoaccettochecked) {
   alert('Necessario scegliere tra SI e NO per l\'invio di informative su tariffe/offerte!');
      return false;
} 

return true; 
}

