/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  June 10th 2009 4:16:50 PM PDT                                */
/*      Machine:  10.16.140.104                                                */
/*       Source:  Local Cache                                                  */
/*     Location:  rsrc:b8f7437w:en_US:/html/js/emntp0wp22gw4084.pkg.js:141     */
/*       Locale:  en_US                                                        */
/*         Path:  js/emntp0wp22gw4084.pkg.js                                   */


function typeahead_mentions(element,source,options){this.element=$(element);options=copy_properties({delimiter:'@',anchor_block:true,max_display:4,max_results:4,submit_keydown_return:false,auto_select:false},options||{});this.selected=null;source=new search_friend_source(source,true);source.allowTypes([search_friend_source.TYPES.USER,search_friend_source.TYPES.PAGE,search_friend_source.TYPES.APP,search_friend_source.TYPES.GROUP,search_friend_source.TYPES.EVENT]);this.parent.construct(this,element,source,options);CSS.addClass(this.list,'typeahead_mentions');CSS.addClass(this.dropdown,'typeahead_search');this.initializeEvents();this.hide();}
typeahead_mentions.extend('typeaheadpro');copy_properties(typeahead_mentions.prototype,{_onchange:bagofholding,set_class:bagofholding,set_value:bagofholding,update_class:bagofholding,recalc_scroll:bagofholding,clear_placeholder:bagofholding,initializeEvents:function(){this.shouldClean=!ua.safari();if(!this.shouldClean){return;}
if(document.selection){Event.listen(this.element,'paste',function(){setTimeout(this.cleanup.bind(this),100);}.bind(this));}else{var timer,element=this.element,nodeCount=element.childNodes.length,charCount=DOM.getText(element).length;var check=function(){if(!this.shouldClean){this.shouldClean=true;return;}
if(Math.abs(nodeCount-element.childNodes.length)>2||Math.abs(charCount-DOM.getText(element).length)>5){this.cleanup();}
this.focusInput();}.bind(this);addEventBase(element,'DOMCharacterDataModified',function(){charCount=DOM.getText(element).length;nodeCount=element.childNodes.length;});addEventBase(element,'DOMNodeInserted',function(){clearTimeout(timer);timer=setTimeout(check,25);});}},show:function(){this.parent.show();this.dropdown.style.width=this.anchor.offsetWidth+'px';},get_value:function(){var range=Text.getRange(),node=Text.getFocusNode(range,this.element),value=Text.getFocusValue(range,node),offset=Text.getFocusOffset(range,node);if(!range||!value||range.collapsed===false){return'';}
var index=value.lastIndexOf(this.delimiter,offset);if(index<0||(index>0&&((/\w/).test(value.charAt(index-1))||value.charAt(index+1)==' '))){return'';}
return value.slice(index,offset);},check_value:function(){if(DOM.getText(this.element).lastIndexOf(this.delimiter)==-1){if(this.value==this.delimiter){this.hide();}
return;}
if(!this.ready){if(!this.loading){this.loading=true;this.source.initialize(function(){this.ready=true;this.results_text=this.delimiter;this.check_value();}.bind(this));this.set_message(_tx("Loading..."));this.show();}
return;}
var value=this.get_value();if(value==this.delimiter){this.set_message('Mention Something');this.show();}
if(value!=this.value){this.dirty_results();this.value=value;}},setup_anchor:function(){return this.element.parentNode.parentNode;},_onblur:function(event){this.fixBreak();this.hide();},_onfocus:function(event){this.fixBreak();this.focused=true;this.results_text='';},_onkeydown:function(event){event=$E(event);var code=event?event_get_keypress_keycode(event):-1;if(window.getSelection&&code==KEYS.BACKSPACE){var node=Text.getFocusNode(),offset=Text.getFocusOffset();if(offset==0){node=node.previousSibling;}else if(node==this.element&&offset>0){node=this.element.childNodes[offset-1];}
if(this.isMention(node)){DOM.remove(node);}}
if(!this.visible&&document.selection&&code==KEYS.RETURN){Text.insertBreak();}
if(this.visible){if(code==KEYS.UP||code==KEYS.DOWN||code==KEYS.RETURN){event.kill();}
return this.parent._onkeydown(event);}},_onkeypress:function(event){if(this.visible){return this.parent._onkeypress(event);}},_onkeyup:function(event){this.check_value();if(this.visible){return this.parent._onkeyup(event);}},_onselect:function(selected){if(!selected){return;}
var value=this.value,nodes=this.element.childNodes;this.shouldClean=false;for(var i=0,l=nodes.length;i<l;i++){var node=nodes[i];if(this.isText(node)){var text=node.data,index=text.lastIndexOf(value,Text.getFocusOffset());if(index>-1){var mention=this.createMention(selected,value);var prefix=document.createTextNode(text.substring(0,index).replace(/\s*$/g,'')+' ');node.data=' '+text.substring(index+value.length).replace(/^\s*/g,'');this.element.insertBefore(mention,node);this.element.insertBefore(prefix,mention);this.focusAfter(mention);break;}}}
this.hide();},completeSubstrings:function(partial,canonical){var canonical=typeahead_source.tokenize(canonical,false,true),partial=typeahead_source.tokenize(partial);canonical.sort(function(a,b){return b.length-a.length;});var flattened=typeahead_source.tokenize(canonical.join(' ')),results=[];partial.each(function(ii){for(var jj=flattened.length;jj--;){if(flattened[jj].lastIndexOf(ii,0)==0){results.push(canonical[jj]);flattened[jj]='';break;}}});return results.join(' ');},createSpacer:function(){var span=document.createElement('span');span.innerHTML='&nbsp;';return span.removeChild(span.firstChild);},createMention:function(obj,value){var data={id:obj.i,text:obj.t};if(value&&obj.ty=='u'){data.substring=this.completeSubstrings(value.substring(1),data.text);}
var mention=$N('a',{href:'#',title:data.text,className:'mention',unselectable:'on',contentEditable:false,oncontextmenu:Event.kill,onclick:Event.kill,onfocus:Event.kill},$N('span',{contentEditable:!!document.selection},'@'+(data.substring||data.text)));Event.listen(mention,'mousedown',this.selectMention.bind(this,mention));Event.listen(mention,'dblclick',function(){DOM.remove(mention);});DataStore.set(mention,'mention',data);return mention;},selectMention:function(mention,event){if(!mention){return;}
if(event){event.kill();}
var prev=mention.previousSibling;if(!prev||(this.isText(prev)&&!prev.nodeValue.trim())){DOM.remove(prev);DOM.insertBefore(this.createSpacer(),mention);}
setTimeout(function(){this.element.focus();if(!mention.parentNode){var offset=prev.length;this.normalize();Text.setFocus(prev,offset);}else{Text.selectNode(mention);}}.bind(this),0);},focusAfter:function(node){this.normalize();setTimeout(function(){this.element.focus();Text.setFocusAfter(node);}.bind(this),0);},normalize:function(){var node=this.element.firstChild;while(node){var next=node.nextSibling;if(this.isText(node)&&this.isText(next)){node.data+=next.data;this.element.removeChild(next);}else{node=node.nextSibling;}}},cleanup:function(){if(!this.shouldClean){return;}
this.shouldClean=false;var nodes=this.element.childNodes,dirty=false;for(var i=nodes.length;i--;){var node=nodes[i];if(!this.isText(node)&&!this.isMention(node)&&!this.isBreak(node)){this.element.replaceChild(document.createTextNode(DOM.getText(node)),node);dirty=true;}}
if(dirty){this.normalize();}
this.shouldClean=true;},focusInput:function(){this.element.focus();},clearMessage:function(){this.element.empty();},getMessage:function(){var message=$A(this.element.childNodes).map(function(node){if(this.isBreak(node)){return"\n";}
if(this.isText(node)){return node.data;}
var data=this.isMention(node);if(data){return'@['+data.id+':'+(data.substring||data.text)+']';}},this);return message.join('');},isBreak:function(node){return DOM.isNode(node,'br');},isText:function(node){return DOM.isNode(node,['#text','#whitespace']);},isMention:function(node){return DOM.isNode(node,'a')&&DataStore.get(node,'mention');},fixBreak:document.selection?bagofholding:function(){var last=this.element.lastChild;if(!last||!this.isBreak(last)){this.element.appendChild($N('br'));}},fixNodes:document.selection?bagofholding:function(){var nodes=this.element.getElementsByTagName('a');for(var i=nodes.length;i--;){var node=nodes[i],next=node.nextSibling,prev=node.previousSibling;if(!prev||!prev.nodeValue.trim()){DOM.insertBefore(this.createSpacer(),node);}
if(!next||!next.nodeValue.trim()){DOM.insertAfter(node,this.createSpacer());}}}});var Text=(function(){if(window.getSelection){functions={getRange:function(selection){selection=selection||this.getSelection();return selection.rangeCount>0?selection.getRangeAt(0):null;},getSelection:function(){return window.getSelection();},getFocusNode:function(range){range=range||this.getRange();return range&&range.endContainer;},getFocusValue:function(range,node){range=range||this.getRange();node=node||this.getFocusNode(range);return node.data;},getFocusOffset:function(range,node){range=range||this.getRange();return range.endOffset||0;},setFocus:function(node,offset){if(!node){return;}
this.getSelection().collapse(node,offset);},setFocusAfter:function(node,offset){if(!offset&&offset!==0){offset=1;}
this.setFocus(node.nextSibling,offset);},insertBreak:function(){},selectNode:function(node){if(!node){return;}
var sel=this.getSelection(),range=this.getRange(sel);sel.collapse(node,0);range.selectNode(node);sel.addRange(range);}};}
else if(document.selection){functions={getRange:function(){return this.getSelection().createRange();},getSelection:function(){return document.selection;},getFocusNode:function(range,node){if(node){return node;}
range=range||this.getRange();return range.parentElement();},getFocusValue:function(range,node){range=range||this.getRange();node=node||this.getFocusNode(range);return node.innerText;},getFocusOffset:function(range,node){range=range||this.getRange();node=node||this.getFocusNode(range);var parent=node,offset=0;while(parent==node){range.moveStart('character',-1);parent=range.parentElement();offset++;}
return range.text.length;},setFocus:function(node,offset){var range=this.getRange();var element=range.parentElement();var length=0,children=[],prev=node.previousSibling;while(prev){var temp=prev.previousSibling;children.push(element.removeChild(prev));prev=temp;}
range.moveToElementText(element);range.collapse();range.moveEnd('character',(offset+length));range.collapse(false);range.select();for(var i=0;i<children.length;i++){element.insertBefore(children[i],element.firstChild);}},setFocusAfter:function(node){var range=this.getRange();range.moveToElementText(node);range.moveEnd('character',2);range.collapse(false);range.select();},insertBreak:function(){var range=this.getRange();range.pasteHTML('<br/>');range.moveEnd('character',1);range.collapse();range.select();},selectNode:function(node){var range=this.getRange();range.moveToElementText(node);range.moveStart('character',-1);range.moveEnd('character',1);range.select();}};}
return functions;})();

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,extraData){this.composer.addState(UIComposer.STATE.ATTACHMENT_AREA);this.attachment=attachment;this.dirtyOnReset=false;var app_id=attachment.app_id;if(this.cache[app_id]&&!extraData){this.showAttachment(app_id);}else{this.loadAttachment(app_id,extraData);}},loadAttachment:function(app_id,extraData){this.composer.refreshHeight();var data={app_id:app_id,composer_id:this.composer.id,stream_id:this.composer.target_id};if(extraData){copy_properties(data,{data:extraData});}
new AsyncRequest().setURI(UIComposerAttachmentArea.ENDPOINT).setData(data).setHandler(UIComposerAttachmentArea.handleResponse.bind(this,extraData)).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(forbid_override){if(this.attachment&&this.attachment.controller){return this.attachment.controller.getEndpoint(forbid_override);}
return null;},post:function(){if(!this.visible){return;}
var data=this.getData();var endpoint=this.getEndpoint(true);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,null)).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(extraData,response){var app_id=this.attachment.app_id;var attachment=this.cache[app_id];var payload=response.getPayload();var error=response.getError();var errIsWarning=response.getErrorIsWarning();if(error&&errIsWarning){UIComposer.showError(response.getErrorSummary(),response.getErrorDescription());}
if(!attachment){this.cache[app_id]=this.createAttachment(payload);this.dirtyOnReset=!!extraData;}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,overrides){this.initialize=this.initialize.bind(this,root,input,user,overrides);UIComposer.storeInstance(root.id,this);onunloadRegister(function(){delete UIComposer.instances[root.id];},true);if(overrides.autoload){this.ensureInitialized();}}
UIComposer.prototype={ensureInitialized:function(initialFocus){if(this.initialized){return;}
this.initialized=true;this.initialize(initialFocus);},initialize:function(root,input,user,overrides,initialFocus){var options={stream:null,target_id:0,autoload:null,endpoint:'/updatestatus.php',attachments:[],context_data:{},clear_message:true,privacy_widget:null,privacy_widget_options:{},input_max_length:0,typeahead_source:null,loc_activated:false};copy_properties(options,overrides);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.last_loc=null;this.initialFocus=initialFocus;this.user=user;this.stream=options.stream;this.endpoint=options.endpoint;this.target_id=options.target_id;this.source_app_id=options.source_app_id;this.context_data=options.context_data;this.clear_message=options.clear_message;this.privacy_widget=options.privacy_widget;this.override_attachment_endpoint=options.override_attachment_endpoint;this.privacy_widget_options=options.privacy_widget_options;if(options.loc_activated){this.addState(UIComposer.STATE.LOC_ACTIVATED);}
this.shouldHide=true;this.resetState=[root.className,UIComposer.STATE.INPUT_FOCUSED,UIComposer.STATE.ATTACHMENT_LIST].join(' ');this.initializeDialog();this.initializeTextarea(options.input_max_length,options.typeahead_source);this.initializeAttachments(options.attachments);this.initializeEvents();this.clearMessage();if(options.autoload){this.loadAttachment(options.autoload);}},initializeDialog:function(){var share=Dialog.newButton('share',_tx("Share"),null,function(){this.shouldHide=false;this.post();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,Dialog.CANCEL]).setTitle(_tx("Publish Story")).setContentWidth(width).setCancelHandler(function(){this.shouldHide=false;this.reset();return false;}.bind(this)).setStackable(true).setModal(true).setBody('');},initializeAttachments:function(attachments){if(!attachments.length){return;}
this.apps=attachments.map(function(attachment){return attachment.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);},initializeTextarea:function(maxLength,typeaheadSource){new TextAreaControl(this.input).setMaxLength(maxLength).setAutogrow(true).onfocus();this.input.onfocus='';var detector=new UrlDetector(this.input);detector.subscribe('urlDetected',this.autoScrape.bind(this));detector.setSuppressDetectionCheck(this.hasState.bind(this,UIComposer.STATE.ATTACHMENT_LOADED));if(this.initialFocus){detector.startDetectionInterval();}
if(!typeaheadSource){return;}
this.initializeTagger(typeaheadSource);},initializeTagger:function(source){if(!source||ua.firefox()<3||ua.safariPreWebkit()){return;}
var input=$N('div',{id:this.input.id,className:'Mentions_Input',contentEditable:true},document.createTextNode(''));CSS.setStyle(input,'width',this.input.offsetWidth+'px');DOM.replace(this.input,input);this.input=input;var initialize=function(){var mentionsInput=new typeahead_mentions(input,source);this.focusInput=mentionsInput.focusInput.bind(mentionsInput);this.getMessage=mentionsInput.getMessage.bind(mentionsInput);this.clearMessage=mentionsInput.clearMessage.bind(mentionsInput);removeEventBase(input,'focus',initialize);}.bind(this);addEventBase(input,'focus',initialize);},initializeEvents:function(){addEventBase(this.input,'focus',this.focus.bind(this));Event.listen(this.button,'click',this.post.bind(this));var loc_button=this.root.scry('a.UIComposer_LocationButton')[0];if(loc_button){loc_button.listen('click',this.toggleLocSetting.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(){this.ensureInitialized(true);if(this.attachmentList&&!this.hasState(UIComposer.STATE.ATTACHMENT_LIST)&&!this.hasState(UIComposer.STATE.ATTACHMENT_AREA)&&!this.hasState(UIComposer.STATE.ATTACHMENT_LIST_SHOWN)){this.attachmentList.show();}
if(!this.hasState(UIComposer.STATE.ATTACHMENT_AREA)){this.showPrivacyWidget();this.showLocWidget();if(this.hasState(UIComposer.STATE.LOC_ACTIVATED)){this.populateLoc();}}
return this.addState(UIComposer.STATE.INPUT_FOCUSED);},blur:function(){if(this.privacy_widget&&this.privacy_widget.dialogOpen()){if(!this.privacy_widget_token){this.privacy_widget_token=this.privacy_widget.subscribe('closeDialog',function(){this.privacy_widget.unsubscribe(this.privacy_widget_token);delete this.privacy_widget_token;}.bind(this));}}else{if(this.attachmentList&&this.hasState(UIComposer.STATE.ATTACHMENT_LIST)&&!this.hasState(UIComposer.STATE.ATTACHMENT_AREA)){this.removeState(UIComposer.STATE.INPUT_FOCUSED);if(!this.hasState(UIComposer.STATE.ATTACHMENT_LIST_SHOWN)){this.attachmentList.hide();}
this.hideLocWidget();if(!this.getMessage()){this.clearMessage();}}
if(!this.hasState(UIComposer.STATE.INPUT_FOCUSED)){this.hidePrivacyWidget();}
this.hidePrivacyWidgetCallout();}
return this;},autoScrape:function(event,url){this.loadAttachment(UIComposer.APP_ID_POSTED,null,{url:url});},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(){this.dialog.setBody(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;},setSourceAppId:function(app_id){this.source_app_id=app_id;return this;},getSourceAppId:function(){return this.source_app_id;},loadAttachment:function(app_id,action,extraData){this.ensureInitialized();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,null,extraData);this.focus();},showAttachment:function(attachment,extraData){if(attachment.supports_privacy){this.showPrivacyWidget();}else{this.hidePrivacyWidget();}
this.hideLocWidget();this.setAttachmentColSpan(1);this.attachmentArea.show(attachment,extraData);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.removeLoc();this.refreshHeight(callback);this.enable();if(clearMessage){this.clearMessage();}
if(focusInput!==false){this.focusInput();}
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);},toggleState:function(state){CSS.toggleClass(this.root,state);return this;},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;},getPrivacyData:function(){if(this.privacy_widget){return this.privacy_widget.getData();}
return null;},getData:function(endpoint){var data={};var message=this.getMessage();if(message&&(/@\[\d+:.+\]/).test(message)){Util.log(message);return null;}
if(endpoint==this.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,app_id:this.source_app_id,privacy_data:{}});if(this.last_loc){this.last_loc.timestamp=Math.floor(this.last_loc.timestamp.getTime()/1000);data.composer_loc_data=JSON.encode(this.last_loc);}
if(this.attachmentArea&&this.attachmentArea.visible){copy_properties(data,this.attachmentArea.getData());}}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(this.attachmentArea.attachment.supports_privacy){data.privacy_data={};}}}
if(data){data.composer_id=this.id;if(this.privacy_widget&&data.privacy_data){copy_properties(data.privacy_data,this.getPrivacyData());}
if(this.context_data){copy_properties(data,this.context_data);}}
return data;},getEndpoint:function(){var endpoint;if(this.hasState(UIComposer.STATE.ATTACHMENT_LOADED)){endpoint=this.attachmentArea.getEndpoint();}
return endpoint||this.endpoint;},post:function(){if(this.isDisabled()){return;}
if(this.privacy_widget_options.everyone_warning&&this.privacy_widget&&this.privacy_widget.isEveryonePrivacy()){this.showConfirmEveryonePrivacyDialog();return;}
this._post();},_post:function(){var endpoint=this.getEndpoint();var data=this.getData(endpoint);this.logActions();if(!data){return;}
this.disable();new AsyncRequest().setURI(endpoint).setData(data).setHandler(bind(this,handle_require_email_conf_response,UIComposer.handleResponse.bind(this),null,null)).setErrorHandler(UIComposer.handleError.bind(this)).setFinallyHandler(this.enable.bind(this)).send();},logActions:function(){var data={target_id:this.target_id};if(this.attachments&&!is_empty(this.attachmentArea.attachment)){data.app_id=this.attachmentArea.attachment.app_id;}
if(this.privacy_widget){data.privacy_default_value=this.privacy_widget.getDefaultValue();data.privacy_value=this.privacy_widget.getValue();}
new AsyncSignal('/ajax/composer/logging.php',data).send();},publish:function(response){var stream=this.stream;if(stream){var markup=response,status,story;if(response.getPayload){var payload=response.getPayload();status=payload.status;markup=payload.markup;if(payload.payload_is_content){story=payload;}}
story=story||HTML(markup).getRootNode();var displayDelay=500;stream.addContent(story,displayDelay);if(stream.setStatus&&status){setTimeout(function(){stream.setStatus(status);},displayDelay);}}
if(this.privacy_widget){this.privacy_widget.reset();}
return this;},populateLoc:function(){var new_results=false;var _populateLoc=function(pos){if(!this.hasState(UIComposer.STATE.LOC_ACTIVATED)||!this.hasState(UIComposer.STATE.INPUT_FOCUSED)||this.hasState(UIComposer.STATE.ATTACHMENT_AREA)){return;}
if(this.last_loc&&new_results!==false&&pos.coords.accuracy>=this.last_loc.coords.accuracy){return;}
new_results=true;var desc=pos.desc.label||pos.desc.street||pos.desc.region;if(!desc){return;}
var field=this.root.find('div.UIComposer_LocationField');field.setContent(_tx("near {place}",{place:desc}));this.last_loc=pos;if(!shown(field)){animation(field).to('height','auto').from('height',0).show().duration(100).ease(animation.ease.end).go();}};var error_count=0;var _errorCase=function(locError){if(++error_count>=2){return this.removeLoc();}};var _finder=function(){navigator.geolocation.getCurrentPosition(_populateLoc.bind(this),_errorCase.bind(this),{maximumAge:1000*60*60,enableHighAccuracy:false});navigator.geolocation.getCurrentPosition(_populateLoc.bind(this),_errorCase.bind(this),{maximumAge:1000*60*10,enableHighAccuracy:true});};Bootloader.loadComponents(['geolocation'],_finder.bind(this));},removeLoc:function(){var field=this.root.scry('div.UIComposer_LocationField')[0];if(field){field.empty();hide(field);}
this.last_loc=null;},toggleLocSetting:function(){this.toggleState(UIComposer.STATE.LOC_ACTIVATED);var loc_activated=this.hasState(UIComposer.STATE.LOC_ACTIVATED);new AsyncRequest('/ajax/geo/setting.php').setData({collect:loc_activated}).setErrorHandler(bagofholding).setTransportErrorHandler(bagofholding).send();if(loc_activated){this.populateLoc();}else{this.removeLoc();}
return false;},showLocWidget:function(){this.addState(UIComposer.STATE.LOC_WIDGET_SHOWN);},hideLocWidget:function(){this.removeLoc();this.removeState(UIComposer.STATE.LOC_WIDGET_SHOWN);},showPrivacyWidget:function(){this.addState(UIComposer.STATE.PRIVACY_WIDGET_SHOWN);if(this.privacy_widget_options.callout){this.showPrivacyWidgetCallout();}},hidePrivacyWidget:function(){this.removeState(UIComposer.STATE.PRIVACY_WIDGET_SHOWN);this.hidePrivacyWidgetCallout();},showPrivacyWidgetCallout:function(){CSS.setStyle(this.root.find('div.UIComposer_PrivacyWidgetCallout'),'display','block');},hidePrivacyWidgetCallout:function(){var nodes=this.root.scry('div.UIComposer_PrivacyWidgetCallout');if(nodes.length){CSS.setStyle(nodes[0],'display','none');}},closePrivacyWidgetCallout:function(){this.savePrivacyWidgetData('close','callout');this.hidePrivacyWidgetCallout();},savePrivacyWidgetData:function(data_key,response_key,callback){response_key=response_key||data_key;callback=callback||bagofholding;var data={};data[data_key]=true;new AsyncRequest().setData(data).setURI('/ajax/privacy/save_composer_data.php').setHandler(function(response){var payload=response.getPayload();this.privacy_widget_options[response_key]=payload[response_key];callback();}.bind(this)).setErrorHandler(bagofholding).setTransportErrorHandler(bagofholding).send();},showConfirmEveryonePrivacyDialog:function(){new Dialog().setAsync(new AsyncRequest().setURI('/ajax/privacy/confirm_everyone_dialog.php')).setHandler(this.savePrivacyWidgetData.bind(this,'seen_everyone','everyone_warning',this._post.bind(this))).show();},getContextData:function(){return this.context_data;},focusInput:function(){this.input.select();this.input.focus();},getMessage:function(){return this.input.value.trim();},clearMessage:function(){this.input.value='';this.input.setStyle('height','');}};copy_properties(UIComposer,{instances:{},getInstance:function(id){return this.instances[id]||null;},storeInstance:function(id,composer){this.instances[id]=composer;},focusInstance:function(id){var instances=this.instances;onloadRegister(function(){instances[id].focus();setTimeout(function(){instances[id].input.focus();},0);});},handleError:function(response){var error=response.getError();var payload=response.getPayload();switch(error){case kError_Platform_CallbackValidationFailure:return UIComposer.showError(payload.errorTitle,payload.errorMessage);case kError_Platform_ApplicationResponseInvalid:return UIComposer.showError(payload.errorTitle,payload.showDebug);default:this.shouldHide=false;this.reset();return UIComposer.showError(response.getErrorSummary(),response.getErrorDescription());}},handleResponse:function(response){var error=response.getError();var errIsWarning=response.getErrorIsWarning();this.reset(this.clear_message).publish(response);if(error&&errIsWarning){UIComposer.showError(response.getErrorSummary(),response.getErrorDescription());}},showError:function(title,message){new ErrorDialog().setTitle(title).setBody(message||_tx("There was an application error. Please try again later.")).setButtons([Dialog.OK]).show();},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,APP_ID_POSTED:2309869772,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},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_LIST_SHOWN:'UIComposer_STATE_ATTACHMENT_LIST_SHOWN',ATTACHMENT_AREA:'UIComposer_STATE_ATTACHMENT_AREA',ATTACHMENT_LOADED:'UIComposer_STATE_ATTACHMENT_LOADED',PRIVACY_WIDGET_SHOWN:'UIComposer_STATE_PRIVACY_WIDGET_SHOWN',LOC_ACTIVATED:'UIComposer_STATE_LOC_ACTIVATED',LOC_WIDGET_SHOWN:'UIComposer_STATE_LOC_WIDGET_SHOWN'}});

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,extraData){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,extraData);}.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 OnVisible(element,handler){this.targetY=Vector2.getElementPosition(element).y;var scroll_listener=function(){var y=Vector2.getScrollPosition().y+
Vector2.getViewportDimensions().y;if(y>this.targetY){this.remove();handler();}
return true;}.bind(this);if(DOMScroll.usingScrollWrapper()){var scroll_target=DOMScroll.getScrollRoot();}else{var scroll_target=window;}
this.scrollListener=Event.listen(scroll_target,'scroll',scroll_listener);this.resizeListener=Event.listen(window,'resize',scroll_listener);scroll_listener();}
copy_properties(OnVisible.prototype,{remove:function(){if(this.scrollListener){this.scrollListener.remove();this.resizeListener.remove();this.scrollListener=this.resizeListener=null;}}});

function UIIntentionalStream(root,instanceName,newest,oldest,hiddenCount,hiddenIDCount,storyCount,hasAdditionalStories){if(!root){throw new Error('UIIntentionalStream instantiated with no root.');}
copy_properties(this,{id:root.id,root:root,instanceName:instanceName,newest:newest,oldest:oldest,hiddenCount:hiddenCount,hiddenIDCount:hiddenIDCount,storyCount:storyCount,hasAdditionalStories:hasAdditionalStories,isAutoRefreshing:false,hasPendingRefresh:false,storyInterval:null,lastRefresh:new Date().getTime(),presenceCheckCounter:0,storyQueue:[],storyQueueCount:0,showNewStories:root.find('div.UIIntentionalStream_ShowNewStories'),showNewStoriesMsg:root.find('a.UIIntentionalStream_ShowNewStories_Msg'),pageloadTime:new Date().getTime(),heavyRefreshCount:0,pushRefreshCount:0,pollRefreshCount:0,scrollLoadIsDone:false,error:root.find('div.UIIntentionalStream_Error'),pager:root.find('div.UIIntentionalStream_Pager'),showMore:root.find('div.UIIntentionalStream_ShowMore'),hiddenInfo:root.find('div.UIIntentionalStream_HiddenInfo'),streamContent:root.find('div.UIIntentionalStream_Content'),requestNum:0,firstStory:null,forceRefresh:false});this.setAutoRefreshConfig({});onunloadRegister(this.unload.bind(this));this.userActivity();this.updateFirstStory();this.updatePager();CSS.removeClass(this.pager,'hidden_elem');this.uaToken=UserActivity.subscribe(this.userActivity.bind(this));if(!UIIntentionalStream.instances){UIIntentionalStream.instances={};}
UIIntentionalStream.instances[instanceName]=this;UIIntentionalStream.instance=this;}
UIIntentionalStream.prototype.unload=function(){if(this.logDetail&&this.allowAutoRefresh){var open_time=new Date().getTime()-this.pageloadTime;scribe_log('nile_refresh_detail','unload_stat '+open_time+' '+this.heavyRefreshCount+' '+this.pushRefreshCount+' '+this.pollRefreshCount);}
this.enableAutoRefresh(false);UIIntentionalStream.instance=null;UIIntentionalStream.instances[this.instanceName]=null;UserActivity.unsubscribe(this.uaToken);this.clearScrollLoader();}
UIIntentionalStream.getInstance=function(instanceName){return UIIntentionalStream.instances[instanceName];}
UIIntentionalStream.handleNewStoryMessage=function(channel,obj){if(obj.type=='feedpub'){var stream=UIIntentionalStream.instance;if(stream&&!stream.queueIsFull()){stream.pushRefreshCount++;stream.updateStream();}
return true;}
return false;}
UIIntentionalStream.callOnInstance=function(fn_name){return function(){if(UIIntentionalStream.instance){var fn=UIIntentionalStream.instance[fn_name];return fn.apply(UIIntentionalStream.instance,arguments);}else{return null;}}}
UIIntentionalStream.prototype.presenceStreamCheck=function(time,asyncData,forceUpdate){if(!this.allowAutoRefresh||!this.presenceLoopPerPoll){return false;}
if(!presenceNotifications.requiresUpdate(time,asyncData,forceUpdate)){return false;}
if(!this.needsRefresh()){return false;}
++this.presenceCheckCounter;if(this.presenceCheckCounter>=this.presenceLoopPerPoll){var extraData=this.getCurrentParams();extraData.newest=this.newest;extraData.last_refresh=this.getMSSinceLastRefresh();this.lastPresenceRequestNum=++this.requestNum;asyncData['stream_query']=extraData;this.presenceCheckCounter=0;return true;}
return false;}
UIIntentionalStream.prototype._getUpdateInsertType=function(){if(this.isDarkRefresh){return UIIntentionalStream.REFRESH_DARK;}else if(this.queueNewStories){return UIIntentionalStream.REFRESH_QUEUE;}else{return UIIntentionalStream.REFRESH_PREPEND;}}
UIIntentionalStream.prototype.presenceStreamResponse=function(payload,time){this.lastRefresh=new Date().getTime();this.heavyRefreshCount++;this.handleResponsePayload(this.lastPresenceRequestNum,this._getUpdateInsertType(),payload);this.lastPresenceRequestNum=0;}
UIIntentionalStream.prototype.setStoryInterval=function(rate){this.storyInterval=rate;return this;}
UIIntentionalStream.prototype.setAutoRefreshConfig=function(config){config=config||{};var long_time=24*60*60*1000;this.allowAutoRefresh=coalesce(config.allow_auto_refresh,false);this.inactiveThreshold=coalesce(config.inactive_threshold,0);this.activeRefreshTime=coalesce(config.fast_refresh_rate,long_time);this.inactiveRefreshTime=coalesce(config.slow_refresh_rate,long_time);this.allowPolling=coalesce(config.allow_polling,false);this.refreshFactor=coalesce(config.refresh_factor,10);this.queueNewStories=coalesce(config.queue_new_stories,true);this.isDarkRefresh=coalesce(config.dark,false);this.presenceLoopPerPoll=coalesce(config.presence_loop_per_poll,0);this.maxQueueSize=coalesce(config.max_queue_size,0);this.minRefreshInterval=coalesce(config.min_refresh_interval,60*1000);this.logDetail=coalesce(config.log_detail,false)
return this;}
UIIntentionalStream.prototype.queueIsFull=function(){return(this.maxQueueSize&&this.storyQueueCount>=this.maxQueueSize);}
UIIntentionalStream.prototype.shouldAutoRefresh=function(){return this.isAutoRefreshing&&this.allowAutoRefresh;}
UIIntentionalStream.prototype.userActivity=function(){var wasInactive=this.isInactive();this.lastActivity=(new Date().getTime());if(wasInactive&&this.allowAutoRefresh&&this.needsRefresh()){this.updateStream();this.schedulePoll(this.getRefreshInterval());}
return true;}
UIIntentionalStream.prototype.getMSSinceLastActivity=function(){return(new Date().getTime())-this.lastActivity;}
UIIntentionalStream.prototype.getMSSinceLastRefresh=function(){return(new Date().getTime())-this.lastRefresh;}
UIIntentionalStream.prototype.isInactive=function(){return this.getMSSinceLastActivity()>this.inactiveThreshold;}
UIIntentionalStream.prototype.getRefreshInterval=function(){if(this.isInactive()){return this.inactiveRefreshTime;}else{if(this.storyInterval!=null){var interval=this.storyInterval*this.refreshFactor;return Math.max(interval,this.activeRefreshTime);}else{return this.activeRefreshTime;}}}
UIIntentionalStream.prototype.enableAutoRefresh=function(enabled,immediate){this.isAutoRefreshing=enabled;if(enabled){var delay=immediate?0:this.getRefreshInterval();this.schedulePoll(delay);}else{this.cancelUpdate();}}
UIIntentionalStream.prototype.cancelUpdate=function(){if(this.updateTask){clearTimeout(this.updateTask);this.updateTask=null;}}
UIIntentionalStream.prototype.schedulePoll=function(delay){this.cancelUpdate();if(this.allowPolling){this.updateTask=setTimeout(this.runUpdatePoll.bind(this),delay);}}
UIIntentionalStream.prototype.needsRefresh=function(){return!(this.queueIsFull()||this.hasPendingRefresh||this.getMSSinceLastRefresh()<this.minRefreshInterval);}
UIIntentionalStream.prototype.runUpdatePoll=function(){this.updateTask=null;if(!this.shouldAutoRefresh()){return;}
if(this.needsRefresh()){this.pollRefreshCount++;this.updateStream();}
this.schedulePoll(this.getRefreshInterval());}
UIIntentionalStream.prototype.updateStream=function(flush_on_complete){if(!this.allowAutoRefresh){return;}
this.loadNewer({showLoader:false,ignoreSelf:true,flushOnComplete:flush_on_complete,insertType:this._getUpdateInsertType()});}
UIIntentionalStream.prototype.clearScrollLoader=function(){if(this.currentScrollListener){this.currentScrollListener.remove();this.currentScrollListener=null;}
this.scrollLoadIsDone=true;}
UIIntentionalStream.prototype.loadMoreOnScroll=function(loadMoreStoryID,count){if(this.scrollLoadIsDone){return;}
var scroll_handler=function(){this.clearScrollLoader();this.loadOlder({count:count,showLoader:false});}.bind(this);if(ge(loadMoreStoryID)){this.currentScrollListener=new OnVisible($(loadMoreStoryID),scroll_handler);}else{this.scroll_handler();}}
UIIntentionalStream.prototype.updatePageCache=function(){this.loadNewer({bundleAsync:true,showLoader:false});}
UIIntentionalStream.prototype.getID=function(){return this.id;}
UIIntentionalStream.prototype.showPositioned=function(element,type,kwargs){if(type==UIIntentionalStream.REFRESH_APPEND){this.root.appendContent(element);}else if(type==UIIntentionalStream.REFRESH_PREPEND){this.root.prependContent(element);}else if(type==UIIntentionalStream.REFRESH_EXPAND){DOM.insertAfter($(kwargs.expandStoryID),element);}
element.setStyle('display','block');if(element.src){element.src=element.src;}}
UIIntentionalStream.showHidden=function(){var req=URI.getRequestURI();req.addQueryData({'show_hidden':true});goURI(req);DOMScroll.scrollTo($('home_stream'),false);return false;}
UIIntentionalStream.prototype.showHiddenPeople=function(filterKey){if(filterKey==undefined){filterKey=this.getCurrentFilterKey();}
var onModified=function(){var data=this.getCurrentParams();this.refresh(UIIntentionalStream.REFRESH_TRANSITION,data);DOMScroll.scrollTo($('home_stream'),false);}.bind(this);NewsFeedEditor.show(filterKey,onModified);return false;}
UIIntentionalStream.prototype.getCurrentFilterKey=function(){var params=this.getCurrentParams();if(params){return params.filter;}
return null;}
UIIntentionalStream.prototype.loadOlder=function(kwargs){kwargs=kwargs||{};if(!this.oldest){return;}
var params=this.getCurrentParams();params.oldest=this.oldest;if(kwargs.count){params.delay_load_count=kwargs.count;}
this.refresh(UIIntentionalStream.REFRESH_APPEND,params,kwargs);return this;}
UIIntentionalStream.prototype.loadNewer=function(kwargs){if(!this.newest){return;}
kwargs=kwargs||{};var extraData=this.getCurrentParams();extraData.newest=this.newest;if(kwargs.ignoreSelf){extraData.ignore_self=true;}
var type=coalesce(kwargs.insertType,UIIntentionalStream.REFRESH_PREPEND);this.lastRefresh=new Date().getTime();this.refresh(type,extraData,kwargs);return this;}
UIIntentionalStream.prototype.getCurrentParams=function(){var params={};var qdata=URI.getRequestURI(true,true).getQueryData();var valid_param=this.getValidParams();if(valid_param){valid_param.forEach(function(i){params[i]=qdata[i];});}else{params=qdata;}
params.hidden_count=this.hiddenCount||0;return params;}
UIIntentionalStream.prototype.setHomeFilter=function(home_filter){this._homeFilter=home_filter;}
UIIntentionalStream.prototype.setHomeFilterLoading=function(loading){if(this._homeFilter){this._homeFilter.setLoading(loading);}}
UIIntentionalStream.prototype.refresh=function(type,data,kwargs){kwargs=kwargs||{};var requestNum=++this.requestNum;var bundleAsync=coalesce(kwargs.bundleAsync,false);var showLoader=coalesce(kwargs.showLoader,true);var instanceName=this.instanceName;var handler=function(response){UIIntentionalStream.getInstance(instanceName).handleResponse(requestNum,type,response,kwargs);};var errHandler=function(response){UIIntentionalStream.getInstance(instanceName).handleError(requestNum,type,response);};var finallyHandler=function(response){UIIntentionalStream.getInstance(instanceName).handleFinally(type,response);};if(!data.request_type){data.request_type='none';}
var is_replayable=true;if(data.newest){is_replayable=false;}
this.hasPendingRefresh=true;new AsyncRequest().setURI(this.getEndpoint()).setReadOnly(true).setOption('retries',0).setMethod('GET').setData(data).setOption('bundle',bundleAsync).setReplayable(is_replayable).setHandler(handler).setErrorHandler(errHandler).setTransportErrorHandler(errHandler).setFinallyHandler(finallyHandler).send();if(type==UIIntentionalStream.REFRESH_TRANSITION){this.storyCount=0;this.hasAdditionalStories=true;hide(this.pager);this.clearQueue();this.clearScrollLoader();this.oldest=this.newest=null;}
if(type==UIIntentionalStream.REFRESH_APPEND&&showLoader){this.pager.addClass('UIIntentionalStream_PagerLoading');}
if(showLoader){this.setHomeFilterLoading(true);}}
UIIntentionalStream.prototype.updateFirstStory=function(content){content=$(content||this.streamContent);var story=content.scry(UIIntentionalStream.FIRST_STORY_SELECTOR)[0];if(this.firstStory){CSS.removeClass(this.firstStory,UIIntentionalStream.FIRST_STORY_CLASS);}
if(story){CSS.addClass(story,UIIntentionalStream.FIRST_STORY_CLASS);}
this.firstStory=story;}
UIIntentionalStream.prototype.addContent=function(content,delay){CSS.addClass(content,UIIntentionalStream.FIRST_STORY_CLASS);this.addContentPrepend($N('div',{className:'UIStream'},content),delay);}
UIIntentionalStream.prototype.addContentPrepend=function(content,delay){this.updateFirstStory(content);if(ua.ie()<=7){CSS.setStyle(content,'display','none');this.streamContent.prependContent(content);setTimeout(function(){CSS.setStyle(content,'display','');},delay);}else{CSS.setStyle(content,'overflow','hidden');CSS.setStyle(content,'height','0px');CSS.setOpacity(content,'0');this.streamContent.prependContent(content);var anim=animation(content).to('height','auto').to('opacity','1').duration(UIIntentionalStream.ANIMATION_DURATION);if(delay){setTimeout(anim.go.bind(anim),delay);}else{anim.go();}}}
UIIntentionalStream.prototype.addContentAppend=function(content){this.streamContent.appendContent(content);this.clearFirst(content);}
UIIntentionalStream.prototype.unfollow=function(data){var asyncData={value:data.id,action:'unfollow',filter_key:this.getCurrentFilterKey()};var asyncHandler=function(){var count=UIIntentionalStream.forEachStory(data.id,hide);this.hiddenCount+=count;this.hiddenIDCount++;this.updatePager();}.bind(this);new AsyncRequest().setURI('/ajax/feed/filter_action.php').setData(asyncData).setReplayable(true).setHandler(asyncHandler).send();var selected_story=$(data.storyID);var msg_div=$N('div',{className:'unfollow_message'});var undo_link=$N('a',{className:'unfollow_undo','href':'#'},HTML(_tx("Undo")));var show_hidden_link=$N('a',{onclick:this.showHiddenPeople.shield(this)},HTML(_tx("Edit Options")));undo_link.listen('click',this.undoUnfollow.bind(this,data,msg_div));var unfollow_msg;if(!data.isApp){unfollow_msg=_tx("<strong>{name} has been hidden from your News Feed.<\/strong><br>In the future, you won't see posts from {first_name}.  ",{'name':data.name,'first_name':data.firstName});}else{unfollow_msg=_tx("<strong>{application} has been hidden from your News Feed.<\/strong><br>In the future, you won't see posts from {application}.  ",{'application':data.name});}
msg_content=[undo_link,HTML(unfollow_msg),' (',show_hidden_link,')'];msg_div.setContent($N('p',msg_content));hide(msg_div);DOM.insertBefore(msg_div,selected_story);var count=UIIntentionalStream.forEachStory(data.id,hide);CSS.setOpacity(msg_div,'0');show(msg_div);if(count>1){DOMScroll.scrollTo(msg_div,false,true);}
animation(msg_div).to('opacity','1').duration(UIIntentionalStream.ANIMATION_DURATION).ondone(function(){setTimeout(function(){animation(msg_div).to('opacity','0').checkpoint().ease(animation.ease.both).to('height','0').to('padding','0').blind().duration(UIIntentionalStream.ANIMATION_DURATION).ondone(function(){if(msg_div.parentNode){msg_div.remove();}}).go();},10*1000);}).go();return false;}
UIIntentionalStream.forEachStory=function(id,fn){var stories=UIIntentionalStream.getStoriesByAssoc(id);stories.forEach(fn);return stories.length;}
UIIntentionalStream.prototype.undoUnfollow=function(data,msg_div){var asyncData={value:data.id,action:'undo_unfollow',filter_key:this.getCurrentFilterKey()};var asyncHandler=function(){var count=UIIntentionalStream.forEachStory(data.id,show);this.hiddenCount-=count;this.hiddenIDCount--;this.updatePager();}.bind(this);new AsyncRequest().setURI('/ajax/feed/filter_action.php').setData(asyncData).setReplayable(true).setHandler(asyncHandler).send();var count=UIIntentionalStream.forEachStory(data.id,show);if(count>1){DOMScroll.scrollTo(msg_div,false,true);}
msg_div.remove();return false;}
UIIntentionalStream.prototype.updatePager=function(){var show_hidden_link=null;var edit_prefs_link=null;if(this.hiddenCount>0){var story_count_text;if(this.hiddenCount==1){story_count_text=_tx("1 Hidden Post");}else{story_count_text=_tx("{count} Hidden Posts",{'count':this.hiddenCount});}
show_hidden_link=$N('a',{href:'#'},_tx("Show {count-stories}",{'count-stories':story_count_text}));Event.listen(show_hidden_link,'click',UIIntentionalStream.showHidden);}
if(this.hiddenIDCount>0){edit_prefs_link=$N('a',{href:'#'},_tx("Edit Options"));Event.listen(edit_prefs_link,'click',this.showHiddenPeople.shield(this));}
var bottom_info='';if(show_hidden_link&&edit_prefs_link){bottom_info=[show_hidden_link,HTML(' &#183; '),edit_prefs_link];}else if(show_hidden_link){bottom_info=[show_hidden_link];}else if(edit_prefs_link){bottom_info=[edit_prefs_link];}
if(!this.storyCount||!this.hasAdditionalStories){hide(this.showMore);if(this.hiddenIDCount){show(this.pager);}else{hide(this.pager);}}else{show(this.showMore);show(this.pager);}
DOM.setContent(this.hiddenInfo,bottom_info);}
UIIntentionalStream.getStoriesByAssoc=function(assoc){return DOM.scry(UIIntentionalStream.instance.root,'div.aid_'+assoc);}
UIIntentionalStream.prototype.handleResponse=function(requestNum,type,response,kwargs){return this.handleResponsePayload(requestNum,type,response.getPayload(),response.isReplay(),kwargs);}
UIIntentionalStream.prototype.handleResponsePayload=function(requestNum,type,payload,ignore_request_num,kwargs){kwargs=kwargs||{};if(is_empty(payload)){return;}
if(payload.autoRefreshConfig){this.setAutoRefreshConfig(payload.autoRefreshConfig);}
this.setHomeFilterLoading(false);if(type==UIIntentionalStream.REFRESH_APPEND){this.pager.removeClass('UIIntentionalStream_PagerLoading');}
if(type==UIIntentionalStream.REFRESH_EXPAND){$(kwargs.expandStoryID).find('div.UIIntentionalStory_CollapsedStories').removeClass('UIIntentionalStory_CollapsedStoriesLoading').addClass('hidden_elem');}
hide(this.error);if(!ignore_request_num&&requestNum!=this.requestNum){return;}
this.hiddenCount=payload.hiddenCount;this.hiddenIDCount=payload.hiddenIDCount;this.storyCount+=payload.storyCount;if('newestStoryTime'in payload&&payload.newestStoryTime>this.newest){this.newest=payload.newestStoryTime;}
if('oldestStoryTime'in payload&&(!this.oldest||payload.oldestStoryTime<this.oldest)){this.oldest=payload.oldestStoryTime;}
if('hasAdditionalStories'in payload){this.hasAdditionalStories=payload.hasAdditionalStories;}else if(type==UIIntentionalStream.REFRESH_APPEND&&payload.storyCount==0){this.hasAdditionalStories=false;}
this.updatePager();if(payload.html){var content=HTML(payload.html).getRootNode();switch(type){case UIIntentionalStream.REFRESH_QUEUE:this.queueStories(content,payload.storyCount);break;case UIIntentionalStream.REFRESH_PREPEND:this.addContentPrepend(content);break;case UIIntentionalStream.REFRESH_APPEND:this.addContentAppend(content);this.clearScrollLoader();break;case UIIntentionalStream.REFRESH_TRANSITION:this.streamContent.setContent(content);this.updateFirstStory();DOMScroll.scrollTo(new Vector2(0,0,"document"),false);break;case UIIntentionalStream.REFRESH_DARK:break;case UIIntentionalStream.REFRESH_EXPAND:CSS.setStyle(content,'overflow','hidden');CSS.setOpacity(content,'0');DOM.insertAfter($(kwargs.expandStoryID),content);animation(content).to('opacity','1').duration(UIIntentionalStream.ANIMATION_DURATION).go();break;}}
if(kwargs.flushOnComplete){this._flushQueue();}}
UIIntentionalStream.prototype.clearQueue=function(delay){delay=delay||0;this.storyQueue=[];this.storyQueueCount=0;if(delay){setTimeout(function(){animation(this.showNewStories).to('opacity','0').checkpoint().to('height','0').hide().duration(150).go();}.bind(this),delay);}else{hide(this.showNewStories);}}
UIIntentionalStream.prototype.flushQueue=function(){if(this.getMSSinceLastRefresh()<this.minRefreshInterval){this._flushQueue();}else{this.updateStream(true);}}
UIIntentionalStream.prototype._flushQueue=function(){var stories=[];var newStories=$N('div',{className:'UIStream'});this.storyQueue.forEach(function(stream,i){if(i!=0){this.clearFirst(stream);}
newStories.appendContent($A(stream.childNodes));stream.remove();}.bind(this));this.addContentPrepend(newStories);this.clearQueue(UIIntentionalStream.ANIMATION_DURATION);}
UIIntentionalStream.prototype.clearFirst=function(content){var first=DOM.scry(content,UIIntentionalStream.FIRST_STORY_SELECTOR)[0];if(first){CSS.removeClass(first,UIIntentionalStream.FIRST_STORY_CLASS);}}
UIIntentionalStream.prototype.queueStories=function(content,numStories){var showMessage=(this.storyQueueCount==0);hide(content);this.streamContent.prependContent(content);this.storyQueue=[content].concat(this.storyQueue);var countString='';if(numStories){this.storyQueueCount+=numStories;countString=this.storyQueueCount;}
var msg;if(this.storyQueueCount==1){msg=_tx("SHOW 1 NEW POST");}else{msg=_tx("SHOW {count} NEW POSTS",{count:countString});}
this.showNewStoriesMsg.setContent(HTML(msg));if(showMessage){CSS.setStyle(this.showNewStories,'height','0');CSS.setStyle(this.showNewStories,'display','block');animation(this.showNewStories).to('height','auto').to('opacity','1').go();}}
UIIntentionalStream.prototype.handleError=function(requestNum,type,response){if(!response.isReplay()&&requestNum!=this.requestNum){return;}
this.setHomeFilterLoading(false);if(type==UIIntentionalStream.REFRESH_PREPEND){this.pager.removeClass('UIIntentionalStream_PagerLoading');}
if(type==UIIntentionalStream.REFRESH_EXPAND){$(kwargs.expandStoryID).find('div.UIIntentionalStory_CollapsedStories').removeClass('UIIntentionalStory_CollapsedStoriesLoading');}
var error=response.getError();if(error==kError_Async_NotLoggedIn){var title=_tx("Feed Error");var msg=_tx("Your session has timed out. Please {login}.",{'login':'<a href="/login.php">'+_tx("log in")+'</a>'});new ErrorDialog().showError(title,msg);}
if(type!=UIIntentionalStream.REFRESH_PREPEND){this.showPositioned(this.error,type);}}
UIIntentionalStream.prototype.handleFinally=function(type){if(type==UIIntentionalStream.REFRESH_TRANSITION){PageTransitions.transitionComplete();}
this.hasPendingRefresh=false;}
UIIntentionalStream.prototype.getValidParams=function(){return UIIntentionalStream.VALID_PARAMS;}
UIIntentionalStream.prototype.getEndpoint=function(){return UIIntentionalStream.ENDPOINT;}
copy_properties(UIIntentionalStream,{ANIMATION_DURATION:300,REFRESH_TRANSITION:1,REFRESH_PREPEND:2,REFRESH_APPEND:3,REFRESH_QUEUE:4,REFRESH_DARK:5,REFRESH_EXPAND:6,FIRST_STORY_CLASS:'UIIntentionalStory_First',FIRST_STORY_SELECTOR:'div.UIIntentionalStory_First',PAGER_SELETOR:'div.UIIntentionalStream_Pager',PAGER_INNER_SELETOR:'div.UIIntentionalStream_PagerInner',VALID_PARAMS:['filter','show_hidden'],ENDPOINT:'/ajax/intent.php',_presenceInit:false});UIIntentionalStream.presenceRegister=function(){if(UIIntentionalStream._presenceInit){return true;}
var checkCB=UIIntentionalStream.callOnInstance('presenceStreamCheck');var responseCB=UIIntentionalStream.callOnInstance('presenceStreamResponse');presenceUpdater.register('stream_update',checkCB,responseCB,bagofholding,bagofholding);presence.registerMsgHandler(UIIntentionalStream.handleNewStoryMessage);UIIntentionalStream._presenceInit=true;};UIIntentionalStream.prototype.showHighlightsIHeader=function(){var highlightsIHeader=this.streamContent.find('div.UIIntentionalStream_HighlightsHeader');CSS.setStyle(highlightsIHeader,'height','0');CSS.setStyle(highlightsIHeader,'opacity','0');CSS.setStyle(highlightsIHeader,'display','block');animation(highlightsIHeader).to('height','auto').to('opacity','1').duration(UIIntentionalStream.ANIMATION_DURATION*3).go();}

UIIntentionalStory={setup:function(root,data){if(!root||!data){return null;}
if(data.unfollow){var hover=Event.listen(root,'mouseover',function(){this.createUnfollowMenu(root,data);hover.remove();}.bind(this));}},createUnfollowMenu:function(root,data){var menuRoot=root.scry('div.UIStory_Hide')[0];if(!menuRoot){return;}
var title=data.title;data=data.unfollow;var menu=new UIActionMenu();var list=new UISelectList();var listCallback=function(root,menu,list,checked,data){menu.hideMenu();list.reset();var unfollowData=copy_properties({storyID:root.id},data);UIIntentionalStream.instance.unfollow(unfollowData);}.bind(this,root,menu,list);list.setMode(UISelectList.SINGLE_SELECT_MODE).setCallback(listCallback);data.users.each(function(user){list.addItem(HTML(user.hideString),false,user);});if(data.app){list.addItem(HTML(data.app.hideString),false,data.app);}
menu.setTitle(title).setContentCallback(list.getElement.bind(list)).setSuppressButton(true).setAlignRight(true);menuRoot.setContent(menu.getNodes());},_moreDetails:{},expandStory:function(story_id,actor_id,newest,oldest){var data=UIIntentionalStream.instance.getCurrentParams();data.expand_story_uid=actor_id;data.newest=newest;data.oldest=oldest;var kwargs={expandStoryID:story_id,showLoader:false};$(story_id).find('div.UIIntentionalStory_CollapsedStories').addClass('UIIntentionalStory_CollapsedStoriesLoading');UIIntentionalStream.instance.refresh(UIIntentionalStream.REFRESH_EXPAND,data,kwargs);},morePrivacyDetails:function(fbid,row,elem){if(is_empty(this._moreDetails)){onunloadRegister(function(){this._moreDetails={};}.bind(this));}
if(this._moreDetails[fbid]){return;}
this._moreDetails[fbid]=true;new AsyncRequest().setURI('/ajax/privacy/more_details.php').setData({fbid:fbid,privacy_data:row}).setHandler(function(response){var explanation=response.getPayload().explanation;DOM.setContent(DOM.find(elem,'span.UITooltip_Text'),explanation);}).setErrorHandler(bagofholding).setTransportErrorHandler(bagofholding).send();}};

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