Ajax.CachedAutocompleter = Class.create();
    Object.extend(Object.extend(Ajax.CachedAutocompleter.prototype, Autocompleter.Base.prototype), {
      initialize: function(element, update, url, options) {
        this.baseInitialize(element, update, options);
        this.options.asynchronous  = true;
        this.options.onComplete    = this.onComplete.bind(this);
        this.options.defaultParams = this.options.parameters || null;
        this.url                   = url;
        this.cache                 = {};
      },
 
      getUpdatedChoices: function() {
        var t = this.getToken();
        if(this.cache[t]) {
            this.updateChoices(this.cache[t]);
        } else {
            entry = encodeURIComponent(this.options.paramName) + '=' + 
              encodeURIComponent(t);
 
            this.options.parameters = this.options.callback ?
              this.options.callback(this.element, entry) : entry;
 
            if(this.options.defaultParams) 
              this.options.parameters += '&' + this.options.defaultParams;
 
 			new Ajax.Request(this.url, this.options);
        }
      },
      onComplete: function(request) {
        this.updateChoices(this.cache[this.getToken()] = request.responseText);
      }
    }); 

document.observe('dom:loaded', function() {
new Insertion.After('swords', ' <div id="AutocompleteChoices" class="tx-winterproducts-pi1-autocompletecontainer"></div>');
new Ajax.CachedAutocompleter('swords', 'AutocompleteChoices', 'index.php?eID=winterproducts_autocomplete&lang='+document.getElementById('tx_winterproducts_pi1[lang]').value, {
	paramName: 'swords',
	method: 'get',
    minChars: 3
});
});
