 
  function closeList(listID)
  {
    lista = document.getElementById(listID);
    lista.style.display = "none";
  }
  
  
  function openList(listID)
  {
    closeList("listA");
    closeList("listD");
    closeList("listO");
    
    lista = document.getElementById(listID);
    lista.style.display = "block";
  }
  
  
  function trim(str)
  {
    s = new String(str);
    return s.replace(/^\s*|\s*$/g,"");
  }
  
  function check(val)
  {
    if(trim(val) == "")
    {
      return false;
    }
    return true;
  }
  
  function check_form()
  {
    f = document.contatti;

    if(!check(f.nome.value))
    {
      alert("Inserire il nome.");  
      return false;
    }
    
    if(!check(f.cognome.value))
    {
      alert("Inserire il cognome.");  
      return false;
    }
    
    if(!check(f.via.value))
    {
      alert("Inserire la via."); 
      return false;
    }
    
    if(!check(f.citta.value))
    {
      alert("Inserire la citta'."); 
      return false;
    }
    
    if(!check(f.prov.value))
    {
      alert("Inserire la provincia."); 
      return false;
    }
    
    if(!check(f.tel.value))
    {
      alert("Inserire il recapito telefonico."); 
      return false;
    }
    
    if((f.mail.value.indexOf("@")==-1) || (f.mail.value.indexOf(".")==-1))
    {
		  alert("Indirizzo E-mail non valido.");
		  return false;
	  }	
    
    if(!check(f.mex.value))
    {
      alert("Il campo messaggio è vuoto."); 
      return false;
    }
    
    if(!f.dati.checked)
    {
      alert("Selezionare la casella di consenso al trattamento dei dati."); 
      return false;
    }
    
    f.submit();
  }
  
  
  function showDistr(zona)
  {
    //nasconde tutte le zone
    for(var i=1; i<21; i++)
    {
      var Z = 'Z';
      if(i < 10)Z += '0';
      Z += String(i);
      
      distr = document.getElementById(Z);
      distr.style.display = "none";
    }
   
   //visualizza solo la zona selezionata
   distr = document.getElementById(zona);
   distr.style.display = "block";  
  }
  
  function openoverlay(ov)
    {
        document.getElementById(ov).style.display='block';
    }
  
  function closeoverlay(ov)
    {
        document.getElementById(ov).style.display='none';
    }