/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  March 26th 2009 11:58:47 AM PDT                              */
/*      Machine:  10.16.139.101                                                */
/*       Source:  Local Cache                                                  */
/*     Location:  rsrc:b9c7uy71:en_US:/html/js/424ncw09cvuoc08o.pkg.js:141     */
/*       Locale:  en_US                                                        */
/*         Path:  js/424ncw09cvuoc08o.pkg.js                                   */


function UIComposerAttachmentArea(composer,root){this.composer=composer;this.root=root;this.area=root.find('div.UIComposer_AttachmentArea_Cache');this.cache={};this.visible=null;this.attachment={};this.dirtyOnReset=false;var closeButton=root.find('a.UIComposer_AttachmentArea_CloseButton');Event.listen(closeButton,'click',function(event){Event.kill(event);composer.reset();});}
UIComposerAttachmentArea.prototype={show:function(attachment){this.composer.addState(UIComposer.STATE.ATTACHMENT_AREA);this.attachment=attachment;this.dirtyOnReset=false;var app_id=attachment.app_id;if(this.cache[app_id]){this.showAttachment(app_id);}else{this.loadAttachment(app_id);}},loadAttachment:function(app_id){this.composer.refreshHeight();var data={app_id:app_id,composer_id:this.composer.id,stream_id:this.composer.target_id};new AsyncRequest().setURI(UIComposerAttachmentArea.ENDPOINT).setData(data).setHandler(UIComposerAttachmentArea.handleResponse.bind(this)).setErrorHandler(UIComposer.handleError.bind(this.composer)).setTransportErrorHandler(UIComposer.handleError.bind(this.composer)).send();},showAttachment:function(app_id){if(!this.composer.hasState(UIComposer.STATE.ATTACHMENT_AREA)){return;}
this.visible=this.cache[app_id];this.visible.addClass(UIComposerAttachmentArea.CLASS.VISIBLE);this.composer.addState(UIComposer.STATE.ATTACHMENT_LOADED);this.composer.refreshHeight(this.composer.removeHeight.bind(this.composer));this.fireAttachmentEvent('load');},createAttachment:function(payload){var element=$N('div',{className:UIComposerAttachmentArea.CLASS.CACHED});this.area.appendChild(element).setContent(HTML(payload.html));return element;},setAttachment:function(controller){if(this.attachment){this.attachment.controller=controller;controller.initialize(this.composer,this.cache[this.attachment.app_id],this.attachment.app_id);}
return this;},getAttachment:function(){if(this.attachment&&this.attachment.controller){return this.attachment.controller;}
return null;},getData:function(){if(this.attachment&&this.attachment.controller){return this.attachment.controller.getData();}
return null;},getEndpoint:function(){if(this.attachment&&this.attachment.controller){return this.attachment.controller.getEndpoint();}
return null;},post:function(){if(!this.visible){return;}
var data=this.getData();var endpoint=this.getEndpoint();if(!data||!endpoint){return;}
data.composer_id=this.composer.id;this.composer.removeState(UIComposer.STATE.ATTACHMENT_LOADED);this.composer.refreshHeight();new AsyncRequest().setURI(endpoint).setData(data).setHandler(UIComposerAttachmentArea.handleResponse.bind(this)).setErrorHandler(UIComposer.handleError.bind(this.composer)).send();},reset:function(){if(!this.visible){return;}
this.visible.removeClass(UIComposerAttachmentArea.CLASS.VISIBLE);this.visible=null;if(this.dirtyOnReset){var app_id=this.attachment.app_id;this.cache[app_id].remove();this.cache[app_id]=null;}
this.fireAttachmentEvent('reset');},fireAttachmentEvent:function(event){if(this.attachment&&this.attachment.controller){this.attachment.controller[event]();}}};copy_properties(UIComposerAttachmentArea,{handleResponse:function(response){var app_id=this.attachment.app_id;var attachment=this.cache[app_id];var payload=response.getPayload();if(!attachment){this.cache[app_id]=this.createAttachment(payload);}else{attachment.setContent(HTML(payload.html));this.dirtyOnReset=true;}
this.showAttachment(app_id);}});copy_properties(UIComposerAttachmentArea,{CLASS:{CACHED:'UIComposer_Attachment_Cached',VISIBLE:'UIComposer_Attachment_Visible'},ENDPOINT:'/ajax/composer/attachment.php',PARAM_STRUCTURE:'app_data[attachment][params]'});

function UIComposer(root,input,user,attachments,stream,target_id){if(!root){throw new Error('UIComposer instantiated with no root.');return false;}
this.id=root.id;this.root=root;this.holder=root.parentNode;this.input=input;this.button=root.find('input.UIComposer_Button');this.user=user;this.stream=stream;this.target_id=target_id;this.shouldHide=true;this.resetState=[root.className,UIComposer.STATE.INPUT_FOCUSED,UIComposer.STATE.ATTACHMENT_LIST].join(' ');this.initializeDialog();this.initializeAttachments(attachments);this.initializeEvents();UIComposer.storeInstance(this.id,this);onunloadRegister(function(){delete UIComposer.instances[root.id];},true);}
UIComposer.prototype={initializeDialog:function(){var share=Dialog.newButton('share',_tx("Share"),null,function(){this.shouldHide=false;this.post();return false;}.bind(this));var cancel=Dialog.newButton('cancel',_tx("Cancel"),'inputaux',function(){this.shouldHide=false;this.reset();return false;}.bind(this));var width=this.hasState(UIComposer.STATE.PIC_OUTSIDE)?UIComposer.DIALOG_WIDTH_PIC:UIComposer.DIALOG_WIDTH;this.dialog=new Dialog().setButtons([share,cancel]).setTitle('Publish Story').setContentWidth(width).setStackable(true).setModal(true).setBody('');},initializeAttachments:function(attachments){if(!attachments.length){return;}
var action;this.apps=attachments.map(function(attachment){var app_id=attachment.app_id;if(attachment.action!==undefined){action={app:app_id,type:attachment.action};}
return app_id;});this.attachments=attachments;this.attachmentCell=this.root.find('td.UIComposer_TDAttachments');this.attachmentBlind=this.root.find('div.UIComposer_Attachments');this.attachmentRoot=this.root.find('div.UIComposer_AttachmentArea');this.attachmentList=new UIComposerAttachmentList(this,this.attachmentBlind);this.attachmentArea=new UIComposerAttachmentArea(this,this.attachmentRoot);if(action){this.loadAttachment(action.app,action.type);}},initializeEvents:function(){Event.listen(this.input,'focus',this.focus.bind(this));Event.listen(this.button,'click',this.post.bind(this));if(this.attachments){var cancelHide=function(){this.shouldHide=false;}.bind(this);Event.listen(this.root,'click',cancelHide);Event.listen(this.root,'mousedown',cancelHide);Event.listen(document.body,'click',function(){if(this.shouldHide){this.blur();}
this.shouldHide=true;}.bind(this));}},focus:function(){if(this.attachmentList&&!this.hasState(UIComposer.STATE.ATTACHMENT_LIST)&&!this.hasState(UIComposer.STATE.ATTACHMENT_AREA)){this.attachmentList.show();}
return this.addState(UIComposer.STATE.INPUT_FOCUSED);},blur:function(){if(this.attachmentList&&this.hasState(UIComposer.STATE.ATTACHMENT_LIST)&&!this.hasState(UIComposer.STATE.ATTACHMENT_AREA)){this.removeState(UIComposer.STATE.INPUT_FOCUSED);this.attachmentList.hide();if(!this.getMessage()){this.clearMessage();}}
return this;},attach:function(){this.dialog.hide();CSS.setStyle(this.holder,'paddingTop',this.padding+'px');DOM.prependContent(this.holder,this.root);this.input.focus();},detach:function(callback){this.padding=parseInt(CSS.getStyle(this.holder,'paddingTop'),10);var padding=parseInt(CSS.getStyle(this.root,'marginBottom'),10)
+this.root.offsetHeight
+this.padding;this.dialog.onloadRegister(function(){DOM.find(this.dialog._pd.content,'div.dialog_body').appendChild(this.root);CSS.setStyle(this.holder,'paddingTop',padding+'px');if(callback){setTimeout(callback,500);}}.bind(this)).show();},setAttachment:function(controller){this.attachmentArea.setAttachment(controller);return this;},getAttachment:function(){return this.attachmentArea.getAttachment();},getRequiredHeight:function(){return UIComposer.getVerticalSpace(this.attachmentList.root)
+UIComposer.getVerticalSpace(this.attachmentArea.root);},refreshHeight:function(callback){if(!this.attachmentBlind){return;}
return UIComposer.animation(this.attachmentBlind,callback).to('height',this.getRequiredHeight()+'px').go();},removeHeight:function(){this.attachmentBlind.setStyle('height','');return this;},setAttachmentColSpan:function(colSpan){this.attachmentCell.colSpan=colSpan;return this;},loadAttachment:function(app_id,action){var attachment=this.attachments[this.apps.indexOf(app_id)];if(this.hasState(UIComposer.STATE.ATTACHMENT_AREA)){this.reset(false,false);}
if(!attachment){this.input.blur();return this.blur();}
if(!action){action=attachment.is_fluid?'select':'swap';}
this.attachmentList[action](attachment);this.focus();},showAttachment:function(attachment){this.setAttachmentColSpan(1);this.attachmentArea.show(attachment);return this;},reset:function(clearMessage,focusInput){var callback=bagofholding;if(this.root.parentNode!=this.holder){callback=this.attach.bind(this);}
if(this.attachments){this.attachmentBlind.setStyle('height',this.getRequiredHeight()+'px');this.attachmentList.reset();this.attachmentArea.reset();this.setAttachmentColSpan(2);}
CSS.setClass(this.root,this.resetState);this.refreshHeight(callback);this.enable();if(clearMessage){this.clearMessage();}
if(focusInput!==false){this.input.select();this.input.focus();}
this.shouldHide=true;return this;},addState:function(state){this.root.addClass(state);return this;},removeState:function(state){this.root.removeClass(state);return this;},hasState:function(state){return this.root.hasClass(state);},disable:function(){this.input.disabled=true;this.addState(UIComposer.STATE.INPUT_DISABLED).disableButton();return this;},enable:function(){this.input.disabled=false;this.removeState(UIComposer.STATE.INPUT_DISABLED).enableButton();return this;},disableButton:function(){var dialogButton=this.dialog.getButtonElement('share');if(dialogButton){dialogButton.disabled=true;dialogButton.addClass('inputsubmit_disabled');}
this.button.disabled=true;this.addState(UIComposer.STATE.BUTTON_DISABLED);return this;},enableButton:function(){var dialogButton=this.dialog.getButtonElement('share');if(dialogButton){dialogButton.disabled=false;dialogButton.removeClass('inputsubmit_disabled');}
this.button.disabled=false;this.removeState(UIComposer.STATE.BUTTON_DISABLED);return this;},isDisabled:function(){return this.input.disabled||this.button.disabled;},getData:function(endpoint){var data={};var message=this.getMessage();if(endpoint==UIComposer.ENDPOINT){if(!message){return null;}
copy_properties(data,this.target_id>0?UIComposer.TARGET_DATA:UIComposer.HOME_DATA);copy_properties(data,{status:message,target_id:this.target_id,profile_id:this.user});}else{data=this.attachmentArea.getData();if(data){copy_properties(data,{id:this.user,target_id:this.target_id,app_id:this.attachmentArea.attachment.app_id,action:'post',button:'publish_button',comment_text:message});}}
if(data){data.composer_id=this.id;}
return data;},getEndpoint:function(){var endpoint;if(this.hasState(UIComposer.STATE.ATTACHMENT_LOADED)){endpoint=this.attachmentArea.getEndpoint();}
return endpoint||UIComposer.ENDPOINT;},getMessage:function(){return this.input.value.trim();},clearMessage:function(){this.input.value='';this.input.setStyle('height','');},post:function(){if(this.isDisabled()){return;}
var endpoint=this.getEndpoint();var data=this.getData(endpoint);if(!data){return;}
this.disable();new AsyncRequest().setURI(endpoint).setData(data).setHandler(UIComposer.handleResponse.bind(this)).setErrorHandler(UIComposer.handleError.bind(this)).setFinallyHandler(this.enable.bind(this)).send();var ab_test_name=this.target_id==0?'NILE_HOME_COMPOSER_MESSAGE':'NILE_PROFILE_COMPOSER_MESSAGE';new AsyncSignal('/ajax/log_ab_test_action.php',{id:this.user,name:ab_test_name,action:'USER_POSTS_SOMETHING'}).send();},publish:function(response){var stream=this.stream;if(stream){var story=response,status;if(response.getPayload){var payload=response.getPayload();status=payload.status;story=payload.markup;}
story=HTML(story).getNodes()[0];setTimeout(function(){stream.addContent(story);if(stream.setStatus&&status){stream.setStatus(status);}},500);}
return this;}};copy_properties(UIComposer,{instances:{},getInstance:function(id){return this.instances[id]||null;},storeInstance:function(id,composer){this.instances[id]=composer;},handleError:function(response){var error=response.getError();var payload=response.getPayload();var showError=function(title,message){new ErrorDialog().setTitle(title).setBody(message||_tx("There was an application error. Please try again later.")).setButtons([Dialog.OK]).show();};switch(error){case kError_Platform_CallbackValidationFailure:return showError(payload.errorTitle,payload.errorMessage);case kError_Platform_ApplicationResponseInvalid:return showError(payload.errorTitle,payload.showDebug);default:this.shouldHide=false;this.reset();return showError(response.getErrorSummary(),response.getErrorDescription());}},handleResponse:function(response){this.reset(true).publish(response);},getVerticalSpace:function(element){var height=element.offsetHeight;if(height){height+=parseInt(element.getStyle('marginTop'),10)||0;height+=parseInt(element.getStyle('marginBottom'),10)||0;}
return height;},animation:function(element,callback){return animation(element).ondone(callback||bagofholding).ease(animation.ease.end).duration(200);}});copy_properties(UIComposer,{DIALOG_WIDTH:560,DIALOG_WIDTH_PIC:620,HOME_DATA:{action:'HOME_UPDATE',home_tab_id:1,profile_id:null,status:null,target_id:null},TARGET_DATA:{action:'PROFILE_UPDATE',profile_id:null,status:null,target_id:null},ENDPOINT:'/updatestatus.php',STATE:{PIC_NONE:'UIComposer_STATE_PIC_NONE',PIC_INSIDE:'UIComposer_STATE_PIC_INSIDE',PIC_OUTSIDE:'UIComposer_STATE_PIC_OUTSIDE',INPUT_FOCUSED:'UIComposer_STATE_INPUT_FOCUSED',INPUT_DISABLED:'UIComposer_STATE_INPUT_DISABLED',BUTTON_DISABLED:'UIComposer_STATE_BUTTON_DISABLED',ATTACHMENT_LIST:'UIComposer_STATE_ATTACHMENT_LIST',ATTACHMENT_AREA:'UIComposer_STATE_ATTACHMENT_AREA',ATTACHMENT_LOADED:'UIComposer_STATE_ATTACHMENT_LOADED'}});

function UIComposerAttachmentList(composer,root){this.composer=composer;this.root=root.find('ul.UIComposer_AttachmentList');this.mask=root.find('div.UIComposer_AttachmentMask');this.maskLabel=root.find('span.UIComposer_AttachmentLink');this.selected=null;var more=root.scry('li.UIComposer_More_Actuator')[0];var menu=ge('UIComposer_'+composer.id+'_Dropdown');var items=$A(root.scry('li.UIComposer_Attachment'));var menuItems=(menu&&$A(menu.scry('li')))||[];this.composer.attachments.each(function(attachment,index){attachment.index=index;var item=items[index],menuItem=menuItems[index];var load=this.select.bind(this,attachment);if(item){attachment.item=item;Event.listen(item,'click',load);}
if(menuItem){attachment.menuItem=menuItem;Event.listen(menuItem,'click',load);if(!this.swinger&&menuItem.hasClass('UIComposer_Swinger')){this.swinger=attachment;}}},this);if(menu&&more){more=more.find('a');dropmenu(more).registerHTMLMenu(menu).setPosition(dropmenu.ALIGN_LEFT).addHook('show',CSS.addClass.curry(more,'UIComposer_More_Selected')).addHook('hide',CSS.removeClass.curry(more,'UIComposer_More_Selected'));Event.listen(menu,'mousedown',function(){composer.shouldHide=false;});}}
UIComposerAttachmentList.prototype={swap:function(attachment){if(!attachment.item.hasClass('hidden_elem')){return;}
attachment.item.removeClass('hidden_elem');attachment.menuItem.addClass('hidden_elem');this.swinger.item.addClass('hidden_elem');this.swinger.menuItem.removeClass('hidden_elem');this.swinger=attachment;},select:function(attachment,internal){this.swap(attachment);this.selected=attachment.item;var offsetDir,offsetTransition;var offset=this.selected.offsetLeft;if(!intl_locale_is_rtl()){offsetDir='left';offset=this.selected.offsetLeft
-parseInt(this.mask.getStyle('paddingLeft'),10);}else{offsetDir='right';offset=this.root.offsetWidth
-this.selected.offsetLeft
-this.selected.offsetWidth
-parseInt(this.mask.getStyle('paddingRight'),10);}
this.mask.setStyle(offsetDir,offset+'px');this.maskLabel.setContent(attachment.caption);this.maskLabel.setStyle('backgroundImage','url('+attachment.icon+')');this.maskLabel.addClass('UIComposer_SelectedAttachment');var showAttachment=function(attachment){this.root.setStyle('display','');this.composer.showAttachment(attachment);}.bind(this,attachment);if(internal){offsetTransition=function(){CSS.setOpacity(this.root,0);UIComposer.animation(this.mask).to(offsetDir,'0px').go();showAttachment();}.bind(this);}else{offsetTransition=function(){CSS.setOpacity(this.root,0);CSS.setStyle(this.mask,offsetDir,'0px');showAttachment();}.bind(this);}
if(attachment.is_fluid){offsetTransition();}else{this.composer.detach(offsetTransition);}},reset:function(){if(this.maskLabel){CSS.removeClass(this.maskLabel,'UIComposer_SelectedAttachment');}
CSS.setOpacity(this.root,1);},show:function(){this.root.setStyle('display','block');this.composer.addState(UIComposer.STATE.ATTACHMENT_LIST);this.composer.refreshHeight();},hide:function(){this.root.setStyle('display','none');this.composer.removeState(UIComposer.STATE.ATTACHMENT_LIST);this.composer.refreshHeight();}};

function MegaphoneHelper(){}
MegaphoneHelper.hideStory=function(story_id,location,element_id){var data={'mp_id':story_id,'location':location};var async=new AsyncSignal('/ajax/megaphone_hide.php',data).send();var el_to_hide=ge(element_id);if(el_to_hide){animation(el_to_hide).to('height',0).duration(500).hide().go();}}

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