/*       Source:  Local Cache                                                                 */
/*     Location:  rsrc:108505:/html/js/feedcomment.js                                         */
/*      Machine:  10.16.139.108                                                               */
/*    Generated:  July 23rd 2008 7:16:18 AM PDT                                               */
/*    HTTP Host:  static.ak.fbcdn.net                                                         */


function feedcomment_show_error(error_target,title,description){set_inner_html(error_target,'<h2>'+title+'</h2><p>'+description+'</p>');show(error_target);}
function feedcomment_submit(story_fbid,story_key){var add_comment_form=ge('add_comment_'+story_fbid);var owner=add_comment_form.owner.value;var show_all_div=ge('feed_comment_show_all_div_'+story_fbid);var add_comment_textarea=ge('add_comment_text_'+story_fbid);var comment_button_id='submit_comment_'+story_fbid;var comment_button=ge(comment_button_id);var onResponse=function(asyncResponse){var result=asyncResponse.getPayload();var feed_comments=ge('feed_comments_'+story_fbid);var comment_count;if(typeof result.comment_count!='undefined'){comment_count=result.comment_count;}else{comment_count=feed_comments_get_count(story_fbid)+1;}
feed_comment_update_count(story_fbid,story_key,comment_count-1,comment_count);if(!Rect.getViewportBounds().contains(Rect.getElementBounds(comment_button))){var scroll_offset=-1*Math.max(getViewportHeight()/2,100);animation(document.body).to('scrollTop',Vector2.getElementPosition(comment_button).y+scroll_offset).ease(animation.ease.end).duration(1500).go();}
set_inner_html(feed_comments,result.all_comments_html);if(show_all_div){hide(show_all_div);}
add_comment_textarea.value='';comment_button.disabled=false;hide(add_comment_form);show(ge('add_another_comment_'+story_fbid));}
var onTransportFail=function(response){feedcomment_show_error(add_comment_form,tx('wp02'),tx('wp03'));comment_button.disabled=false;};var onFail=function(response){comment_button.disabled=false;if(payload=response.getPayload()){if(payload.errTitle){feedcomment_show_error(add_comment_form,payload.errTitle,payload.errBody?payload.errBody:'');}else{onTransportFail(response);}}else{onTransportFail(response);}};var comment_text=ge('add_comment_text_'+story_fbid).value
if(add_comment_textarea.getControl&&add_comment_textarea.getControl().getValue()){comment_button.disabled=true;new AsyncRequest().setURI('/ajax/feed_wallpost_ajax.php').setData({'story_fbid':story_fbid,'story_key':story_key,'owner':owner,'comment_text':comment_text}).setHandler(onResponse).setErrorHandler(onFail).send();}
return status;}
function feed_comment_update_count(story_fbid,story_key,old_count,new_count){var story=ge('story_'+story_key);var show_all_link=ge('feed_comment_show_all_link_'+story_fbid);var comment_bubble=ge('comment_bubble_'+story_fbid);var comment_link=ge('comment_link_'+story_fbid);if(new_count==0){remove_css_class_name(story,'with_comments');add_css_class_name(story,'no_comments');if(comment_bubble){set_inner_html(comment_bubble,'');}
if(comment_link){set_inner_html(comment_link,tx('fc07'));}}else{if(comment_bubble){set_inner_html(comment_bubble,new_count.toString());}
if(new_count==1){if(comment_link){set_inner_html(comment_link,tx('fc08'));}
if(old_count==0){remove_css_class_name(story,'no_comments');add_css_class_name(story,'with_comments');if(show_all_link){set_inner_html(show_all_link,tx('fc05'));}}}else{if(comment_link){set_inner_html(comment_link,tx('fc09',{'num-comments':new_count}));}
if(show_all_link){set_inner_html(show_all_link,tx('fc06',{'num-comments':new_count}));}}}}
function feed_comments_get_count(story_fbid){var comments=ge('feed_comments_'+story_fbid);var count=0;if(comments){var comment_divs=comments.getElementsByTagName('div');for(var i=0;i<comment_divs.length;i++){if(CSS.hasClass(comment_divs[i],'wallpost')){count++;}}}
return count;}
function load_all_feed_comments(story_fbid,story_key,owner){var add_comment_form=ge('add_comment_'+story_fbid);var show_all_link=ge('feed_comment_show_all_link_'+story_fbid);var onResponse=function(asyncResponse){var result=asyncResponse.getPayload();var feed_comments=ge('feed_comments_'+story_fbid);var show_all_div=ge('feed_comment_show_all_div_'+story_fbid);set_inner_html(feed_comments,result.all_comments_html);if(show_all_div){hide(show_all_div);}};var onFail=function(response){if(payload=response.getPayload()){if(payload.errTitle){if(add_comment_form){feedcomment_show_error(add_comment_form,payload.errTitle,payload.errBody?payload.errBody:'');}}else{onTransportFail(response);}}else{onTransportFail(response);}};new AsyncRequest().setURI('/ajax/feed_wallpost_ajax.php').setData({'story_fbid':story_fbid,'story_key':story_key,'get_all':1,'owner':owner}).setHandler(onResponse).setErrorHandler(onFail).send();}
function remove_feed_comment_dialog(story_fbid,story_key,comment_id){var add_comment_form=ge('add_comment_'+story_fbid);var owner=add_comment_form.owner.value;var onResponse=function(asyncResponse){var result=asyncResponse.getPayload();remove_feed_comment(story_fbid,story_key,comment_id,result.comment_count);};var onFail=function(response){if(payload=response.getPayload()){if(payload.errTitle){feedcomment_show_error(add_comment_form,payload.errTitle,payload.errBody?payload.errBody:'');}else{onTransportFail(response);}}else{onTransportFail(response);}};new Dialog().setTitle(tx('fc01')).setBody(tx('fc02')).setButtons([{name:'delete',label:tx('sh:delete'),handler:bind(this,function(){new AsyncRequest().setURI('/ajax/feed_wallpost_ajax.php').setData({'story_fbid':story_fbid,'story_key':story_key,'del_id':comment_id,'owner':owner}).setHandler(onResponse).setErrorHandler(onFail).send();})},Dialog.CANCEL]).show();}
function remove_feed_comment(story_fbid,story_key,comment_id,comment_count){if(typeof comment_count=='undefined'){comment_count=feed_comments_get_count(story_fbid)-1;}
feed_comment_update_count(story_fbid,story_key,comment_count+1,comment_count);var comment_box=ge('comments_box_'+story_fbid);if(comment_box){var comment=ge('comment_'+story_fbid+"_"+comment_id);if(comment){comment.parentNode.removeChild(comment);}}}
function hide_show_comment(story_fbid,story_key){var story=ge('story_'+story_key);if(story){CSS.toggleClass(story,'expanded_comments');CSS.toggleClass(story,'collapsed_comments');}}
if(window.Bootloader){Bootloader.done(1);}