//overwrite methods of controls.js/prototype.js
if(Ajax.Autocompleter.prototype){

  //hide "go-button" when indicator is shown
  Ajax.Autocompleter.prototype.startIndicator = function() {
    //if ajax call has parameter option "indicatorRemove"
    if(this.options.indicatorRemove) Element.hide(this.options.indicatorRemove);
    if(this.options.indicator) Element.show(this.options.indicator);
  }

  //show "go-button" when indicator is hidden
  Ajax.Autocompleter.prototype.stopIndicator = function() {
    if(this.options.indicator) Element.hide(this.options.indicator);
    //if ajax call has parameter option "indicatorRemove"
    if(this.options.indicatorRemove) Element.show(this.options.indicatorRemove);
  }

    //PATCH PRE-SELECTING FIRST ENTRY
  Ajax.Autocompleter.prototype.updateChoices = function(choices) {
    if(!this.changed && this.hasFocus) {
      this.update.innerHTML = choices;
      Element.cleanWhitespace(this.update);
      Element.cleanWhitespace(this.update.down());

      if(this.update.firstChild && this.update.down().childNodes) {
        this.entryCount =
          this.update.down().childNodes.length;
        for (var i = 0; i < this.entryCount; i++) {
          var entry = this.getEntry(i);
          entry.autocompleteIndex = i;
          this.addObservers(entry);
        }
      } else {
        this.entryCount = 0;
      }

      this.stopIndicator();
      //PATCH: instead of this.index = 0;
      this.index = -1;

      if(this.entryCount==1 && this.options.autoSelect) {
        this.selectEntry();
        this.hide();
      } else {
        this.render();
      }
    }
  }

  //PATCH JUMPING PAGE in version 1.8.3 (alternative: http://www.gilluminate.com/2009/01/20/scriptaculous-autocomplete-page-jump-using-arrow-keys/)
  Ajax.Autocompleter.prototype.markPrevious = function() {
    if(this.index > 0) this.index--;
      else this.index = this.entryCount-1;
  }

  Ajax.Autocompleter.prototype.markNext = function() {
    if(this.index < this.entryCount-1) this.index++;
      else this.index = 0;
  }
  //END PATCH JUMPING PAGE

}

//PATCH transport.abort (flickering updating result) in controls.js (my_search) and prototype.js (function abort)