function initVenuePicker() {
  if (document.getElementById('venue.title') != null)
    {
  var lastValue;

  var selectVenue = function(venue) {
    document.getElementById("venue.id").value = venue.id;
    document.getElementById("venue.title").value = venue.alias;
    document.getElementById("venue.address").value = venue.address;
    document.getElementById("venue.postal-code").value = venue.postalCode;
    document.getElementById("venue.postal-area").value = venue.postalArea;
    document.getElementById("venue.email").value = venue.email;
    document.getElementById("venue.url").value = venue.url;
    document.getElementById("venue.telephone").value = venue.telephone;
    lastValue = venue.alias;
  }


  var combobox = new Combobox({inputId: "venue.title", data: [], onchange: selectVenue});
  var titleInput = document.getElementById("venue.title");

  var client;
  try {
      client = new ActiveXObject("Microsoft.XMLHTTP");    // Trying Internet Explorer
  } catch(e) {
      client = new XMLHttpRequest()
  }

  client.onreadystatechange = function() {
    if(client.readyState == 4 && client.status == 200) {
      // so far so good
      if(client.responseText != null) {
	// success!
	combobox.setData(eval('(' + client.responseText + ')'));
      } else {
	// No reply?
      }
    } else if (this.readyState == 4 && this.status != 200) {
      // fetched the wrong page or network error...
    }
  }

  client.open("GET", "last-10-venue-alias.ajax", true);
  client.send(null);

  titleInput.onkeyup = function() {
      if (titleInput.value.length >= 2 && titleInput.value != lastValue) {
	lastValue = titleInput.value;
      var client;
      try {
	client = new ActiveXObject("Microsoft.XMLHTTP");    // Trying Internet Explorer
      } catch(e) {
	client = new XMLHttpRequest()
      }

      client.onreadystatechange = function() {
	if(client.readyState == 4 && client.status == 200) {
	  // so far so good
	  if(client.responseText != null) {
	    // success!
	    liste = eval('(' + client.responseText + ')');
	    if (liste.length > 0 ) {
	      combobox.setData(liste);
	      combobox.show();
	    } else {
	      combobox.hide();
	    }
	  } else {
	    // No reply?
	  }
	} else if (this.readyState == 4 && this.status != 200) {
	  // fetched the wrong page or network error...
	}
      }

      client.open("GET", "search-venue-alias.ajax?title=" + encodeURI('%' + titleInput.value + '%'), true);
      client.send(null);
    }
  }
}
}

