/*
HTTP Host: b.static.ak.fbcdn.net
Generated: March 21st 2010 1:27:08 PM PDT
Machine: 10.16.140.106
Locale: nu_ll
Path: js/poke.js
*/

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/poke.js"]); }


function show_poke_dialog(uid,pobj,DEPRECATED,parent,refresh,first_name,ref){new PokeController(uid,pobj,parent,refresh,first_name,ref).show();return false;}
function PokeController(uid,pokeback_obj,parent,refresh,first_name,ref){copy_properties(this,{uid:uid,pokeback:(pokeback_obj?1:0),pokeback_obj:pokeback_obj,failed_captcha:0,parent:parent,refresh:refresh,dialog:null,first_name:first_name,title:null,ref:ref});this.dialog=Dialog.getCurrent();if(this.dialog){this.dialog.setHandler(this.poke.bind(this));}}
PokeController.prototype.show=function(){new AsyncRequest('/ajax/poke.php').setData({can_poke:this.uid,pokeback:this.pokeback,failed_captcha:this.failed_captcha}).setContextData('clicktype','Poke',this.ref==="profile_others").setReplayable(false).setHandler(this.onresponse.bind(this)).send();}
PokeController.prototype.onresponse=function(response){var p=response.getPayload();this.dialog=new Dialog();this.title=p.dialog_title;if(!p.status||p.warned){this.dialog.setModal(true);}
if(p.status){this.dialog.setTitle(this.title).setBody(p.dialog_contents).setButtons([Dialog.newButton('poke',_tx("\u6233"),'',this.poke.bind(this)),Dialog.CANCEL]).show();}else{this.dialog.setTitle(this.title).setBody(p.dialog_contents).setButtons([Dialog.OK]).show();}}
PokeController.prototype.poke=function(){var data={uid:this.uid,pokeback:this.pokeback};var captcha_form=ge('captcha_form');if(captcha_form){var captcha_elements=captcha_form.getElementsByTagName('input');for(var i=0;i<captcha_elements.length;i++){data[captcha_elements[i].name]=captcha_elements[i].value;}}
this.show_onpoke_dialog=true;new AsyncRequest('/ajax/poke.php').setData(data).setHandler(this.onpoke.bind(this)).send();return false;}
function remove_poke(obj,rem_class,parent_class,poke){new AsyncRequest().setURI('/ajax/poke.php').setData({'p':poke}).setHandler(function(){hide_poke_obj(obj,rem_class,parent_class);}).send();}
function hide_poke_obj(obj,rem_class,parent_class){obj=ge(obj);if(obj&&parent_class){pobj=obj;while(!CSS.hasClass(pobj,parent_class)&&pobj.parentNode){pobj=pobj.parentNode;}}
if(obj&&rem_class){while(!CSS.hasClass(obj,rem_class)&&obj.parentNode){obj=obj.parentNode;}
if(obj){if(DOM.scry(pobj,'div.ind_poke').length<=1){DOM.remove(pobj);}else{DOM.remove(obj);}}}
return false;}
PokeController.prototype.onpoke=function(response){var p=response.getPayload();if(!p.captcha){this.dialog.setAutohide(100);this.failed_captcha=1;this.show();return;}
if(this.pokeback){var poke_parent_str=this.parent||'sidebar_item pokes';hide_poke_obj(this.pokeback_obj,'ind_poke','pokes');if(this.refresh){update_poke_summary(this.refresh,'poke_start_index','poke_end_index','poke_total');}}
if(this.show_onpoke_dialog){this.dialog.setTitle(this.title).setBody(p.dialog_contents).setButtons([Dialog.OK]).show();if(p.status){this.dialog.setAutohide(1100);}
this.show_onpoke_dialog=false;}}
function update_poke_summary(display_obj,start,end,total){var start_count=$(start).innerHTML;var end_count=$(end).innerHTML-1;var total_count=$(total).innerHTML-1;$(end).innerHTML=end_count;$(total).innerHTML=total_count;$(display_obj).innerHTML=_gen_poke_summary_text(start_count,end_count,total_count);}
function _gen_poke_summary_text(start,end,total){if(total==1){return _tx("\u986f\u793a\u552f\u4e00\u7684\u6233");}else if(total==0||end<start){return _tx("\u6211\u6c92\u6709\u627e\u5230\u4efb\u4f55\u7d50\u679c\u53ef\u4ee5\u7d66\u4f60\u3002");}else if(end==total){return _tx("Displaying all {number} pokes.",{'number':total});}else{return _tx("\u986f\u793a{total}\u500b[\u6233\u4e00\u4e0b!]\u88e1\u7684\u7b2c{start}\u5230{end}.",{'start':start,'end':end,'total':total});}}

if (window.Bootloader) { Bootloader.done(["js\/poke.js"]); }