/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  November 5th 2008 11:03:23 AM PST                            */
/*      Machine:  10.16.140.101                                                */
/*       Source:  Global Cache                                                 */
/*     Location:  js/share.js h:dqvdrpf2                                       */
/*       Locale:  en_US                                                        */
/*         Path:  js/share.js                                                  */


var share_data=null;var share_last_comment={p:null,t:null};function share_internal_config(params){if(share_last_comment.p==params){params+='&c='+escapeURI(share_last_comment.t?share_last_comment.t:'');}else{share_last_comment.p=params;}
var async=new AsyncRequest().setURI('/ajax/share_dialog.php?'+params).setMethod('GET').setReadOnly(true);var dialog=new Dialog().setAsync(async).setContentWidth(445).show();return false;}
function share_show_error(params){var dialog=new Dialog().setTitle(_tx("Invalid URL")).setBody(_tx("Sorry, you have entered an invalid URL.")).setButtons(Dialog.OK).show();return false;}
function share_is_shareable(url){return(/(?:https?:\/\/)?\w+\.\w+/.test(url));}
function share_internal_bookmarklet(){if(/http:\/\/[^\/]*?\/posted?\.php/.test(document.location.href)){var dialog=new Dialog().setClassName('share_congratulations').setTitle(_tx("Share")).setBody('<div class="status"><h2>'+_tx("You've successfully installed the bookmarklet.")+'</h2><p>'
+_tx("Click it on an external site to share it with your friends.")+'</p></div>').setButtons(Dialog.OK).show();}else{throw 0;}}
function share_show_comments(share_id,focus_textarea){CSS.removeClass('share_footer'+share_id,'hide_comments');CSS.addClass('share_footer'+share_id,'show_comments');if(focus_textarea){$('comment'+share_id).focus();}
return false;}
function share_show_add_comment(obj,share_id){var node=obj.parentNode;DOM.remove(node);var add_comment=$('add_comment_input'+share_id);show(add_comment);var submit_button=$('add_comment_button'+share_id);submit_button.disabled=false;var textarea_id='comment'+share_id;$(textarea_id).focus();return false;}
function share_add_comment_submit(obj,share_id){var node=obj.parentNode;var textarea=node.getElementsByTagName('textarea')[0];var comment=textarea.value;if(/^\s*$/.test(comment)){_share_flash_comment_error(textarea);return;}else if(comment.length>1000){$('add_comment_error'+share_id).style.display='block';return;}
new AsyncRequest().setURI('/ajax/share_misc.php').setData({share_id:share_id,comment:comment}).setHandler(function(parentNode,commentsNode,response){hide(parentNode);DOM.appendContent(commentsNode,HTML(response.getPayload()));node.getElementsByTagName('textarea')[0].value='';}.bind(this,node,$('share_comments_for_'+share_id))).send();obj.disabled=true;return true;}
function share_delete_comment(obj,share_id,comment_id){while(!CSS.hasClass(obj,'share_other_comment')&&obj!=null){obj=obj.parentNode;}
if(obj==null){return true;}
var delete_function=function(obj,share_id,comment_id){var p=obj.parentNode;DOM.remove(obj);if(p.childNodes.length==0){hide(p);}
new AsyncRequest().setURI('/ajax/share_misc.php').setData({share_id:share_id,delcomment:1,comment_id:comment_id}).send();return true;}.bind(null,obj,share_id,comment_id);var dialog=new Dialog().setTitle(_tx("Delete Comment?")).setBody(_tx("Are you sure you want to delete this comment?")).setButtons([Dialog.newButton('delete',_tx("Delete")),Dialog.CANCEL]).setHandler(delete_function).show();return false;}
function _share_flash_comment_error(obj){animation(obj).from('background','#ffc8c8').to('background','#fff').duration(500).go();}
function share_show_delete_dialog(context,href){var dialog=new contextual_dialog();dialog.set_context(context);dialog.show_choice(_tx("Are you sure you want to delete this item?"),_tx("Deleting this item will also remove all its comments."),_tx("Delete Item"),function(){_share_delete_clicked(this,context,href);},_tx("Cancel"),function(){generic_dialog.get_dialog(this).hide();});return false;}
function _share_delete_clicked(button,context,href){while(context.parentNode&&!CSS.hasClass(context,'sharebox_item')){context=context.parentNode;}
if(!CSS.hasClass(context,'sharebox_item')){return false;}
generic_dialog.get_dialog(button).hide();new AsyncRequest().setURI(href).send();DOM.remove(context);}
function share_play_video(share_id,unique_id){_share_log_play_content(share_id,'video');if(holder=ge(unique_id+'_holder')){if(container=holder.parentNode.parentNode){CSS.addClass(container,'playing');}}
return false;}
function _share_log_play_content(share_id,media_type){new AsyncRequest().setURI('/ajax/shareplay_ajax.php').setData({s:share_id,m:media_type}).send();}
function share_composer_method(obj,method){var tabs=obj.parentNode.parentNode.getElementsByTagName('a');for(var i=0;i<tabs.length;i++){CSS.removeClass(tabs[i],'selected');}
CSS.addClass(obj,'selected');while(!CSS.hasClass(obj,'share_composer')&&obj){obj=obj.parentNode;}
if(!obj){Util.error("Could not find share composer");return true;}
obj.className='share_composer share_status_'+method;return false;}
function share_send_onsubmit(obj){return _share_onsubmit_to('ids','send',obj);}
function share_wallpost_onsubmit(obj){return _share_onsubmit_to('wall_id','wall',obj);}
function share_post_onsubmit(obj){return _share_onsubmit('post',obj);}
function _share_onsubmit_to(ids,post_action,obj){var ids=$(ids);if(!ids.tokenizer||ids.tokenizer.count_names()==0){new ErrorDialog().showError(_tx("This field is required."),_tx("You must specifiy at least one recipient for this message."));return false;}
return _share_onsubmit(post_action,obj);}
function _share_onsubmit(post_action,obj)
{var post=serialize_form(obj);post.action=post_action;var inputs=obj.getElementsByTagName('input');for(var i=0;i<inputs.length;i++){inputs[i].disabled=true;}
var inputs=obj.getElementsByTagName('textarea');for(var i=0;i<inputs.length;i++){inputs[i].disabled=true;}
share_last_comment.t=inputs[0].value;var divs=obj.getElementsByTagName('div');for(var i=0;i<divs.length;i++){if(typeof divs[i].tokenizer!='undefined'){divs[i].tokenizer.disable();}else if(!CSS.hasClass(divs[i],'tokenizer')){CSS.addClass(divs[i],'tokenizer_locked');}}
while(!CSS.hasClass(obj,'dialog_content')&&obj){obj=obj.parentNode;}
if(!obj){Util.error("Could not locate base element for dialog");return false;}
new AsyncRequest().setURI('/ajax/share.php').setData(post).setHandler(share_post_send_callback.bind(obj)).send();}
function share_post_send_callback(response){payload=response.getPayload();if(payload['html']){set_inner_html(this,payload['html']);if(payload['redr']){setTimeout(function(){goURI(payload['redr']);},3000);}else{var gd=generic_dialog.get_dialog(this);var tmout=payload['timeout']||3000;if(gd){gd.fade_out(500,tmout);}else if(payload['close']){setTimeout(function(){self.close();},tmout);}}}else if(payload['redr']){goURI(payload['redr']);}}
function share_scroll_to_comment(share_id,comment_id){var target;var target_offset;if(share_id&&comment_id){target=ge('comment_'+share_id+'_'+comment_id);target_offset=-10;}else{target=ge('share_footer'+share_id);target_offset=0;}
if(target){var target_top=Vector2.getElementPosition(target).y;animation(DOMScroll.getScrollRoot()).to('scrollTop',target_top+target_offset).ease(animation.ease.end).duration(1500).go();}}

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