/*       Source:  Local Cache                                                                 */
/*     Location:  rsrc:103311:/html/js/lib/ui/typeaheadpro/sources/search_friend_source.js    */
/*      Machine:  10.16.139.106                                                               */
/*    Generated:  July 23rd 2008 7:17:13 AM PDT                                               */
/*    HTTP Host:  static.ak.fbcdn.net                                                         */


function search_friend_source(get_param){this.parent.construct(this,get_param);new AsyncRequest().setMethod('GET').setReadOnly(true).setURI('/ajax/typeahead_search.php?'+get_param).setErrorHandler(function(){}).setTransportErrorHandler(function(){}).setHandler(function(response){var payload=response.getPayload();this.values=payload.entries;this.build_index.bind(this).defer();var now_minus_5_min=((new Date()).getTime()/1000)-60*5;if(payload.gen_time<now_minus_5_min){new AsyncRequest().setMethod('GET').setReadOnly(true).setURI('/ajax/recent_pics.php').setData({ref_time:payload.gen_time}).setErrorHandler(function(){}).setTransportErrorHandler(function(){}).setHandler(function(response){this.updated_pics=response.getPayload().updated_pics;}.bind(this)).send();}}.bind(this)).send();}
search_friend_source.extend(static_source);search_friend_source.prototype.text_noinput=search_friend_source.prototype.text_placeholder=search_friend_source.prototype.text_nomatch='';search_friend_source.prototype.cache_results=true;search_friend_source.prototype.updated_pics={};search_friend_source.url_templates={};search_friend_source.loaded_images={};search_friend_source.image_load=function(image_elm,insertion_time,user_id){var current_time=(new Date()).getTime();search_friend_source.loaded_images[user_id]=true;if((current_time-insertion_time)<100){CSS.setOpacity(image_elm,1);}else{animation(image_elm).to('opacity',1).duration(100).go();}};search_friend_source.prototype.gen_html=function(friend,highlight){var icon_url=friend.it;if(!icon_url&&friend.ty&&search_friend_source.url_templates[friend.ty]){icon_url=search_friend_source.url_templates[friend.ty].icon;}
if(this.updated_pics[friend.i]){icon_url=this.updated_pics[friend.i];}
switch(friend.ty){case'u':if(!icon_url){return['<div>',typeahead_source.highlight_found(friend.t,highlight),'</div><div><small>',friend.n,'</small></div>'].join('');}else{if(!search_friend_source.loaded_images[friend.i]){var insertion_time=(new Date()).getTime();var attrs=sprintf('onload="search_friend_source.image_load(this, %d, %d);" style="opacity:0;filter:alpha(opacity=0);"',insertion_time,friend.i);}
return['<div class="wrapper"><img ',attrs,' alt="" src="',icon_url,'"/>','<div class="with_pic">',typeahead_source.highlight_found(friend.t,highlight),'</div><div class="with_pic"><small>',friend.n,'</small></div></div>'].join('');}
break;case'search':return['<div class="icon" style="background-image: url(',icon_url,')">&nbsp;</div><div class="app_name">',friend.t,'</div>'].join('');break;default:return['<div class="icon" style="background-image: url(',icon_url,')">&nbsp;</div><div class="app_name">',typeahead_source.highlight_found(friend.t,highlight),'</div>'].join('');}};search_friend_source.prototype.search_value=function(text){var results;var enough_tokens=false;var tokens=typeahead_source.tokenize(text);for(var i=0;i<tokens.length;i++){if(tokens[i]!=''){enough_tokens=true;break;}}
if(enough_tokens){this.owner.less_than_n_chars=false;results=this.parent.search_value(text);}else if(this.is_ready){this.owner.less_than_n_chars=true;results=[];}
return results;};search_friend_source.prototype._sort_text_obj=function(a,b){if(a.o!=b.o){return a.o-b.o;}else if(a.t==b.t){return 0;}
return a.t<b.t?-1:1};window.ADVANCED_SEARCH_TYPEAHEAD=false;
if(window.Bootloader){Bootloader.done(1);}