Autocompleter.SelectBox=Class.create();Autocompleter.SelectBox.prototype=Object.extend(new Autocompleter.Base(),{initialize:function(h,l){this.element='<input type="text" id="'+$(h).id+'_combo" style="display:none"/>';this.select=$(h);this.selectOptions=[];this.oldSelectWidth=(this.select).getWidth()+"px";
new Insertion.Before(h,this.element);var j=Element.classNames(h);j.each(function(a){Element.addClassName($(h).id+"_combo",a);});this.update='<div id="'+$(h).id+'_options" class="autocomplete"></div>';new Insertion.Before(h,this.update);this.select_id=$(h).id+"_combo";this.select_opt=$(h).id+"_options";
this.baseInitialize(this.select_id,this.select_opt,l);$(this.element.id).setAttribute("readonly","readonly");this.element.readOnly=true;if(this.options.debug){alert("input "+this.element.id+" and div "+this.update.id+" created, Autocompleter.Base() initialized");}if(!this.options.debug){Element.hide(h);
}var k=$(this.select).getElementsByTagName("option");var m=$A(k);for(i=0;i<m.length;i++){this.selectOptions.push('<li id="'+m[i].value+'">'+m[i].innerHTML+"</li>");if(m[i].getAttribute("selected")){this.element.value=m[i].innerHTML;}if(this.options.debug){alert("option "+m[i].innerHTML+" added to "+this.update.id);
}}Event.observe(this.element,"click",this.activate.bindAsEventListener(this));if($(h).selectedIndex>=0){this.element.value=$(h).options[$(h).selectedIndex].innerHTML;}var g=this;this.options.afterUpdateElement=function(a,e){var b=$(h).getElementsByTagName("option");var d=$A(b);var c=d.find(function(f){return(f.value==e.id);
});$(h).selectedIndex=c.index;$(g.select_id).value=e.innerHTML;if(g.options.redirect){document.location.href=c.value;}if(g.options.onClick){g.options.onClick();}if(g.options.autoSubmit){$(g.options.autoSubmit).submit();}};$(this.select_id).setStyle({display:"block",width:this.oldSelectWidth});},getUpdatedChoices:function(){this.updateChoices(this.setValues());
},setValues:function(){return("<ul>"+this.selectOptions.join("")+"</ul>");},setOptions:function(b){this.options=Object.extend({redirect:false,debug:false,onClick:false,autoSubmit:""},b||{});}});var TestLoader=Class.create();TestLoader.prototype={initialize:function(c,d){this.dialog=$(c);this.options=$(d);
new Autocompleter.SelectBox(d,{debug:false,onClick:this.run.bind(this)});},run:function(){(this.dialog).update(this.options[this.options.selectedIndex].innerHTML+" was clicked");}};