function Valida()
{
var campi=new Array('txNome','txCognome','txCitta','txTel');
var check;
if(checkPiva()){
if(checkPrivacy()){
if(checkCondizioni()){
if(isValidEmail()){
for(var i=0;i<campi.length;i++){
check = document.getElementById(campi[i]);


  //name field
    if (check.value == "" || check.value == null || check.value.charAt(0) == ' ')
    {
    alert( campi[i].slice(2)+" non valido");

    return false;
    }

   }
   return true;
   }
}
} 
}
return false;

}
function checkPiva(){
var p=document.getElementById('txPartitaIVA').value;

if(p.length!=11){
alert("Partita IVA non valida. Deve essere di 11 caratteri.");
return false;
}
else{return true;}
}
function checkPrivacy(){
if(document.getElementById('cbPrivacy').checked==false){
alert("E' necessario acconsentire al trattamento dei dati personali per effettuare il download");
return false;
}
else{return true;}
}
function checkCondizioni(){
if(document.getElementById('cbCondizioni').checked==false){
alert("E' necessario accettare le condizioni di servizio per effettuare il download");
return false;
}
else{return true;}
}

//function to check valid email address
function isValidEmail(){
  validRegExp = /^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/;
  strEmail = document.getElementById('txMail').value;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('Indirizzo E-Mail non valido');
      return false;
    } 
    return true; 
}
