var nameHint = nameHint || '';  // this var should have been set in /javascript/LocationsList, but we'll make sure here
Event.addBehavior({
  "#ftl:focus" : function(e) {
    if (this.value === nameHint) {
      this.clear();
    }
  },
  "#ftl:blur" : function(e) {
	if (this.value === '') {
	  this.value = nameHint;
	}
  }
});
Event.onReady(function() {
  var ftl = $('ftl');
  if (ftl.value === '') {
    ftl.value = nameHint;
  };
  new Autocompleter.Local(
    "ftl", 
    "namecomplete", 
    LocationsList,
    {
      choices: LocationsList.length,
      fullSearch: true,
	  minChars:3,
	  partialChars: 3,
      afterUpdateElement : function (input, li) { 
        input.addClassName('set'); 
      }
	  ,onShow: (typeof showAutocomplete !== 'undefined') ? showAutocomplete : null
    }
  );
}); // Event.onReady(function())

function doDestinationSearch(frm) {
	frm.target = "_blank";
	return true;
}
function showAutocomplete(element, update) {
    if(!update.style.position || update.style.position=='absolute') {
      update.style.position = 'absolute';
	  /*
      Position.clone(element, update, {
        setHeight: false
      });
	  */
    }
    //Effect.Appear(update,{duration:0.15});
    update.setStyle({'display':'block'});
    update.scrollTop = 0;
}