function AutoSuggestControl(oTextbox,oProvider){this.cur=-1;this.layer=null;this.provider=oProvider;this.textbox=oTextbox;this.timeoutId=null;this.userText=oTextbox.value;this.init();} AutoSuggestControl.prototype.autosuggest=function(aSuggestions,bTypeAhead){this.cur=-1;if(aSuggestions.length>0){if(bTypeAhead){this.typeAhead(aSuggestions[0]);} this.showSuggestions(aSuggestions);}else{this.hideSuggestions();}};AutoSuggestControl.prototype.createDropDown=function(){this.layer=document.createElement("div");this.layer.className="suggestions";this.layer.style.visibility="hidden";this.layer.style.width=this.textbox.offsetWidth;document.body.appendChild(this.layer);var oThis=this;this.layer.onmousedown=this.layer.onmouseup=this.layer.onmouseover=function(oEvent){oEvent=oEvent||window.event;oTarget=oEvent.target||oEvent.srcElement;if(oEvent.type=="mousedown"){oThis.textbox.value=oTarget.firstChild.nodeValue;oThis.hideSuggestions();}else if(oEvent.type=="mouseover"){oThis.highlightSuggestion(oTarget);}else{oThis.textbox.focus();}};};AutoSuggestControl.prototype.getLeft=function(){var oNode=this.textbox;var iLeft=0;while(oNode.tagName!="BODY"){iLeft+=oNode.offsetLeft;oNode=oNode.offsetParent;} return iLeft;};AutoSuggestControl.prototype.getTop=function(){var oNode=this.textbox;var iTop=0;while(oNode.tagName!="BODY"){iTop+=oNode.offsetTop;oNode=oNode.offsetParent;} return iTop;};AutoSuggestControl.prototype.goToSuggestion=function(iDiff){var cSuggestionNodes=this.layer.childNodes;if(cSuggestionNodes.length>0){var oNode=null;if(iDiff>0){if(this.cur0){oNode=cSuggestionNodes[--this.cur];}} if(oNode){this.highlightSuggestion(oNode);this.textbox.value=oNode.firstChild.nodeValue;}}};AutoSuggestControl.prototype.handleKeyDown=function(oEvent){switch(oEvent.keyCode){case 38:this.goToSuggestion(-1);break;case 40:this.goToSuggestion(1);break;case 27:this.textbox.value=this.userText;this.selectRange(this.userText.length,0);case 13:this.hideSuggestions();oEvent.returnValue=false;if(oEvent.preventDefault){oEvent.preventDefault();} break;}};AutoSuggestControl.prototype.handleKeyUp=function(oEvent){var iKeyCode=oEvent.keyCode;var oThis=this;this.userText=this.textbox.value;clearTimeout(this.timeoutId);if(iKeyCode==8||iKeyCode==46){this.timeoutId=setTimeout(function(){oThis.provider.requestSuggestions(oThis,false);},850);}else if(iKeyCode<32||(iKeyCode>=33&&iKeyCode<46)||(iKeyCode>=112&&iKeyCode<=123)){}else{this.timeoutId=setTimeout(function(){oThis.provider.requestSuggestions(oThis,true);},250);}};AutoSuggestControl.prototype.hideSuggestions=function(){this.layer.style.visibility="hidden";};AutoSuggestControl.prototype.highlightSuggestion=function(oSuggestionNode){for(var i=0;i