function servoCitta(stringa) {
  if (stringa.length > 1 && stringa != lastStringa) {
    if (typeof(servo) == 'undefined' || typeof(servo) == 'string') { servo = new ajax() }
    Scrivi('loading', 'caricamento...');
    servo.Carica('get','/ajax/servoCitta.asp?stringa=' + stringa, 'servoCitta_ok');
    }
  else {
    document.getElementById('listaComuni').style.display = 'none';
    Scrivi('loading', '');
    }
  lastStringa = stringa
  }
  
function servoCitta_ok() {
  var nomeComune = '';
  var elencoComuni = '';
  var i = 0;
  var nomeComune_value;

  
  if (lunghezza('c') == 0) {
    document.getElementById('listaComuni').style.display = 'none';
    Scrivi('loading', '');
    document.getElementById('idComune').value = ''
    return
    }
  
  if (lunghezza('c') == 1) {
    document.getElementById('comune_nome').value = LoadVal('c', 0).replace(/&#39/g, "'");
    document.getElementById('idComune').value = LoadAtt('c', 'id', 0);
    document.getElementById('listaComuni').style.display = 'none';
    Scrivi('loading', '');
    return
    }
    
  while ( i < parseFloat(lunghezza('c')) ) {
    nomeComune = LoadVal('c', i);
    nomeComune_value = LoadAtt('c', 'id', i);
    nomeProvincia = LoadAtt('c', 'p', i);
    elencoComuni = elencoComuni + '<div onclick="document.getElementById(\'idComune\').value = \'' + nomeComune_value + '\'; document.getElementById(\'comune_nome\').value = \'' + nomeComune.replace(/&#39/g, "\\'") + '\'; document.getElementById(\'listaComuni\').style.display = \'none\'; " style="cursor:pointer" onmouseover="this.style.background=\'#ececec\'" onmouseout="this.style.background=\'#ffffff\'">' + nomeComune + ' (' + nomeProvincia + ')</div>';
    i++
    }
    
  if (elencoComuni != '') {
    document.getElementById('listaComuni').style.display = 'block';
    document.getElementById('listaComuni').innerHTML = elencoComuni;
    Scrivi('loading', '')
    }
  else {
    document.getElementById('listaComuni').style.display = 'none';
    Scrivi('loading', '')
    }
  servo = ''
  }
  
var servo;
var lastStringa