// Copyright (c) 2005 ABAS Software AG
// Extensions to scriptaculous
// DWR Autocompleter
Autocompleter.DWR = Class.create();
 Object.extend(Object.extend(Autocompleter.DWR.prototype, Autocompleter.Base.prototype), {
  initialize: function(element, update, dwrCall, options) {
this.baseInitialize(element, update, options);
    this.options.onComplete    = this.onComplete.bind(this);
    this.dwrCall               = dwrCall;
  },
  getUpdatedChoices: function() {
    entry = encodeURIComponent(this.options.paramName) + '=' +
      encodeURIComponent(this.getToken());
    this.options.parameters = this.options.callback ?
      this.options.callback(this.element, entry) : entry;
    if(this.options.defaultParams)
      this.options.parameters += '&' + this.options.defaultParams;
    this.dwrCall(this.options.parameters, this.options.onComplete);
  },
onComplete: function(result) {
this.updateChoices(result);
}
});

