	
// MSe: 13.05.2008
// MKa: 23.05.2008

var nm_Autocompleter = Class.create(Ajax.Autocompleter,{
	
	markPrevious: function() {
	    if(this.index > 0) this.index--;
	      else this.index = this.entryCount-1;
	    //this.getEntry(this.index).scrollIntoView(true);
  	},
	


        updateChoices: function($super, choices) {
            this.stopIndicator();
            $super(choices);
        },

	getUpdatedChoices: function() {
	    this.startIndicator();

	    var 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;

	    if(this.options.filterName != 'undefined' && this.options.filterName != null && this.options.filterName != ''){
		this.options.parameters += '&' + this.options.filterName + '=' + document.getElementsByName(this.options.filterName)[0].value; 
	    }

	    new Ajax.Request(this.url, this.options);
	  },


	updateElement: function($super, selectedElement) {
  		if (selectedElement.style.display == "none"){
  			document.getElementById(this.options.formID).submit();
  		}
  		else {
  		if (this.options.actionSelectURL != null)
		{	
		var thisChild = selectedElement.firstChild;
			
			var param = "&";
			if (this.options.actionSelectURL.indexOf("?")==-1){
				var param = "?";
			}
				while ( thisChild != selectedElement.lastChild )
				{
					for (var key in this.options.actionSelectParamByID) {
						if ( thisChild.id == this.options.actionSelectParamByID[key] ){
							param = param + key + "=" + thisChild.title;
						};
					};
					thisChild = thisChild.nextSibling;
				}
				window.location.href = this.options.actionSelectURL + param;
			}
		 else {
		 
			$super(selectedElement);
		}
		}
  	}
});

var nm_Autocompleter_local = Class.create(Autocompleter.Local,{
	
	
	markPrevious: function() {
	    if(this.index > 0) this.index--;
	      else this.index = this.entryCount-1;
	    //this.getEntry(this.index).scrollIntoView(true);
  	}
	
});