
DefaultAutocompleteSSLoader=new Class({Implements:Options,options:{language:'',country:'',url:'',count:10,callbackParam:'cb'},templates:{list:'<ul>{items}</ul>',item:'<li><a id="i{i}" href="javascript:void(0);" class="js_suggestion_text" data-suggestion="{suggestion}">'+'{suggestion}'+'</a></li>'},initialize:function(options){this.setOptions(options||{});this.type='iap-fast';},getSuggestions:function(query,callback){var params={q:query,lang:this.options.language,country:this.options.country,category:'SS'},result={'query':query,'html':'','itemsCount':0},self=this;var seggestionsRequest=new Request.JSONP({url:this.options.url,data:params,callbackKey:this.options.callbackParam,onFailure:function(){callback(null);},onException:function(){callback(null);},onSuccess:function(data){if(data){data=data.data||{};var items=data.SuggestionItems[0]?data.SuggestionItems[0].list:[],itemsHtml='';if(items.length>0){Array.some(items,function(item,index){if(index==self.options.count)return true;itemsHtml+=self.templates.item.substitute({i:index,suggestion:item.term0});});result.html=self.templates.list.substitute({items:itemsHtml});result.itemsCount=items.length>self.options.count?self.options.count:items.length;}}
callback(result);}});seggestionsRequest.send();},getParams:function(){return this.options;},setParams:function(params){this.setOptions(params);if(this.options.language=="zh"){if(this.options.country=="hk"||this.options.country=="tw"){this.options.language="zht";}else if(this.options.country=="cn"){this.options.language="zhs";}}}});window.autocompleteLoader.addLoader(new DefaultAutocompleteSSLoader());

/*
Date: 3/15/2015 2:32:32 PM
All images published
*/