
var Suggest=function(rootEl,q,formEl,textBoxEl,idEl,uri,param,successHandler,instructions,networkType,placeholderText,defaultOptions,showNoMatches,override_resize)
{this.onInputChange=function()
{var currentInputValue=oThis.typeAheadObj.currentInputValue;var cache=oThis.getCache(currentInputValue);if(cache)
{oThis.onSuggestRequestDone(currentInputValue,cache[0],cache[1],cache[2]);}
else
{var typeStr="";if(oThis.networkType)
{typeStr="&t="+oThis.networkType;}
var q=escapeURI(currentInputValue);var ajax=new Ajax(oThis.onAjaxDone,oThis.onAjaxFail);ajax.key=currentInputValue;ajax.pEvent=oThis.typeAheadObj.pEvent;ajax.get(oThis.suggestURI,oThis.suggestParam+"="+q+typeStr);}}
this.onAjaxFail=function()
{}
this.onAjaxDone=function(ajaxObj,responseText)
{var suggestNames=[];var suggestIDs=[];var suggestLocs=[];eval(responseText);oThis.onSuggestRequestDone(ajaxObj.key,suggestNames,suggestIDs,suggestLocs,ajaxObj.pEvent);}
this.onSuggestRequestDone=function(key,names,ids,locs,pEvent)
{this.setCache(key,names,ids,locs);if(this.typeAheadObj.displaySuggestList(names,ids,locs))
{this.typeAheadObj.pEvent=pEvent;this.typeAheadObj.onListChange();}}
this.getCache=function(key)
{return this.suggestCache[key.toUpperCase()];}
this.setCache=function(key,names,ids,locs)
{this.suggestCache[key.toUpperCase()]=new Array(names,ids,locs);}
this.init=function()
{this.suggestURI=uri;this.suggestParam=param;this.suggestCache=[];this.networkType=networkType;if(!instructions)
{instructions="Type to select a network";}
if(!defaultOptions)
{}
else
{}
textBoxEl.value=q;this.typeAheadObj=new TypeAhead(rootEl,formEl,textBoxEl,idEl,defaultOptions,instructions,0,successHandler,this.onInputChange,null,null,null,placeholderText,showNoMatches,override_resize);}
var oThis=this;this.init();}
function debug(str)
{document.getElementById("debug").innerHTML+=str+"<BR>";}
