text: /*1300176619,169775812*/
  
  if (window.CavalryLogger) { CavalryLogger.start_js(["S7T5H"]); }
  
  function Poller(b,a){this.setTimePeriod(b);this._requestCallback=a;this.scheduleRequest();}Poller.MIN_TIME_PERIOD=2000;copy_properties(Poller.prototype,{stop:function(){clearTimeout(this._token);this._token=null;this._cancelRequest();},scheduleRequest:function(){this.stop();if(this._timePeriod)this._token=this._makeRequest.bind(this).defer(this._timePeriod);},requestNow:function(){this.stop();this._makeRequest();},_timePeriod:null,setTimePeriod:function(a){a=a||null;if(a&&(isNaN(a)||a<Poller.MIN_TIME_PERIOD))return;this._timePeriod=a;},_makeRequest:function(){this._cancelRequest();if(!this._isLoadUser())return;var b=new AsyncRequest();var a=true;b.setInitialHandler(function(){return a;});this._cancelRequest=function(){a=false;};b.setFinallyHandler(this.scheduleRequest.bind(this));b.setInitialHandler=bagofholding;b.setFinallyHandler=bagofholding;this._requestCallback(b);if(a)b.send();},_isLoadUser:function(){return Env.user==getCookie('c_user');},_cancelRequest:bagofholding,getTimePeriod:function(){return this._timePeriod;}});
  var ChatUserInfos={};
  var FriendLists={get:function(a){var b=FriendLists._map;if(!b[a])b[a]=[];return b[a];},set:function(a,b){if(b===undefined)return;var c=FriendLists.get(a);c.length=0;c.push.apply(c,$A(b));},_map:{}};
  var AvailableList=(function(){var a=5;var c=60000;var d='/ajax/chat/buddy_list.php';var b=5000;var z=0;var zf=false;var q=0;var y=false;var v=null;var o=null;var i=null;var n=0;var h=null;var w={};var t={};var u={};var p={'0':2,'1':1,'-1':0};var za={0:-1,1:1,2:0};function l(){return Chat.isOnline()?(zf?v:o):null;}function f(zh,zj,zi){if(zh==Env.user)return;if(AvailableList.get(zh)==zj)return;switch(zj){case AvailableList.OFFLINE:case AvailableList.IDLE:case AvailableList.ACTIVE:break;default:return;}if(zi){t[zh]=zj;u[zh]=presence.getTime()+c;}else w[zh]=zj;z++;if(!i)i=zb.defer();}function zd(zh){h=zh;Arbiter.inform('buddylist/count-changed',zh);}function zc(zh){if(presence.isShutdown||!Chat.isOnline()){AvailableList._poller.stop();return;}n=new Date();y=true;zh.setHandler(s).setErrorHandler(r).setTransportErrorHandler(r).setOption('suppressErrorAlerts',true).setOption('retries',1).setData({user:Env.user,popped_out:presence.poppedOut,available_list:AvailableList.haveFullList?k():{},force_render:zf}).setURI(d).setAllowCrossPageTransition(true);}function s(zk){var zj=zk.getPayload();var zh=zj.buddy_list;if(!zh){r(zk);return;}presence.updateServerTime(zj.time);AvailableList.updateTime=presence.getTime();q=0;y=false;if(zh.forcedRender)AvailableList.haveFullList=true;if(zh.availableCount)zd(zh.availableCount);var zl=zh.userInfos;if(zl)copy_properties(ChatUserInfos,zl);if(zh.wasAvailableIDs)zh.wasAvailableIDs.forEach(function(zm){w[zm]=AvailableList.OFFLINE;});var zi=zh.nowAvailableList;zi&&AvailableList.addLegacyAvailableList(zi);zg();Arbiter.inform('buddylist/fl-changed',{flMode:zh.flMode,flData:zh.flData});presenceCookieManager.store();}function r(zh){if(presence.checkMaintenanceError(zh))return;q++;y=false;if(q>=a){zd(0);Arbiter.inform('buddylist/update-error');}}function k(){var zh={};AvailableList.getAvailableIDs().forEach(function(zi){zh[zi]={i:AvailableList.isIdle(zi)?1:0};});return zh;}function zg(){if(AvailableList.haveFullList)Arbiter.inform('buddylist/updated');}function zb(){i=null;if(AvailableList.haveFullList)zd(AvailableList.getAvailableIDs().length);Arbiter.inform('buddylist/availability-changed');}function g(zh,zj){for(var zi in zh){var zk;if(zj){zk=p[zh[zi].ol];}else zk=zh[zi]?(zh[zi].i?AvailableList.IDLE:AvailableList.ACTIVE):0;f(zi,zk,zj);zh[zi]&&zh[zi].fl&&FriendLists.set(zi,zh[zi].fl);}}function m(){ze();if(Chat.isOnline()){AvailableList.update();}else e();}function e(){AvailableList.haveFullList=false;w={};t={};u={};zb();}function ze(){AvailableList._poller&&AvailableList._poller.setTimePeriod(l());}function j(){var zh={};Chat.getActiveChats().forEach(function(zl){var zk=AvailableList.get(zl);if(zk)zh[zl]={i:zk==AvailableList.IDLE?1:0};});var zi={ac:h,ut:parseInt(AvailableList.updateTime*.001,10),ud:v*.001,lc:0};var zj=AvailableList.getLegacyOverlay();if(!is_empty(zj))zi.uo=zj;if(!is_empty(zh))zi.al=zh;return zi;}function x(){for(var zh in t)if(u[zh]<presence.getTime()){delete t[zh];delete u[zh];}}return {OFFLINE:0,IDLE:1,ACTIVE:2,haveFullList:false,init:function(zn,zj,zm,zl,zk,zh,zi){AvailableList.updateTime=zn;AvailableList.haveFullList=zj;AvailableList.addLegacyAvailableList(zh);AvailableList.addLegacyOverlay(zm);v=zl;o=zk;AvailableList._poller=new Poller(l(),zc);zd(zi);Arbiter.subscribe('presence/restarted',AvailableList.update);Arbiter.subscribe('chat/visibility-changed',m);Arbiter.subscribe('presence-cookie-manager/initialized',function(zo,zp){zp.register('bl',j);});if(AvailableList.haveFullList){n=new Date();}else if(zf)AvailableList.update();},get:function(zh){if(zh==Env.user)return AvailableList.ACTIVE;if(zh in t&&presence.getTime()<u[zh])return t[zh];return w[zh]||AvailableList.OFFLINE;},set:function(zh,zi){f(zh,zi,true);},update:function(){if(new Date()-n<b){!y&&zg.defer();return;}zf=true;ze();AvailableList._poller&&AvailableList._poller.requestNow();},getRev:function(){return z;},isIdle:function(zh){return AvailableList.get(zh)==AvailableList.IDLE;},getCount:function(){return h;},getAvailableIDs:function(){var zh,zi=[];for(zh in w)if(AvailableList.get(zh))zi.push(zh);for(zh in t){if(zh in w)continue;if(AvailableList.get(zh))zi.push(zh);}return zi;},getLegacyAvailability:function(zi){var zh=AvailableList.get(zi);return zh?{i:zh==AvailableList.IDLE?1:0}:null;},getLegacyOverlay:function(){x();var zi={};for(var zh in t)zi[zh]={exp:u[zh],fl:FriendLists.get(zh),ol:za[t[zh]]};return zi;},addLegacyOverlay:function(zh){g(zh,true);},addLegacyAvailableList:function(zh){g(zh,false);}};})();
  var Chat={openTab:function(a,b,c){Chat._withComponent('chatDisplay',function(d){d.focusTab(a,true,b,b,c);});},loadTabFragile:function(b,c,a,d){Chat._withComponent('chatDisplay',function(e){e.loadTabFragile(b,c,a,d);});},openBuddyList:function(){Chat._withComponent('buddyListNub',function(a){a.show();});},closeBuddyList:function(){Chat._withComponent('buddyListNub',function(a){a.hide();});},getAvailability:function(a){return AvailableList.getLegacyAvailability(a);},getAvailableIds:function(){return AvailableList.getAvailableIDs();},goOnline:function(a){Arbiter.subscribe('chat-options/initialized',function(event,b){if(Chat.isOnline()){a&&a();}else{if(a)var c=Arbiter.subscribe('chat/visibility-changed',function(){Arbiter.unsubscribe(c);a();});b.sendVisibility(true);}});},isOnline:function(){return window.chatOptions&&chatOptions.visibility;},isAvailabilityReady:function(){return !!this._buddyList;},squelchTab:function(a,b){Chat._withComponent('chatDisplay',function(c){b!==false&&c.unfocus(a,false);c.setSquelchedTab(a,true);});},unsquelchTab:function(a){Chat._withComponent('chatDisplay',function(b){b.setSquelchedTab(a,false);});},enterErrorMode:function(a){Chat._withComponent('buddyList',function(b){b.enterErrorMode(a);});},getActiveChats:function(){if(!window.chatDisplay)return [];return keys(chatDisplay.tabs);},isFeatureAvailable:function(a){return window.chatDisplay&&a in chatDisplay.gatedFeatures&&chatDisplay.gatedFeatures[a];},_componentInitEvents:{buddyList:'buddylist/initialized',chatDisplay:'chat-display/loaded',buddyListDisplay:'buddylist-display/initialized',buddyListNub:'buddylist-nub/initialized'},_withComponent:function(b,a){Arbiter.subscribe(Chat._componentInitEvents[b],function(event,c){a(c);});}};Chat._withComponent("buddyList",function(a){Chat._buddyList=a;});copy_properties(Chat,{debugPrintUpdateOverlay:function(){Chat._withComponent('buddyList',function(a){a.debugPrintUpdateOverlay();});},updateUserInfo:function(a){Chat._buddyList&&Chat._buddyList.updateUserInfos(a);},setAvailable:function(c,a,b){a&&FriendLists.set(c,$A(a));AvailableList.set(c,AvailableList.ACTIVE);},setUnavailable:function(a){AvailableList.set(a,AvailableList.OFFLINE);},updateAvailability:function(){AvailableList.update();},setUserInfo:function(b,c,a){ChatUserInfos[b]=c;Chat._withComponent('buddyList',function(d){d.updateItemDisplay(b);a&&FriendLists.set(b,a);});},addOverlayInfo:function(a){AvailableList.addLegacyOverlay(a);}});
  var NavigationMessage={NAVIGATION_BEGIN:'NavigationMessage/navigationBegin',NAVIGATION_SELECT:'NavigationMessage/navigationSelect',NAVIGATION_COMPLETED:'NavigationMessage/navigationCompleted',NAVIGATION_FAILED:'NavigationMessage/navigationFailed',NAVIGATION_COUNT_UPDATE:'NavigationMessage/navigationCount',REFRESH_RIGHT_COLUMN:'NavigationMessage/refreshRightColumn',PREFETCH:'NavigationMessage/prefetch',INTERNAL_LOADING_BEGIN:'NavigationMessage/internalLoadingBegin',INTERNAL_LOADING_COMPLETED:'NavigationMessage/internalLoadingCompleted'};
  function AsyncLayout(){}AsyncLayout.prototype={init:function(b,a,c,d){this.canvas_id=b.id;if(a)this.auxiliary_id=a.id;if(c)this.header_id=c.id;if(d)this.toolbar_id=d.id;this.auxEndpoints={};this.waitingForAux=false;PageTransitions.registerHandler(this.catchPageTransition.bind(this));this.subscription=Arbiter.subscribe(NavigationMessage.NAVIGATION_BEGIN,this.onNavigate.bind(this));this.auxSubscription=Arbiter.subscribe(NavigationMessage.REFRESH_RIGHT_COLUMN,this.refreshRightColumn.bind(this));return this;},catchPageTransition:function(a){Arbiter.unsubscribe(this.subscription);Arbiter.unsubscribe(this.auxSubscription);return false;},setAuxiliaryEndpoints:function(b){for(var a in b)this.auxEndpoints[a]=b[a];},onNavigate:function(d,a){var e=a.useAjaxPipe&&AjaxPipeRequest.isActiveOnPage(a.params.endpoint);a=a.params;if(a.endpoint){if(this.request){this.request.setFinallyHandler(bagofholding);this.request.abort();}if(this.sideRequest)this.sideRequest.abort();if(e){this.request=new AjaxPipeRequest().setURI(a.endpoint).setData(a).setCanvasId(a.sidecol?'contentCol':'contentArea').setFinallyHandler(this.finallyHandler.bind(this)).setErrorHandler(this.errorHandler.bind(this)).send();}else{a.handled=true;var b=false;if(a.prefetch){b=true;delete a.prefetch;}this.waitingForAux=a.sidecol;if(a.sidecol&&!b)this.refreshRightColumn(d,a);var f=!!a.iframe;var c=new AsyncRequest().setOption('useIframeTransport',f).setURI(new URI(a.endpoint)).setReadOnly(true).setMethod('GET').setData(a).setPrefetch(b).setHandler(this.onResponse.bind(this)).setFinallyHandler(this.finallyHandler.bind(this));if(!b){c.setErrorHandler(this.errorHandler.bind(this));this.request=c;}c.send();}}},refreshRightColumn:function(b,a){if(a.key&&this.auxEndpoints[a.endpoint]){this.sideRequest=new AsyncRequest(this.auxEndpoints[a.endpoint]).setData({key:a.key}).setHandler(this.onSideResponse.bind(this));this.sideRequest.send();}},onSideResponse:function(b){var a=b.getPayload();if(a&&this.auxiliary_id)this.receivedAux(a);},receivedAux:function(a){!this.waitingForAux;this.waitingForAux=false;DOM.setContent($(this.auxiliary_id),HTML(a));},onResponse:function(e){var d=e.getPayload();if(d.redirect){goURI(d.redirect);}else{var c=d.html||d;DOM.setContent($(this.canvas_id),HTML(c));if(d.side_html&&this.auxiliary_id)this.receivedAux(d.side_html);if(this.header_id&&!d.keep_header){var b=$(this.header_id);DOM.setContent(b,HTML(d.header_html||''));CSS.conditionShow(b,d.header_html);}if(d.toolbar_html&&this.toolbar_id)DOM.setContent($(this.toolbar_id),HTML(d.toolbar_html));if(d.js)(new Function(d.js))();CSS.conditionClass('contentCol','hasRightCol',this.auxiliary_id&&!d.noRightSide);var f=ge('rightCol');if(f&&d.noRightSide)DOM.empty(f);}var a=e.getRequest().getData();Arbiter.inform(NavigationMessage.NAVIGATION_COMPLETED,a.key);},errorHandler:function(a){AsyncResponse.verboseErrorHandler(a);Arbiter.inform(NavigationMessage.NAVIGATION_FAILED);this.request=null;},finallyHandler:function(a){this.request=null;PageTransitions.transitionComplete();Arbiter.inform(NavigationMessage.NAVIGATION_COMPLETED);CSS.removeClass(document.body,'fixedHeader');}};
  function SideNav(){SideNav.instance=this;}SideNav.instance=null;SideNav.getInstance=function(){if(SideNav.instance===null)return new SideNav();return SideNav.instance;};SideNav.prototype={init:function(c,a,b,d,e){this.selectedKey=d;this.loadingKey=null;this.loadingNode=null;this.editNav={};this.path=URI.getRequestURI().getPath();this.domain=URI.getRequestURI().getDomain();this.navData={};this.root=c;this.defaultKey=a;this.endpoints=b;this.keyParam='sk';this.useAjaxPipe=e;PageTransitions.registerHandler(this.catchPageTransition.bind(this));Arbiter.subscribe(NavigationMessage.NAVIGATION_COMPLETED,this.navigationComplete.bind(this));Arbiter.subscribe(NavigationMessage.NAVIGATION_FAILED,this.navigationFailed.bind(this));Arbiter.subscribe(NavigationMessage.NAVIGATION_COUNT_UPDATE,this.navigationCountUpdate.bind(this));Arbiter.subscribe(NavigationMessage.NAVIGATION_SELECT,this.navigationSelect.bind(this));if(this.selectedKey){Arbiter.inform('SideNav.selectedKey',this.selectedKey,Arbiter.BEHAVIOR_STATE);}else{selected=Arbiter.query('SideNav.selectedKey');if(selected){data={asLoading:false};data[this.keyParam]=selected;this.navigationSelect(null,data);}}Event.listen(this.root,'click',(function(event){var f=event.getTarget();if(CSS.hasClass(f,'uiCloseButton')&&f.parentNode.tagName=='LI'){CSS.hide(Parent.byTag(f,'li'));return;}if(!(CSS.hasClass(f,'navMoreLess')||CSS.hasClass(f,'navEditDone')))f=Parent.byTag(f,'a');if(f&&CSS.hasClass(f,'navEditDone'))this.toggleSortMode(DOM.find(Parent.byClass(f,'expandedMode'),'ul.uiSideNav'),f.getAttribute('data-endpoint'));}).bind(this));},addEndpoints:function(a){this.endpoints=merge(this.endpoints,a);},updateCloseButtons:function(b,a){DOM.scry(b,'span.buttonWrap').each((function(c){Event.listen(c,'click',(function(event){var d=Parent.byClass(event.getTarget(),'uiCloseButton');if(d){d=DOM.find(d,'input');Form.bootstrap(d.form,d);if(a)CSS.hide(Parent.byTag(d,'li'));}Event.kill(event);}).bind(this));CSS.show(c);}).bind(this));},getEndpoint:function(a){return this.endpoints?this.endpoints[a]||this.endpoints:'';},catchPageTransition:function(c){var b=c.getQueryData(),a=this.resolveKey(b[this.keyParam],c);if(a===false)return false;if(a===undefined)a=this.defaultKey;this.loadKey(a);return this.handlePageTransition(b,a);},resolveKey:function(a,b){if(this.path!=b.getPath()||this.domain!=b.getDomain())return false;return a;},loadKey:function(b,c){var a=DOM.scry(this.root,'li.key-'+b);this.loadingNode&&!c&&CSS.removeClass(this.loadingNode,'loading');this.loadingKey=b;if(a.length){this.loadingNode=a[0];!c&&CSS.addClass(this.loadingNode,'loading');}else this.loadingNode=null;this.refreshRightColumn=this.shouldRefreshRightColumn(this.loadingNode,b);},shouldRefreshRightColumn:function(b,a){return b&&this.isTopLevelNode(b);},handlePageTransition:function(c,b){var a=this.getEndpoint(b);if(!(typeof a=='string'))return false;copy_properties(c,{key:b,endpoint:a,sidecol:this.refreshRightColumn});c={params:c};c.useAjaxPipe=this.useAjaxPipe||c.params.ap;Arbiter.inform(NavigationMessage.NAVIGATION_BEGIN,c);return true;},isTopLevelNode:function(a){return (a&&a.firstChild&&(CSS.hasClass(a.firstChild,'item')||CSS.hasClass(a.firstChild,'inputsearch')));},navigationSelect:function(c,a){var b=a[this.keyParam];if(b!==undefined){this.loadKey(b);if(!a.asLoading)this.navigationComplete();}},navigationFailed:function(){CSS.removeClass(this.loadingNode,'loading');this.loadingNode=null;},navigationComplete:function(){if(this.loadingKey)DOM.scry(this.root,'li.selectedItem').each(function(c){CSS.removeClass(c,'selectedItem');});if(this.loadingNode){CSS.removeClass(this.loadingNode,'loading');var b=null;if(this.isTopLevelNode(this.loadingNode)){b=this.loadingNode;}else b=this.loadingNode.parentNode.parentNode;if(!CSS.hasClass(b,'open')){DOM.scry(this.root,'li.open').each(function(c){CSS.removeClass(c,'open');});CSS.addClass(b,'open');}CSS.addClass(this.loadingNode,'selectedItem');var a=CSS.hasClass(this.loadingNode,'hider');DOM.scry(this.root,'div.navFold').forEach(function(c){CSS.conditionClass(c,'hideContent',a);});if(CSS.hasClass(this.loadingNode,'expander'))CSS.addClass(Parent.byClass(this.loadingNode,'expandableSideNav'),'expandedMode');this.selectedKey=this.loadingKey;Arbiter.inform('SideNav.selectedKey',this.selectedKey,Arbiter.BEHAVIOR_STATE);this.loadingNode=null;this.loadingKey=null;}},navigationCountUpdate:function(f,d){if(!d||!d['key']||d.count===undefined)return;var e=DOM.find(this.root,'li.key-'+d.key);var b=DOM.scry(e,'span.count');if(b){var a=b[0];var c=DOM.find(e,'span.countValue');if(c){if(d.count<0){d.count+=parseInt(DOM.getText(c),10);d.count=Math.max(d.count,0);}DOM.setContent(c,d.count);}CSS.conditionClass(a,'hidden_elem',!d['count']);}},toggleSortMode:function(c,a){if(!this.editNav[c]){Bootloader.loadComponents('sortable-side-nav-js',this.initializeSortable.bind(this,c,a));}else{var d=c.parentNode,b=this.editNav[c].inEditMode();CSS.conditionClass(d,'editMode',!b);this.editNav[c][(b?'endEdit':'beginEdit')]();}return false;},initializeSortable:function(b,a){this.editNav[b]=new SortableSideNav(b,a);this.toggleSortMode(b);}};
  function ProfileSideNav(){this.parent.construct(this);}ProfileSideNav.extend('SideNav');ProfileSideNav.prototype={keyParam:'sk',altKeyParam:'v',ajaxPipeBlacklistedKeys:['places'],init:function(c,a,b,d){this.parent.init(c,a,b,d,true);this.queryData=URI.getRequestURI().getQueryData();if(b&&this.ajaxLoadKey)onloadRegister(this.handlePageTransition.bind(this,this.queryData,this.ajaxLoadKey));},setTabsAndKey:function(b,a){this.FBTabs=b;this.ajaxLoadKey=a;},isFBTab:function(a){return this.FBTabs&&this.FBTabs.contains(a);},handlePageTransition:function(e,d){var b=this.getEndpoint(d)[0];if(typeof b!='string')return false;var c=!this.isFBTab(d);if(c){if(!CSS.hasClass(document.body,'thirdParty'))return false;}else if(CSS.hasClass(document.body,'thirdParty'))return false;e[this.keyParam]=d;if(this.ajaxPipeBlacklistedKeys.indexOf(d)!=-1){var f=URI.getRequestURI();f.addQueryData(e);go_or_replace(window.location,f,true);}copy_properties(e,{endpoint:b,sidecol:false});var a={params:e,useAjaxPipe:true};Arbiter.inform(NavigationMessage.NAVIGATION_BEGIN,a);return true;},resolveKey:function(a,c){if(a==undefined){var b=c.getQueryData();a=b[this.altKeyParam];}return this.parent.resolveKey(a,c);},catchPageTransition:function(c){var d=c.getQueryData();if(this.queryData&&d&&this.queryData.id!=d.id)return false;var b=this.queryData&&this.queryData.viewas;var a=d&&d.viewas;if(b!=a)return false;return this.parent.catchPageTransition(c);}};
  add_properties('Hovercard',{active:{},init:function(){if(ua.ie()<7)return;Event.listen(document.documentElement,'mouseover',this.handle.bind(this));},handle:function(event){var a=Parent.byTag(event.getTarget(),'a');if((a||!this.isShowing)&&this.setActive(a)){(this.process||this.bootload).call(this,a);event.stop();}},bootload:function(a){this.bootload=bagofholding;Bootloader.loadComponents(['hovercard-core'],function(){if(a==this.active.node)this.process(a);}.bind(this));},getEndpoint:function(a){return a.getAttribute('data-hovercard');},isActive:function(a){return a&&this.isShowing&&this.active.node==a;},setActive:function(b){if(!this.isActive(b)){var a;if(!b||!(a=this.getEndpoint(b))){this.active={};return false;}if(this.active.node!=b){this.active.moveToken&&this.active.moveToken.remove();this.active={node:b,endpoint:a,pos:null};}}return true;}});onloadRegister(Hovercard.init.bind(Hovercard));
  function adjustImage(e,g){if(!g){var a=e.parentNode;while(a.parentNode&&(CSS.getStyle(a,'display')!='block'||a.offsetWidth==0))a=a.parentNode;g=a.offsetWidth;}var c=e.offsetWidth;if(c==0){var d=e.nextSibling,f=e.parentNode;document.body.appendChild(e);c=e.offsetWidth;if(d){f.insertBefore(e,d);}else f.appendChild(e);}if(c>g)try{if(ua.ie()<8){var img_div=document.createElement('div');img_div.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+e.src.replace('"','%22')+'", sizingMethod="scale")';img_div.style.width=g+'px';img_div.style.height=Math.floor(((g/e.offsetWidth)*e.offsetHeight))+'px';if(e.parentNode.tagName=='A')img_div.style.cursor='pointer';e.parentNode.insertBefore(img_div,e);e.parentNode.removeChild(e);}else throw 1;}catch(b){e.style.width=g+'px';}CSS.removeClass(e,'img_loading');}function imageConstrainSize(e,b,c,d){var a=new Image();a.onload=function(){if(a.width>0&&a.height>0){var k=a.width;var h=a.height;if(k>b||h>c){var g=c/b;var f=h/k;if(f>g){k=k*(c/h);h=c;}else{h=h*(b/k);k=b;}}var j=ge(d);if(j){var i=document.createElement('img');i.src=e;i.width=k;i.height=h;j.parentNode.insertBefore(i,j);j.parentNode.removeChild(j);}}};a.src=e;}function image_has_loaded(a){if(a.naturalWidth!==undefined){return a.complete&&a.width!=0;}else if(a.height==20&&a.width==20&&a.complete){return false;}else if(a.complete===undefined&&ua.safari()<500){var b=new Image();b.src=a.src;return b.complete;}return a.complete;}function image_has_failed(a){if((a.complete==null&&a.width==20&&a.height==20)||(a.mimeType!=null&&a.complete&&a.mimeType=='')||(a.naturalHeight!=null&&a.complete&&a.naturalHeight==0))return true;}
  function TextAreaControl(a){this.autogrow=false;this.parent.construct(this,a);this.width=null;}TextAreaControl.extend('TextInputControl');TextAreaControl.getWidth=function(b){var a=function(d){return parseInt(CSS.getStyle(b,d),10);};var c=b.offsetWidth-a('paddingLeft')-a('paddingRight')-a('borderLeftWidth')-a('borderRightWidth');if(ua.firefox())c-=2;return Math.max(c,0);};TextAreaControl.prototype={setAutogrow:function(a){this.autogrow=a;return this;},onupdate:function(){this.parent.onupdate();if(this.autogrow){var b=this.getRoot();var c=this.getShadow(b);if(!c)return;CSS.setStyle(c,'width',this._getWidth()+'px');DOM.setContent(c,HTML(htmlize(b.value)+'...'));var a=Math.max(this.minHeight,c.offsetHeight);if(a!=this.height){CSS.setStyle(b,'height',this.isEmpty()?'':a+'px');this.height=a;Arbiter.inform('reflow');}}else if(this.shadow){DOM.remove(this.shadow);this.shadow=null;}},_getWidth:function(){if(this.width===null)this.width=TextAreaControl.getWidth(this.getRoot());return this.width;},getShadow:function(c){if(!this.shadow){var a=CSS.getStyle(c,'fontSize');if(!a)return false;var b=parseInt(CSS.getStyle(c,'height'),10);this.minHeight=b>0?b:c.offsetHeight-8;this.shadow=$N('div',{className:'DOMControl_shadow',style:{wordWrap:'break-word',fontSize:a,fontFamily:CSS.getStyle(c,'fontFamily')}});DOM.getRootElement().appendChild(this.shadow);}return this.shadow;},resetHeight:function(){this.height=-1;this.update();}};
  function URLScraper(a){this.input=a;this.enable();}URLScraper.mixin('Arbiter',{reset:function(){this.lastMatch=null;},enable:function(){if(this.events)return;var a=function(b){setTimeout(this.check.bind(this,b),30);};this.events=Event.listen(this.input,{paste:a.bind(this,false),keydown:a.bind(this,true)});},disable:function(){if(!this.events)return;for(var event in this.events)this.events[event].remove();this.events=null;},check:function(b){var c=this.input.value;if(b&&URLScraper.trigger(c))return;var a=URLScraper.match(c);if(a&&a!=this.lastMatch){this.lastMatch=a;this.inform('match',{url:a});}}});(function(){var c='[a-z][a-z0-9\\-+.]+://',h='www\\d{0,3}[.]',b='[a-z0-9.\\-]+[.][a-z]{2,4}\\/',a='\\([^\\s()<>]+\\)',f='[^\\s()<>]+',e='[^\\s`!()\\[\\]{};:\'".,<>?]';var d=new RegExp('\\b('+'(?:'+c+'|'+h+'|'+b+')'+'(?:'+a+'|'+f+')*'+'(?:'+a+'|'+e+')'+')','im');var g=/[\s'"!;,)]/;URLScraper.match=function(i){return (d.exec(i)||[])[1]||null;};URLScraper.trigger=function(i){return !g.test(i.charAt(i.length-1));};})();
  function rand32(){return Math.floor(Math.random()*4294967295);}function verifyNumber(a){if(typeof a=='undefined'||isNaN(a)||a==Number.POSITIVE_INFINITY||a==Number.NEGATIVE_INFINITY)a=0;return a;}
  function html_hyperlink(g,h,i,e){if(typeof g==='undefined'||!g.toString)return '';if(typeof h!=='function')h=htmlize;if(typeof i!=='function')i=htmlize;var g=g.toString();var f=[];var b;while((b=URLScraper.match(g))){var d=g.indexOf(b);if(d>=0)f.push(h(g.substring(0,d)));var a=i(b);var c=b.replace(/"/g,'%22');if(!(/^[a-z][a-z0-9\-+.]+:\/\//i.test(b)))c='http://'+c;f.push('<a target="_blank" rel="nofollow" href="'+c+'"');if(e)f.push(' onmousedown="UntrustedLink.bootstrap(this, \''+Env.lhsh+'\', event)"');f.push('>'+a+'</a>');g=g.substring(d+b.length);}g&&f.push(h(g));return f.join('');}function nl2br(a){if(typeof(a)=='undefined'||!a.toString)return '';return a.toString().replace(/\n/g,'<br />');}function is_email(a){return /^([\w!.%+\-])+@([\w\-])+(?:\.[\w\-]+)+$/.test(a);}
  function XHPTemplate(a){this.model=a;}XHPTemplate.prototype={render:function(){if(HTML.isHTML(this.model))this.model=DOM.setContent(document.createDocumentFragment(),this.model)[0];return this.model.cloneNode(true);}};(function(){var b={};var a='XHPTemplate:nodes';copy_properties(XHPTemplate,{getNode:function(d,c){return XHPTemplate.getNodes(d)[c];},getNodes:function(f){var e=DataStore.get(f,a);if(!e){e={};var g=DOM.scry(f,'[data-jsid]');g.push(f);var c=g.length;while(c--){var d=g[c];e[d.getAttribute('data-jsid')]=d;d.removeAttribute('data-jsid');}DataStore.set(f,a,e);}return e;},register:function(c,d){b[c]=d;},render:function(d,c){var e=d in b?b[d].render():null;c&&c(e);return e;}});})();
  UserActivity=window.UserActivity||{SIGNAL:'useractivity/activity',_lastActive:+new Date(),_listeners:null,DEFAULT_IDLE_MS:5000,EVENT_INTERVAL_MS:500,onActivity:function(event){UserActivity._listeners.forEach(function(a){a.remove();});UserActivity._listeners=null;UserActivity._lastActive=+new Date();setTimeout(UserActivity.listen,UserActivity.EVENT_INTERVAL_MS);Arbiter.inform(UserActivity.SIGNAL,event);},listen:function(){if(UserActivity._listeners)return;UserActivity._listeners=[Event.listen(document.body,'mouseover',UserActivity.onActivity),Event.listen(document.body,'keydown',UserActivity.onActivity),Event.listen(document.body,'click',UserActivity.onActivity)];},subscribe:function(a){UserActivity.listen();return Arbiter.subscribe(UserActivity.SIGNAL,a,Arbiter.SUBSCRIBE_NEW);},unsubscribe:function(a){Arbiter.unsubscribe(a);},isActive:function(a){return (new Date()-UserActivity._lastActive<(a||UserActivity.DEFAULT_IDLE_MS));}};onloadRegister(UserActivity.listen);
  function OnVisible(b,c,f,a,d){d=d||{};this.targetY=Vector2.getElementPosition(b).y;this.buffer=coalesce(a,300);this.lastY=Vector2.getScrollPosition().y;this.lastTime=(+new Date());var e=function(){var l=Vector2.getScrollPosition().y;var j=Vector2.getViewportDimensions().y;var k=l+j+this.buffer;var i=!f||(Vector2.getScrollPosition().y-this.buffer<(this.targetY+Vector2.getElementDimensions(b).y));if(i&&(k>this.targetY)){this.remove();if(d.detect_speed){var g=(l-this.lastY);var h=g/((+new Date())-this.lastTime+1);if((h>j/100)||(k>=Vector2.getDocumentDimensions().y&&g>1000))return true;}c();}if(d.detect_speed){this.lastY=l;this.lastTime=(+new Date());}return true;}.bind(this);this.scrollListener=Event.listen(window,'scroll',e);this.resizeListener=Event.listen(window,'resize',e);e();onleaveRegister(this.remove.bind(this));}copy_properties(OnVisible.prototype,{remove:function(){if(this.scrollListener){this.scrollListener.remove();this.resizeListener.remove();this.scrollListener=this.resizeListener=null;}}});
  var PhotoInlineCaptionEditor=function(a){this.instanceId=a;PhotoInlineCaptionEditor.instances[a]=this;};copy_properties(PhotoInlineCaptionEditor,{instances:{},getInstance:function(a){return this.instances[a];}});PhotoInlineCaptionEditor.prototype={init:function(a){this.element=a;Event.listen(a,'click',this.handleClick.bind(this));var b=DOM.scry(a,'input[name="caption_id"]');if(b.length)b[0].value=this.instanceId;},handleClick:function(event){var a=event.getTarget();if(Parent.byClass(a,'editIcon')||Parent.byClass(a,'noCaption')){this.toggleEditDescription(true);}else if(Parent.byClass(a,'cancelEdit')){Input.setValue(DOM.find(this.element,'textarea.fbPhotoCaptionInput'),this.getCaption());this.toggleEditDescription(false);}},setCaption:function(a){DOM.setContent(DOM.find(this.element,'.fbPhotoCaption'),a);this.toggleEditDescription(false);},getCaption:function(){return DOM.getText(DOM.find(this.element,'.fbPhotoCaption'));},toggleEditDescription:function(c){if(!c)DOM.find(this.element,'textarea.fbPhotoCaptionInput').blur();CSS.conditionClass(this.element,'fbPhotoInlineCaptionEditorEditMode',!!c);if(c){var b=DOM.find(this.element,'textarea.fbPhotoCaptionInput');var a=DOMControl.getInstance(b);a&&a.update();b.focus();}else CSS.conditionClass(DOM.find(this.element,'.noCaption'),'hidden_elem',this.getCaption().length);}};
  function PhotoTheaterLog(){}copy_properties(PhotoTheaterLog,{UNKNOWN:0,ESC:1,X:2,OUTSIDE:3,UNLOAD:4,NAVIGATE:5,set:null,time:null,views:0,width:0,height:0,initLogging:function(){this.set=null;this.time=new Date();this.views=1;var a=Vector2.getViewportDimensions();this.width=a.x;this.height=a.y;},setPhotoSet:function(a){this.set=a;},addPhotoView:function(){this.views++;},logPhotoViews:function(a){if(this.views){var c=Vector2.getViewportDimensions();var b={set:this.set,time:new Date()-this.time,views:this.views,width:c.x||this.width,height:c.y||this.height,close:a?a:this.UNKNOWN};new AsyncRequest().setURI('/ajax/photos/theater/session_logging.php').setAllowCrossPageTransition(true).setOption('asynchronous',false).setOption('suppressCacheInvalidation',true).setOption('suppressErrorHandlerWarning',true).setData(b).send();this.set=null;this.views=0;}}});onunloadRegister(function(){PhotoTheaterLog.logPhotoViews(PhotoTheaterLog.UNLOAD);});
  var PhotoTheater={OPEN:'PhotoTheater.OPEN',CLOSE:'PhotoTheater.CLOSE',PAGE:'PhotoTheater.PAGE',RESET_HELP:'PhotoTheater.RESET_HELP',GO:'PhotoTheater.GO',DATA_CHANGE:'PhotoTheater.DATA_CHANGE',BUCKET_SIZE:15,BUFFER_PERCENT:1/3,PRELOAD_BUFFER:5,ADS_REFRESH_RATE:30000,LOADING_IMAGE:'/images/loaders/indicator_black.gif',SIZES:{NORMAL:'n'},IMG_MAX_HEIGHT:720,IMG_MIN_HEIGHT:500,STAGE_CHROME:150,STAGE_CHROME_NARROWER:100,STAGE_CHROME_NARROWEST:88,stageChrome:0,bootstrap:function(b,a){this.loading&&CSS.removeClass(this.loading,'loading');CSS.addClass((this.loading=a),'loading');Arbiter.inform(PhotoTheater.GO,b,Arbiter.BEHAVIOR_STATE);this.loadIfUninitialized();Bootloader.loadComponents(['TagTokenizer','TagToken','PhotoTag','PhotoTagger']);},loadImageOnMouseDown:function(event){var a=Parent.byTag(event.getTarget(),'a');if(a&&a.getAttribute('rel')=='theater'){var c=URI(a.getAttribute('ajaxify')).getQueryData();if(c.src){var b=new Image();b.src=c.src;}}},loadIfUninitialized:function(){if(this.root)return;new AsyncRequest().setURI('/ajax/photos/theater/init.php').setMethod('GET').setAllowCrossPageTransition(true).setReadOnly(true).send();},init:function(a){var b=ge('fbPhotoTheater');if(!b){b=DOM.appendContent(document.body,a)[0];this.initialLoad=false;}if(this.root==b)return;this.initializeNodes(b);if(!this.subscription){LinkController.registerHandler(this.handleNavigateAway.bind(this),LinkController.TARGETS|LinkController.MODIFIERS);Event.listen(document.documentElement,'mousedown',this.loadImageOnMouseDown.bind(this));this.subscription=Arbiter.subscribe(PhotoTheater.GO,function(c,d){CSS.removeClass(this.loading,'loading');this.open(d);}.bind(this));}PageTransitions.registerHandler(this.openHandler.bind(this));},initializeNodes:function(a){this.root=a;this.container=DOM.find(a,'div.container');this.positioner=DOM.find(a,'div.positioner');this.infoWrapper=DOM.find(a,'div.photoInfoWrapper');this.stageWrapper=DOM.find(a,'div.stageWrapper');this.stage=DOM.find(this.stageWrapper,'div.stage');this.errorBox=DOM.find(this.stageWrapper,'div.stageError');this.stageActions=DOM.find(a,'div.stageActions');this.prevPager=DOM.find(this.stageActions,'a.prev');this.nextPager=DOM.find(this.stageActions,'a.next');this.buttonActions=DOM.find(this.stageActions,'div.fbPhotoTheaterButtons');this.stageChrome=this.STAGE_CHROME;if(CSS.hasClass(a,'narrowerWhiteBar')){this.stageChrome=this.STAGE_CHROME_NARROWER;}else if(CSS.hasClass(a,'narrowestWhiteBar'))this.stageChrome=this.STAGE_CHROME_NARROWEST;Event.listen(this.root,'click',this.closeListener.bind(this));},getRoot:function(){return this.root;},openHandler:function(a){if(this.isOpen||a.getPath()!='/photo.php'||a.getQueryData().closeTheater)return false;this.open(a);PageTransitions.transitionComplete();return true;},open:function(a){Bootloader.loadComponents('fb-photos-theater-css',function(){this._open(a);}.bind(this));},_open:function(d){var a=URI(d).getQueryData();var c=a.src;this.urlEntryCount=1;this.hasSrc=!!c;if(c)delete a.src;if(!this.initialLoad){a.firstLoad=true;this.initialLoad=true;}this.isOpen=true;this.refreshOnClose=false;this.createLoader(c,a);this.stageHandlers=[Event.listen(window,'resize',this.adjustForResize.bind(this)),Event.listen(this.buttonActions,'click',this.buttonListener.bind(this))];var b=$('fbPhotoTheaterUfi');if(b)this.stageHandlers.push(Event.listen(b,'click',function(event){if(Parent.byClass(event.getTarget(),'like_link'))CSS.toggleClass(DOM.find(this.buttonActions,'a.likeButton'),'viewerLikesThis');}.bind(this)));this.startingURI=URI.getMostRecentURI().addQueryData({closeTheater:1}).getUnqualifiedURI();KeyEventController.registerKey('ESCAPE',this.closeListener.bind(this));this.initLoader();PhotoTheaterLog.initLogging();if(ua.firefox())(function(){$$('embed').each(function(e){e.setAttribute('autostart','false');var f=e.getAttribute('flashvars');if(f){f=f.replace('autoplay=1','autoplay=0');e.setAttribute('flashvars',f);}var g=URI(e.src);g.addQueryData({autoplay:'0'});g.setPath(g.getPath().replace('autoplay=1','autoplay=0'));e.src=g.toString();});}).bind(this).defer();CSS.addClass(document.body,'theaterMode');Arbiter.inform('new_layer');Arbiter.inform(PhotoTheater.OPEN);(function(){this.adjustForResize();this.adjustForChromeBug(true);if(ua.ie()){this.container.focus();}else this.root.focus();}).bind(this).defer();},closeHandler:function(){if(!this.isOpen)return;if(URI.getMostRecentURI().addQueryData({closeTheater:1}).getUnqualifiedURI().toString()==this.startingURI.toString()){this.close();return;}this.close();this.returnToStartingURI(this.refreshOnClose);},returnToStartingURI:function(b,a){if(!b)if(a){this.squashNextTransition(goURI.curry(a));}else this.squashNextTransition();if(this.urlEntryCount<window.history.length){window.history.go(-1*this.urlEntryCount);}else goURI(PhotoTheater.startingURI);},squashNextTransition:function(a){this.squashNext=true;PageTransitions.registerHandler(function(b){if(PhotoTheater.squashNext){PhotoTheater.squashNext=false;if(a)a.defer();PageTransitions.transitionComplete();return true;}return false;});},handleNavigateAway:function(b){var a=_computeRelativeURI(window.PageTransitions._most_recent_uri.getQualifiedURI(),b.getAttribute('href'));if(this.isOpen&&(a instanceof URI)&&a.getUnqualifiedURI().toString()!=this.startingURI.toString()&&a.getPath()!='/photo.php'){if(!this.closingAction)this.closingAction=PhotoTheaterLog.NAVIGATE;this.close();this.returnToStartingURI(false,a);return false;}return true;},closeListener:function(event){if(this.isOpen&&!(window.Dialog&&Dialog.getCurrent())){var b=event.getTarget();var a=Parent.byClass(b,'closeTheater');if(b==this.root||b==this.container||b==this.positioner||b==this.infoWrapper||a){if(a){this.closingAction=PhotoTheaterLog.X;}else this.closingAction=PhotoTheaterLog.OUTSIDE;this.closeHandler();Event.kill(event);}else if(Event.getKeyCode(event)==KEYS.ESC){this.closingAction=PhotoTheaterLog.ESC;Event.kill(event);this.closeHandler();}}},close:function(){if(this.isOpen){this.isOpen=false;CSS.hide(this.errorBox);KeyEventController.getInstance().resetHandlers();this.destroy();CSS.removeClass(document.body,'theaterMode');this.switchImage(this.LOADING_IMAGE,false);this.recacheData();PhotoTheaterLog.logPhotoViews(this.closingAction);this.closingAction=null;DOM.empty(DOM.find(this.root,'div.fbPhotoTheaterEgo'));PageTransitions.registerHandler(this.openHandler.bind(this));Arbiter.inform(PhotoTheater.CLOSE);this.root.setAttribute('aria-busy','true');}},createLoader:function(a,b){this.image=DOM.find(this.root,'img.spotlight');this.loadQuery=b;if(a)(function(){this.switchImage(a,false);}).bind(this).defer();CSS.hide(this.stageActions);},initLoader:function(){this.loaded=false;this.cache={image:[],data:[],error:[]};this.permalinkMap={};this.lastAdsLoad=0;this.dataLoadTimer=null;this.loadingStates={image:false,data:false};this.uncachedCount=null;this.loadingRange={start:null,end:null};this.fetchInitialData();this.adjustMagicStageLineHeight();this.setLoadingState('data',true);PageTransitions.registerHandler(this.transitionHandler.bind(this));},fetchInitialData:function(){new AsyncRequest().setURI('/ajax/photos/theater/load.php').setMethod('GET').setReadOnly(true).setAllowCrossPageTransition(true).setData(this.loadQuery).setHandler(this.storeFromResponse.bind(this)).send();},initialLoadResponse:function(a){if(this.loaded)return;this.loaded=true;this.total=a.total;this.canPage=this.total>1;this.position=a.position;this.photoSetQuery=a.query;this.loadingRange={start:this.position,end:this.position};PhotoTheaterLog.setPhotoSet(this.photoSetQuery.set);this.uncachedCount=this.total-1;if(this.canPage){if(!this.pageHandlers){var c={mouseout:this.mouseOutListener.bind(this),mousemove:this.mouseMoveListener.bind(this),click:this.pageListener.bind(this)};this.pageHandlers=values(Event.listen(this.stageActions,c)).concat(values(Event.listen(this.stageWrapper,c)));KeyEventController.registerKey('LEFT',this.pageListener.bind(this));KeyEventController.registerKey('RIGHT',this.pageListener.bind(this));}var b=5;this.calculateNewRangeAndFetchIfNeccessary(b);}else if(this.pageHandlers){this.pageHandlers.each(function(d){d.remove();});this.pageHandlers=null;}this.adjustForChromeBug.bind(this).defer();CSS.conditionClass(this.stageActions,'hidePagers',!this.canPage);CSS.show(this.stageActions);this.root.setAttribute('aria-busy','false');},adjustMagicStageLineHeight:function(){var a=Math.min(this.IMG_MAX_HEIGHT,Math.max(this.IMG_MIN_HEIGHT,Vector2.getViewportDimensions().y-this.stageChrome));if(ua.ie()==7)this.stageWrapper.style.height=a+'px';this.stage.style.lineHeight=a+'px';if(this.image.offsetHeight){var b=Vector2.getElementPosition;var c=Math.floor((b(this.image).y-b(this.stage).y-1)-((this.stage.offsetHeight-this.image.offsetHeight)/2));if(c)this.stage.style.marginTop="-"+c+"px";}},adjustForResize:function(){var a=Vector2.getViewportDimensions();CSS.conditionClass(document.body,'tinyScreen',a.x<=981);if(ua.ie()<9)CSS.conditionClass(this.stageWrapper,'stageWrapperIEFix',a.y-this.stageChrome<this.IMG_MIN_HEIGHT);this.revertChromeBugFix();this.adjustMagicStageLineHeight();this.adjustForNewData();},adjustForNewData:function(){if(ua.firefox()||ua.ie()){var c=DOM.scry(this.root,'div.tagsWrapper')[0];var a=Vector2.getElementDimensions(this.image);if(c){c.style.width=a.x+"px";if(ua.ie()<=7){var b=DOM.scry(this.root,'div.tagContainer')[0];if(b)CSS.conditionClass(c,'ie7VerticalFix',Vector2.getElementDimensions(b).y>a.y);}}}},adjustForChromeBug:function(a){if(ua.chrome())if(a){this.stage.style.width='960px';}else{var b=Vector2.getElementDimensions(this.image).x;this.stage.style.width=b?b+'px':'auto';}},revertChromeBugFix:function(){if(ua.chrome())this.stage.style.width='auto';},checkToLoadAds:function(){if(this.noAds)return;var a=(+new Date());if(a-this.lastAdsLoad>this.ADS_REFRESH_RATE){UIPagelet.loadFromEndpoint('WebEgoPane','fbPhotoTheaterEgo',{is_ajax:true,pid:13,data:[]},{crossPage:true});this.lastAdsLoad=a;}},setLoadingState:function(b,a){this.loadingStates[b]=a;if(b=='image'){if(a)this.switchImage(this.LOADING_IMAGE,false);CSS.conditionClass(this.root,'imageLoading',a);}else{CSS.conditionClass(this.root,'dataLoading',a);this.infoWrapper.setAttribute('aria-busy',a?'true':'false');}},destroy:function(){this.stageHandlers.each(function(a){a.remove();});if(this.pageHandlers){this.pageHandlers.each(function(a){a.remove();});this.pageHandlers=null;}},checkState:function(a){if(a!='error'&&!this.loadingStates[a])return;if(a=='image'){if(this.cache.image[this.position]){this.switchImage(this.cache.image[this.position].url,true);this.setLoadingState(a,false);}}else if(a=='data'){if(this.cache.data[this.position]){this.swapData();this.setLoadingState(a,false);}}else if(this.cache.error[this.position]){CSS.hide(this.image);CSS.show(this.errorBox);}},buttonListener:function(event){var a=event.getTarget();if(Parent.byClass(a,'likeButton')){DOM.find($('fbPhotoTheaterUfi'),'button.like_link').click();}else if(Parent.byClass(a,'commentButton')){DOM.find(this.root,'div.commentBox textarea').focus();this.root.scrollTop=this.root.scrollHeight;}else if(Parent.byClass(a,'rotateRight')){this.rotate('right');}else if(Parent.byClass(a,'rotateLeft'))this.rotate('left');},rotate:function(b){var c=this.cache.image[this.position];var a={fbid:c.info.fbid,position:this.position};a[b]=1;this.setLoadingState('image',true);var d=c.url;c.url=this.LOADING_IMAGE;var e=this.position;new AsyncRequest('/ajax/photos/photo/rotate/').setMethod('POST').setAllowCrossPageTransition(true).setReadOnly(false).setData(a).setHandler(this.rotationComplete.bind(this,e)).setErrorHandler(this.rotationError.bind(this,e,d)).send();},rotationComplete:function(b,c){this.storeFromResponse(c);var a=this.cache.image[b];a.url=c.getPayload().new_urls[this.SIZES.NORMAL];if(b==this.position){this.setLoadingState('image',false);this.swapData();this.switchImage(a.url);}this.refreshOnClose=true;},rotationError:function(b,c,d){var a=this.cache.image[b];a.url=c;if(b==this.position){this.switchImage(a.url);this.setLoadingState('image',false);AsyncResponse.defaultErrorHandler(d);}},mouseOutListener:function(event){var d=event.getTarget();var a=event.getRelatedTarget();var b=Parent.byClass(d,'stageActions');var c=Parent.byClass(d,'stageWrapper');var e=Parent.byClass(a,'stageActions');var f=Parent.byClass(a,'stageWrapper');if((c&&!e)||(b&&!f)){CSS.removeClass(this.prevPager,'hover');CSS.removeClass(this.nextPager,'hover');}},mouseMoveListener:function(event){var a=event.getTarget()==this.prevPager;CSS.conditionClass(this.prevPager,'hover',a);CSS.conditionClass(this.nextPager,'hover',!a);},pageListener:function(event){var a=Event.getKeyCode(event)||event.getTarget();if((!CSS.hasClass(this.root,'taggingMode')&&a==this.stageActions)||a==this.nextPager||a==KEYS.RIGHT||(DOM.isNode(a)&&Parent.byClass(a,'stageWrapper'))){this.page(1);user_action(event.getTarget(),'a',event);}else if(a==this.prevPager||a==KEYS.LEFT){this.page(-1);user_action(event.getTarget(),'a',event);}},page:function(d,c){if(!d||!this.canPage||!this.loaded)return;Arbiter.inform(PhotoTheater.PAGE);this.recacheData();this.position=this.calculatePosition(d);if(this.checkErrorAt(this.position)){CSS.hide(this.image);CSS.show(this.errorBox);}else{var b=this.cache.image[this.position];if(b){this.switchImage(b.url,true);if(!c){this.replaceUrl=true;this.urlEntryCount++;goURI(b.info.permalink);}}else this.setLoadingState('image',true);var a=this.cache.data[this.position];if(a){this.swapData();}else this.setLoadingState('data',true);}this.revertChromeBugFix();this.loadMoreIfNeccessary(d>0);this.checkToLoadAds();},checkErrorAt:function(a){if(this.cache.error[a]&&!(this.cache.image[a]&&this.cache.data[a])){return true;}else if(this.cache.image[a]&&this.cache.data[a])this.cache.error[a]=false;return false;},goToPosition:function(c){if(c>this.total||c<1)c=this.total;var b=0;var a=0;if(c>this.position){b=c-this.position;a=this.position+this.total-c;}else{b=this.total-this.position+c;a=this.position-c;}this.page(b<a?b:a*-1,true);},transitionHandler:function(b){if(b.getQueryData().closeTheater)return false;if(this.replaceUrl){this.replaceUrl=false;PageTransitions.transitionComplete();return true;}if(b.getQueryData().profile)return false;var a=this.permalinkMap[b.getUnqualifiedURI().toString()];if(a){this.goToPosition(a);PageTransitions.transitionComplete();return true;}return false;},recacheData:function(){if(!this.loadingStates.data){var a=this.cache.data[this.position];for(var b in a){a[b]=$A($(b).childNodes);DOM.empty($(b));}}},switchImage:function(d,c){CSS.hide(this.errorBox);clearTimeout(this.imageRefreshTimer);var a=this.cache&&this.cache.image[this.position];if(a&&d!=this.LOADING_IMAGE)PhotoTheaterLog.addPhotoView();var b=$N('img',{className:'spotlight',alt:''});b.setAttribute('aria-describedby','fbPhotoTheaterCaption');b.setAttribute('aria-busy','true');if(d!=this.LOADING_IMAGE){this.imageRefreshTimer=setTimeout(this.reloadIfTimeOut.bind(this),2000);b.onload=async_callback(function(){clearTimeout(this.imageRefreshTimer);this.image.setAttribute('aria-busy','false');}.bind(this),'photo_theater');window.ArbiterMonitor&&ArbiterMonitor.customReport('phtld',['theater']);}b.src=d;this.useImage(b,false);if(c)this.preloadImages();},useImage:function(b,a){if(a&&image_has_loaded(this.image))return;DOM.replace(this.image,b);this.image=b;},setErrorBoxContent:function(a){DOM.setContent(this.errorBox,a);},reloadIfTimeOut:function(){if(!image_has_loaded(this.image)){var a=$N('img',{className:'spotlight'});a.src=this.image.src;Event.listen(a,'load',this.useImage.bind(this,a,true));}},preloadImages:function(){var d,c;var e=this.total;var b=this.cache.image;var a=this.PRELOAD_BUFFER;if(e>a*2){d=this.calculatePosition(a*-1);c=this.calculatePosition(a);}else{d=1;c=e;}while(d!=c){if(b[d]&&!b[d].resource){b[d].resource=new Image();b[d].resource.src=b[d].url;}d=(d%e)+1;}},calculatePosition:function(a,b){var c=this.total;b=b||this.position;while(a<0)a+=c;return ((b+a)%c)||c;},swapData:function(){if(this.dataLoadTimer){this.setLoadingState('data',true);clearTimeout(this.dataLoadTimer);this.dataLoadTimer=setTimeout(this.clearTimer.bind(this,true),100);return;}var b,a=this.cache.data[this.position];if(a){for(var c in a){b=ge(c);b&&DOM.setContent(b,a[c]);}new PhotoInlineCaptionEditor('center_stage').init(DOM.find($('fbPhotoTheaterCaption'),'div.fbPhotoInlineCaptionEditor'));Arbiter.inform(PhotoTheater.DATA_CHANGE,this.cache.image[this.position].info,Arbiter.BEHAVIOR_STATE);this.setLoadingState('data',false);this.dataLoadTimer=setTimeout(this.clearTimer.bind(this,false),100);}this.adjustForNewData();},clearTimer:function(a){this.dataLoadTimer=false;a&&this.swapData();},loadMoreIfNeccessary:function(c){var d=c?1:-1;var b=this.BUFFER_PERCENT;var a=this.BUCKET_SIZE;var f=Math.ceil(a*b);var e=this.calculatePosition(Math.min(f,this.uncachedCount)*d);if(!this.isInLoadingRange(e)||!this.isInLoadingRange(this.position))this.calculateNewRangeAndFetchIfNeccessary(a*d);},isInLoadingRange:function(a){rangeStart=this.loadingRange.start;rangeEnd=this.loadingRange.end;if(rangeStart<=rangeEnd){return rangeStart<=a&&a<=rangeEnd;}else return a<=rangeEnd||rangeStart<=a;},calculateNewRangeAndFetchIfNeccessary:function(a){if(this.uncachedCount===0||a===0)return;var b,c,d=this.loadingRange;a=a>0?Math.min(this.uncachedCount,a):Math.max(-1*this.uncachedCount,a);if(a>0){b=this.calculatePosition(1,d.end);c=this.calculatePosition(a,d.end);}else{b=this.calculatePosition(a,d.start);c=this.calculatePosition(-1,d.start);}if(this.isInLoadingRange(b))return;if(a>0){d.end=c;}else d.start=b;this.fetch(b,c);},fetch:function(b,c){if(!this.canPage)return;this.uncachedCount-=b>c?this.total-b+c+1:c-b+1;var a=copy_properties({start:b,end:c,total:this.total},this.photoSetQuery);UIPagelet.loadFromEndpoint('PhotoTheaterPagelet',null,a,{usePipe:true,jsNonblock:true,crossPage:true});},storeFromResponse:function(b){if(!this.isOpen)return;var a=b.getPayload();this.storeFromData(a);},storeFromData:function(h){var b=h.error;if(b){this.processErrorResult(b);this.checkState('error');return;}var f=h.init;var e=h.image;var a=h.data;if(f){this.initialLoadResponse(f);this.replaceUrl=true;goURI(e[this.position].info.permalink);this.noAds=f.noads;}this.checkToLoadAds();if(e){for(var d in e){this.cache.image[d]=e[d];this.permalinkMap[URI(e[d].info.permalink).getUnqualifiedURI().toString()]=d;}this.checkState('image');if(!this.hasSrc){this.switchImage(this.cache.image[this.position].url);this.hasSrc=true;}}if(a){for(var g in a){if(!this.cache.data[g])this.cache.data[g]={};for(var c in a[g])this.cache.data[g][c]=HTML(a[g][c]).getNodes();}this.checkState('data');}},processErrorResult:function(a){if(!(a.start||a.end)){CSS.hide(this.image);CSS.show(this.errorBox);}else{var b=a.start;var e=a.end;if(b<e){for(var c=b;c<=e;c++)this.setErrorAt(c);}else{for(var c=1;c<=e;c++)this.setErrorAt(c);for(var d=b;d<=a.total;d++)this.setErrorAt(d);}}},setErrorAt:function(a){if(!(this.cache.image[a]&&this.cache.data[a]))this.cache.error[a]=true;},deletePhoto:function(a){this.refreshOnClose=true;this.closeHandler();}};
  var UFICommentLike={showDetails:function(a,b,c){c.onmouseover=bagofholding;new AsyncRequest().setURI('/ajax/like/tooltip.php').setData({comment_fbid:a,comment_from:b}).setHandler(function(d){TooltipLink.setTooltipText(c,d.getPayload().like_sentence);}).setErrorHandler(bagofholding).send();}};
  var UFIOptimistic={COMMENT_SEND_EVENT:'ufi/comment',_commentSeqNo:0,init:function(a){this._commentTemplate=a;if(!this._loaded){Event.listen(document.documentElement,'click',this._clickHandler.bind(this),Event.Priority.URGENT);this._loaded=true;}},_clickHandler:function(event){var i=event.getTarget();var l=i.name=='comment'&&i.parentNode&&Parent.byClass(i,'optimistic_submit');if(!l)return true;var e=i.form;var k=DOM.find(e,'textarea');if(Input.isEmpty(k))return true;var a=this._commentTemplate.render();var j=XHPTemplate.getNode(a,'text');DOM.setContent(j,HTML(htmlize(trim(k.value))));var c=DOM.scry(e,'ul.commentList')[0];if(!c)return true;CSS.show(c.parentNode);c.appendChild(a);var b=c.lastChild;var g=rand32();b.id='optimistic_comment_'+g+'_'+this._commentSeqNo++;var d=Form.serialize(e);d.comment_replace=b.id;d.comment=1;function h(){new AsyncRequest(Form.getAttribute(e,'action')).setData(d).setRelativeTo(e).setErrorHandler(function(m){CSS.addClass(b,'uiUfiCommentFailed');Event.listen(XHPTemplate.getNode(a,'retry_link'),'click',h);AsyncResponse.defaultErrorHandler(m);}).send();}h();k.value=k.style.height='';k.focus();var f=window.MentionsInput&&MentionsInput.getInstance(k);f&&f.reset();Arbiter.inform(UFIOptimistic.COMMENT_SEND_EVENT,{form:e});return false;}};
  function StreamProfileComposer(){}StreamProfileComposer.prototype={init:function(a){var b=$(a);Arbiter.subscribe('composer/publish',function(event,c){animation.prependInsert(b,c);});}};
  function Toggler(){this.init();}(function(){var d=[];var b;function c(){c=bagofholding;Event.listen(document.documentElement,'click',function(event){var e=event.getTarget();d.each(function(f){f.active&&!f.sticky&&!DOM.contains(f.getActive(),e)&&f.hide();});},Event.Priority.URGENT);}function a(f,e){if(f instanceof Toggler)return f;return Toggler.getInstance(e);}Toggler.mixin('Arbiter',{init:function(){this.active=null;this.togglers={};this.setSticky(false);d.push(this);this.subscribe(['show','hide'],Toggler.inform.bind(Toggler));c();},show:function(f){var e=a(this,f);var g=e.active;if(f!==g){g&&e.hide();e.active=f;CSS.addClass(f,'openToggler');DOM.appendContent(f,e.getToggler('next'));DOM.prependContent(f,e.getToggler('prev'));e.inform('show',e);}},hide:function(g){var f=a(this,g);var e=f.active;if(e&&(!g||g===e)){CSS.removeClass(e,'openToggler');values(f.togglers).each(DOM.remove);f.inform('hide',f);f.active=null;}},toggle:function(f){var e=a(this,f);if(e.active===f){e.hide();}else e.show(f);},getActive:function(){return a(this).active;},getToggler:function(f){var e=a(this);if(!e.togglers[f])e.togglers[f]=$N('button',{className:'hideToggler',onfocus:function(){var g=DOM.scry(e.active,'[rel="toggle"]')[0];g&&g.focus();e.hide();}});return this.togglers[f];},setSticky:function(f){var e=a(this);f=f!==false;if(f!==e.sticky){e.sticky=f;if(f){e._pt&&Arbiter.unsubscribe(e._pt);}else e._pt=Arbiter.subscribe('page_transition',e.hide.bind(e,null));}return e;}});copy_properties(Toggler,Toggler.prototype);copy_properties(Toggler,{bootstrap:function(e){var f=e.parentNode;Toggler.getInstance(f).toggle(f);},createInstance:function(f){var e=new Toggler().setSticky(true);DataStore.set(f,'toggler',e);return e;},getInstance:function(f){while(f){var e=DataStore.get(f,'toggler');if(e)return e;f=f.parentNode;}return (b=b||new Toggler());},listen:function(g,f,e){return Toggler.subscribe($A(g),function(i,h){if(h.getActive()===f)return e(i,h);});},subscribe:(function(e){return function(g,f){g=$A(g);if(g.contains('show'))d.each(function(h){if(h.getActive())f.curry('show',h).defer();});return e(g,f);};})(Toggler.subscribe.bind(Toggler))});})();
  function Composer(){}(function(){var b=1,a=2;var f={};var e=function(){var j=DOM.scry(this.root,'span.linkAttachment')[0];if(!j)return;var i=Parent.byTag(j,'form');this.scraper=new URLScraper(this.input);this.scraper.subscribe('match',function(k,l){i.action='/ajax/composer/attachment/link/scraper.php?scrape_url='+encodeURIComponent(l.url);i.xhpc.value=j.id;i.xhpc.click();}.bind(this));};var g=function(event,i){i=i||{};i.evt=event;i.flowID=this.flowID;i.context=this.form.xhpc_context.value;i.target=this.form.action.split('/').pop();i={data:JSON.stringify(i)};new AsyncSignal('/ajax/composer/logging.php',i).send();};var d=function(i){this.flowID=new Date().getTime().toString()+(rand32()+1);this._logged_short=this._logged_long=false;if(i)return;Event.listen(this.input,'keypress',function(){var j=Input.getValue(this.input).length;if(!this._logged_short&&j>=2){g.call(this,'typing',{extra:'short'});this._logged_short=true;return;}if(!this._logged_long&&j>=15){g.call(this,'typing',{extra:'long'});this._logged_long=true;}}.bind(this));};var c=function(i){if(this.inform('submit')===false){i.kill();return false;}g.call(this,'publish');if(this.submitHandler)return (new Function(this.submitHandler)).apply(this.form);};var h=function(){var i=this.privacyCallout;if(!i)return;if(this.privacy.offsetWidth){i.setDestroyOnHide(true);i.show();}else{i.setDestroyOnHide(false);i.hide();}};Composer.mixin('Arbiter',{init:function(k,i,j){f[k.id]=this;this.root=k;this.resetCfg=j;this.focus=DOM.find(k,'div.focus_target');this.form=DOM.find(k,'form.attachmentForm');this.content=DOM.find(k,'div.attachmentContent');this.blurb=DOM.find(k,'div.uiComposerMessageBox div.textBlurb');this.input=DOM.find(k,'div.uiComposerMessageBox textarea.input');this.button=DOM.find(k,'div.uiComposerMessageBox label.submitBtn');this.privacy=DOM.find(k,'div.uiComposerMessageBox li.privacyWidget');if(i){i.subscribe('init',function(){var l=i.getTypeahead().getView();l.subscribe(['reset','render'],function(m){CSS.conditionClass(k,'uiComposerMention',(m=='render'));});});this.mentionsInput=i;}Event.listen(this.form,'submit',c.bind(this));e.call(this);d.call(this);Arbiter.inform('xhpc/init/'+k.id,this,Arbiter.BEHAVIOR_STATE);},initPrivacyEducation:function(k,p,i,j){if(i){this.privacyCallout=i;if(!CSS.hasClass(this.focus,'child_was_focused'))var n=Event.listen(this.input,'focus',function(){n.remove();h.call(this);}.bind(this));var o=p.subscribe('menuActivated',function(){p.unsubscribe(o);Button.getInputElement(j).click();});i.subscribe('submit',function(){this.privacyCallout=null;}.bind(this));h.call(this);}if(k.warnChange)var l=p.subscribe('privacyChanged',function(r,q){p.unsubscribe(l);Bootloader.loadComponents('dialog',function(){Dialog.bootstrap('/ajax/privacy/change_default_dialog.php',{privacy_data:q,autosave:true});});});if(k.warnEveryone)var m=this.subscribe('submit',function(){if(p.isEveryonePrivacy()){var q='/ajax/privacy/confirm_everyone_dialog.php';Bootloader.loadComponents(['async','dialog'],function(){new Dialog().setAsync(new AsyncRequest(q)).setHandler(function(){this.unsubscribe(m);new AsyncRequest('/ajax/privacy/save_composer_data.php').setData({seen_everyone:true}).send();Button.getInputElement(this.button).click();}.bind(this)).show();}.bind(this));return false;}}.bind(this));},setBlurb:function(i){DOM.setContent(this.blurb,i);},setEnabled:function(i){Button.setEnabled(this.button,i);},setLoading:function(i){CSS.conditionClass(this.root,'async_saving',!!i);},setContentVisible:function(i){CSS.conditionClass(this.root,'uiComposerHideContent',!i);},setMessageBoxVisible:function(i){CSS.conditionClass(this.root,'uiComposerHideMessageBox',!i);},setInputVisible:function(i){CSS.conditionClass(this.root,'uiComposerHideInput',!i);},reset:function(){Input.reset(this.input);this.mentionsInput&&this.mentionsInput.reset();if(this.resetCfg){this.mutate(this.resetCfg);}else{var i=DOM.scry(this.root,'.uiComposerAttachmentSelected')[0];if(i)CSS.removeClass(i,'uiComposerAttachmentSelected');}CSS.removeClass(this.root,'uiComposerInteracted');CSS.setClass(this.focus,'focus_target');this.setLoading(false);d.call(this,true);},mutate:function(j){CSS.addClass(this.root,'uiComposerOpen');CSS.addClass(this.root,'uiComposerInteracted');var i=ge(j.xhpc);if(i){var k=DOM.scry(this.root,'.uiComposerAttachmentSelected')[0];if(k)CSS.removeClass(k,'uiComposerAttachmentSelected');CSS.addClass(i,'uiComposerAttachmentSelected');if(!j.disableCache)Event.listen(i,'click',function(l){$E(l).stop();this.mutate(j);}.bind(this));}if(j.content){DOM.setContent(this.content,HTML(j.content));this.setContentVisible(true);}else{this.setContentVisible(false);DOM.empty(this.content);}this.setMessageBoxVisible(!j.messageBoxHidden);this.setInputVisible(!j.inputHidden);CSS.conditionShow(this.privacy,!j.privacyWidgetHidden);Input.setPlaceholder(this.input,j.placeholder);Button.setLabel(this.button,j.buttonLabel);this.setBlurb(HTML(j.blurb));CSS.conditionClass(DOM.scry(this.form,'.uiComposerMessageBox')[0],'uiCheckinComposer',j.placeVisible);if(j.autoscrape){this.scraper&&this.scraper.enable();}else this.scraper&&this.scraper.disable();this.setEnabled(!j.disabled);this.form.setAttribute('action',j.endpoint);if(j.formType==b){this.form.setAttribute('rel','async');}else this.form.removeAttribute('rel');if(j.formType==a){this.form.target=j.iframeName;this.form.enctype=this.form.encoding='multipart/form-data';}else{this.form.removeAttribute('target');this.form.removeAttribute('enctype');this.form.removeAttribute('encoding');}this.submitHandler=j.submitHandler;h.call(this);if(j.messageBoxFocused)this.focusInput();},focusInput:function(){this.input.focus();},getInput:function(){return this.input;}});copy_properties(Composer,{publish:function(j,i){Composer.getInstance($(j)).reset();Arbiter.inform('composer/publish',HTML(i).getRootNode());},getInstance:function(i){var j=Parent.byClass($(i),'uiComposer');return j?f[j.id]:null;}});})();
  var TypeaheadUtil=(function(){var b=/[ ]+/g;var c=/[^ ]+/g;var a=/[,;:'"!@#%&=<>_\\\-\~\^\$\/\.\*\+\?\|\(\)\[\]\{\}\u2010\u2011\u2012\u2013\u2014\u2015\u30fb]/g;var d=new RegExp('(\\'+['/','.','*','+','?','|','(',')','[',']','{','}','\\'].join('|\\')+')','g');var e={"\u0430":'a',"\u00e0":'a',"\u00e1":'a',"\u00e2":'a',"\u00e3":'a',"\u00e4":'a',"\u00e5":'a',"\u0431":'b',"\u0446":'c',"\u00e7":'c',"\u010d":'c',"\u0434":'d',"\u00f0":'d',"\u010f":'d',"\u044d":'e',"\u0435":'e',"\u00e8":'e',"\u00e9":'e',"\u00ea":'e',"\u00eb":'e',"\u011b":'e',"\u0444":'f',"\u0433":'g',"\u011f":'g',"\u0445":'h',"\u0438":'i',"\u00ec":'i',"\u00ed":'i',"\u00ee":'i',"\u00ef":'i',"\u0131":'i',"\u0439":'j',"\u043a":'k',"\u043b":'l',"\u013e":'l',"\u013a":'l',"\u043c":'m',"\u043d":'n',"\u00f1":'n',"\u0148":'n',"\u043e":'o',"\u00f8":'o',"\u00f6":'o',"\u00f5":'o',"\u00f4":'o',"\u00f3":'o',"\u00f2":'o',"\u043f":'p',"\u0440":'r',"\u0159":'r',"\u0155":'r',"\u0441":'s',"\u015f":'s',"\u0161":'s',"\u0442":'t',"\u0165":'t',"\u0443":'u',"\u044e":'u',"\u00fc":'u',"\u00fb":'u',"\u00fa":'u',"\u00f9":'u',"\u016f":'u',"\u0432":'v',"\u044b":'y',"\u00ff":'y',"\u00fd":'y',"\u0437":'z',"\u017e":'z',"\u00e6":'ae',"\u0153":'oe',"\u0446":'ts',"\u0447":'ch',"\u0448":'sh',"\u044f":'ya'};function f(n){return n?n.replace(a,' '):'';}function g(n){return n?n.replace(d,'\\$1'):'';}function h(q){q=(''+q).toLowerCase();var p='';var n='';for(var o=q.length;o--;){n=q.charAt(o);p=(e[n]||n)+p;}return p.replace(b,' ');}function l(n,o){return o.length-n.length;}function m(q,n,p){q=f(h(q));var r=n||[];var o=c.exec(q);while(o){o=o[0];r.push(o);o=c.exec(q);}p&&r.sort(l);return r;}function j(p,q,o){var n={};return q.every(function(r){r=TypeaheadUtil.escape(r);return o.some(function(t,s){if(n[s])return false;n[s]=t==r||(p&&t.startsWith(r));return n[s];});});}var i=j.curry(false);var k=j.curry(true);return {escape:g,flatten:h,tokenize:m,isPrefixMatch:k,isExactMatch:i};})();
  function MentionsInput(){}MentionsInput.getInstance=function(a){var b=Parent.byClass(a,'uiMentionsInput');return b?DataStore.get(b,'MentionsInput'):null;};MentionsInput.mixin('Arbiter',{triggerMatch:/[@\uff20]([^@\uff20]*)/,userPrefixMatch:/(([A-Z][^ ]+) ([A-Z][^ ]?)|([A-Z][^ ]{4,})( [A-Z][^ ]*)?)/,init:function(g,h,b,a,e,d,c){this.init=bagofholding;this.typeahead=h;this.highlighter=b;this.hiddenInput=a;this.maxMentions=e;this.data=h.getData();this.input=h.getCore().getElement();if(ua.firefox()<4){this.input.blur();setTimeout(function(){this.input.focus();}.bind(this));}var f=this.input.name;this.input.name=f+'_text';this.hiddenInput.name=f;this.initEvents();this.initTypeahead();this.setInitialState(c);DataStore.set(g,'MentionsInput',this);this.initialized=true;this.inform('init');},reset:function(){this.removeAllTokens();if(this.initialized){this.hiddenInput.value='';DOM.empty(this.highlighter);}},initEvents:function(){var a=this.update.bind(this);Event.listen(this.input,{change:a,keydown:a,keypress:a});},initTypeahead:function(){this.typeahead.subscribe('select',function(b,c){var d=c.selected;if(!this.maxMentions||this.numMentioned<this.maxMentions)this.addToken(d.uid,d.text);this.updateValue();this.typeahead.getView().hide();this.inserting=true;}.bind(this));var a=null;this.typeahead.subscribe('render',function(event){if(a===null){a=Input.getSubmitOnEnter(this.input);Input.setSubmitOnEnter(this.input,false);}}.bind(this));this.typeahead.subscribe('reset',function(event){if(a!==null){Input.setSubmitOnEnter(this.input,a);a=null;}}.bind(this));this.typeahead.getData().setFilter(this.filterResults.bind(this));},setInitialState:function(a){this.reset();a.flattened&&Input.setValue(this.input,a.flattened);if(a.mention_data)for(var b in a.mention_data)this.addToken(b,a.mention_data[b]);this.update();},filterResults:function(a){var c=this.typeahead.getCore().getRawValue();if(this.triggerMatch.test(c)){return true;}else if(this.userPrefixMatch.test(c)){return a.type=='user';}else{var b=TypeaheadUtil.tokenize(c);return a.type=='user'&&TypeaheadUtil.isExactMatch(b,a.preparedTokens);}},getTypeahead:function(){return this.typeahead;},addToken:function(a,b){this.mentioned[a]=b;this.numMentioned++;this.data.setExclusions(keys(this.mentioned));},removeToken:function(a){delete this.mentioned[a];this.numMentioned--;this.data.setExclusions(keys(this.mentioned));},removeAllTokens:function(){this.mentioned={};this.numMentioned=0;this.data&&this.data.setExclusions([]);},update:function(){this.updateTokens();this.updateValue();this.updateWidth();if(this.inserting){this.inserting=false;this.typeahead.getView().reset().show();}},updateTokens:function(){var c=Input.getValue(this.input);for(var b in this.mentioned){var a=this.mentioned[b];if(!a||c.indexOf(a)==-1)this.removeToken(b);}},updateValue:function(){var d,c;var e=Input.getValue(this.input);var b=this.mentioned;for(d in b){c=b[d];e=e.replace(c,'@['+d+':]');}var a=htmlize(e);for(d in b){c=b[d];a=a.replace('@['+d+':]','<b>'+htmlize(c)+'</b>');e=e.replace('@['+d+':]','@['+d+':'+c+']');}if(ua.ie())a=a.replace(/ {2}/g,'&nbsp; ');this.hiddenInput.value=e;DOM.setContent(this.highlighter,HTML(a));},updateWidth:function(){var a=TextAreaControl.getWidth(this.input);if(ua.ie()<=7){a-=parseInt(CSS.getStyle(this.highlighter,'paddingLeft'),10);Parent.byClass(this.highlighter,'highlighter').style.zoom=1;}this.highlighter.style.width=a+'px';this.updateWidth=bagofholding;}});
  var Menu=function(){var i='menu:mouseover';var a=null;function b(k){return Parent.byClass(k,'uiMenu');}function c(k){return Parent.byClass(k,'uiMenuItem');}function d(k){if(document.activeElement){var l=c(document.activeElement);return k.indexOf(l);}return -1;}function e(k){return DOM.find(k,'a.itemAnchor');}function f(k){return CSS.hasClass(k,'checked');}function g(k){return !CSS.hasClass(k,'disabled');}function h(event){var k=c(event.getTarget());k&&Menu.focusItem(k);}function j(k){Menu.inform(Menu.ITEM_SELECTED,{menu:b(k),item:k});}onloadRegister(function(){var k={};k.click=function(event){var n=c(event.getTarget());if(n&&g(n)){j(n);var l=e(n);var m=l.href;var o=l.getAttribute('rel');return (o&&o!=='ignore')||(m&&m.charAt(m.length-1)!=='#');}};k.keydown=function(event){var u=event.getTarget();if(!a||DOM.isNode(u,['input','textarea']))return;var q=Event.getKeyCode(event);switch(q){case KEYS.UP:case KEYS.DOWN:var m=Menu.getEnabledItems(a);var o=d(m);Menu.focusItem(m[o+(q===KEYS.UP?-1:1)]);return false;case KEYS.SPACE:var t=c(u);if(t){j(t);event.prevent();}break;default:var l=String.fromCharCode(q).toLowerCase();var p=Menu.getEnabledItems(a);var o=d(p);var n=o;var r=p.length;while((~o&&(n=++n%r)!==o)||(!~o&&++n<r)){var s=Menu.getItemLabel(p[n]);if(s&&s.charAt(0).toLowerCase()===l){Menu.focusItem(p[n]);return false;}}}};Event.listen(document.body,k);});return copy_properties(new Arbiter(),{ITEM_SELECTED:'menu/item-selected',ITEM_TOGGLED:'menu/item-toggled',focusItem:function(k){if(k){this._removeSelected(b(k));CSS.addClass(k,'selected');g(k)&&e(k).focus();}},getEnabledItems:function(k){return Menu.getItems(k).filter(g);},getCheckedItems:function(k){return Menu.getItems(k).filter(f);},getItems:function(k){return DOM.scry(k,'li.uiMenuItem');},getItemLabel:function(k){return k.getAttribute('data-label',2)||'';},isItemChecked:function(k){return CSS.hasClass(k,'checked');},register:function(k){k=b(k);if(!DataStore.get(k,i))DataStore.set(k,i,Event.listen(k,'mouseover',h));a=k;},setItemEnabled:function(l,k){if(!k&&!DOM.scry(l,'span.disabledAnchor')[0])DOM.appendContent(l,$N('span',{className:'itemAnchor disabledAnchor'},HTML(e(l).innerHTML)));CSS.conditionClass(l,'disabled',!k);},toggleItem:function(l){var k=!Menu.isItemChecked(l);CSS.conditionClass(l,'checked',k);e(l).setAttribute('aria-checked',k);Menu.inform(Menu.ITEM_TOGGLED,{menu:b(l),item:l,checked:k});},unregister:function(l){l=b(l);var k=DataStore.remove(l,i);k&&k.remove();a=null;this._removeSelected(l);},_removeSelected:function(k){Menu.getItems(k).filter(function(l){return CSS.hasClass(l,'selected');}).each(function(l){CSS.removeClass(l,'selected');});}});}();
  var Selector=function(){var a;var k=false;function b(m){return Parent.byClass(m,'uiSelector');}function c(m){return Parent.byClass(m,'uiSelectorButton');}function d(m){return DOM.find(m,'a.uiSelectorButton');}function g(m){return DOM.scry(m,'select')[0];}function e(m){return DOM.scry(m,'ul.uiSelectorMenu')[0];}function f(m){return DOM.find(m,'div.uiSelectorMenuWrapper');}function h(){h=bagofholding;Menu.subscribe(Menu.ITEM_SELECTED,function(m,o){if(!a||!o||o.menu!==e(a))return;var p=i(a);var r=j(o.item);if(r){var n=a;var s=Selector.inform('select',{selector:n,option:o.item});if(s===false)return;var q=Selector.isOptionSelected(o.item);if(p||!q){Selector.setSelected(n,Selector.getOptionValue(o.item),!q);Selector.inform('toggle',{selector:n,option:o.item});Selector.inform('change',{selector:n});if(l(n))DataStore.set(n,'dirty',true);}}if(!p||!r)a&&Selector.toggle(a);});}function i(m){return !!m.getAttribute('data-multiple');}function j(m){return CSS.hasClass(m,'uiSelectorOption');}function l(m){return !!m.getAttribute('data-autosubmit');}onloadRegister(function(){var m={};m.keydown=function(event){var o=event.getTarget();if(DOM.isNode(o,['input','textarea']))return;switch(Event.getKeyCode(event)){case KEYS.DOWN:case KEYS.SPACE:case KEYS.UP:k=true;if(c(o)){var n=b(o);Selector.toggle(n);return false;}break;case KEYS.ESC:k=true;if(a){Selector.toggle(a);return false;}break;case KEYS.RETURN:k=true;break;}};m.keyup=function(){!function(){k=false;}.defer();};Event.listen(document.body,m);Toggler.subscribe(['show','hide'],function(v,u){var r=b(u.getActive());if(r){h();var o=d(r);var p=e(r);var s=v==='show';if(s){a=r;if(CSS.hasClass(o,'uiButtonDisabled')){Selector.setEnabled(r,false);return false;}if(!p){var n=o.getAttribute('ajaxify');if(n){var w=HTML('<div class="uiSelectorMenuWrapper">'+'<ul class="uiMenu uiSelectorMenu loading">'+'<li><span></span></li>'+'</ul>'+'</div>');DOM.appendContent(o.parentNode,w);Bootloader.loadComponents('async',function(){AsyncRequest.bootstrap(n,o);});p=e(r);}}if(p){Menu.register(p);if(k){var q=Menu.getCheckedItems(p);if(!q.length)q=Menu.getEnabledItems(p);Menu.focusItem(q[0]);}}}else{a=null;p&&Menu.unregister(p);k&&o.focus();if(l(r)&&DataStore.get(r,'dirty')){var t=DOM.scry(r,'input.submitButton')[0];t&&t.click();DataStore.remove(r,'dirty');}}CSS.conditionClass(d(r),'selected',s);Selector.inform(s?'open':'close',{selector:r});}});});return copy_properties(new Arbiter(),{attachMenu:function(q,m,o){q=b(q);if(q){a&&Menu.unregister(e(a));DOM.setContent(f(q),m);a&&Menu.register(e(q));if(o){var p=g(q);if(p){DOM.replace(p,o);}else DOM.insertAfter(q.firstChild,o);var n=q.getAttribute('data-name');n&&g(q).setAttribute('name',n);}return true;}},getOption:function(o,p){var n=Selector.getOptions(o),m=n.length;while(m--)if(p===Selector.getOptionValue(n[m]))return n[m];return null;},getOptions:function(n){var m=Menu.getItems(e(n));return m.filter(j);},getEnabledOptions:function(n){var m=Menu.getEnabledItems(e(n));return m.filter(j);},getSelectedOptions:function(m){return Menu.getCheckedItems(e(m));},getOptionText:function(m){return Menu.getItemLabel(m);},getOptionValue:function(n){var p=b(n);var o=g(p);var m=Selector.getOptions(p).indexOf(n);return m>=0?o.options[m+1].value:'';},getValue:function(q){var o=g(q);if(!o)return null;if(!i(q))return o.value;var r=[];var n=o.options;for(var m=1,p=n.length;m<p;m++)if(n[m].selected)r.push(n[m].value);return r;},isOptionSelected:function(m){return Menu.isItemChecked(m);},listen:function(n,o,m){return this.subscribe(o,function(q,p){if(p.selector===n)return m(p,q);});},setButtonLabel:function(p,n){var m=d(p);var o=parseInt(m.getAttribute('data-length'),10);n=n||m.getAttribute('data-label')||'';Button.setLabel(m,n);if(typeof n==='string'){CSS.conditionClass(m,'uiSelectorBigButtonLabel',n.length>o);if(o&&n.length>o){m.setAttribute('title',n);}else m.removeAttribute('title');}},setButtonTooltip:function(o,n){var m=d(o);TooltipLink.setTooltipText(m,n||m.getAttribute('data-tooltip')||'');},setEnabled:function(n,m){if(!m&&a&&b(n)===a)Selector.toggle(n);Button.setEnabled(d(n),m);},setOptionEnabled:function(n,m){Menu.setItemEnabled(n,m);},setSelected:function(q,r,o){o=o!==false;var n=Selector.getOption(q,r);if(!n)return;var m=Selector.isOptionSelected(n);if(o!==m){if(!i(q)&&!m){var p=Selector.getSelectedOptions(q)[0];p&&Menu.toggleItem(p);}Menu.toggleItem(n);Selector.updateSelector(q);}},toggle:function(m){Toggler.toggle(DOM.scry(b(m),'div.wrap')[0]);},updateSelector:function(v){var s=Selector.getOptions(v);var u=Selector.getSelectedOptions(v);var p=g(v).options;var r=[];for(var o=0,q=s.length;o<q;o++){var t=u.contains(s[o]);p[o+1].selected=t;if(t)r.push(Selector.getOptionText(s[o]));}p[0].selected=!u.length;var m=CSS.hasClass(v,'uiSelectorDynamicLabel');var n=CSS.hasClass(v,'uiSelectorDynamicTooltip');if(m||n){r=r.join(i(v)?d(v).getAttribute('data-delimiter'):'');m&&Selector.setButtonLabel(v,r);n&&Selector.setButtonTooltip(v,r);}}});}();
  function DataSource(a){copy_properties(this,a);}DataSource.mixin('Arbiter',{events:['activity','query','respond'],maxResults:10,queryData:{},queryEndpoint:'',bootstrapData:{},bootstrapEndpoint:'',indexedFields:['text'],exclusions:[],init:function(){this.init=bagofholding;this._fields=Object.from(this.indexedFields);this.numResults=this.maxResults;this.activeQueries=0;this.dirty();},dirty:function(){this.value=this.flatValue='';this.bootstrapped=false;this.data={};this.localCache={};this.queryCache={};},bootstrap:function(){if(this.bootstrapped)return;this.fetch(this.bootstrapEndpoint,this.bootstrapData);this.bootstrapped=true;},query:function(e,b){this.inform('beforeQuery',{value:e});var a=TypeaheadUtil.flatten(e);var d=this.buildUids(a);var c=this.respond(e,d).filter(function(f){return f.type!='calltoaction';});this.value=e;this.flatValue=a;this.inform('query',{value:e,results:c});if(b||!a||!this.queryEndpoint||this.getQueryCache().hasOwnProperty(a)||!this.shouldFetchMoreResults(c))return false;this.inform('queryEndpoint',{value:e});this.fetch(this.queryEndpoint,this.getQueryData(e,d),e,a);return true;},shouldFetchMoreResults:function(a){return a.length<this.numResults;},getQueryData:function(c,b){var a=copy_properties({value:c},this.queryData||{});b=b||[];if(b.length)a.existing_ids=b.join(',');return a;},setQueryData:function(a,b){if(b)this.queryData={};copy_properties(this.queryData,a);return this;},getExclusions:function(){return this.exclusions;},setExclusions:function(a){this.exclusions=a||[];},setFilter:function(a){this.filter=a;},respond:function(d,c,a){var b=this.buildData(c);this.inform('respond',{value:d,results:b,isAsync:a});return b;},asyncErrorHandler:bagofholding,fetch:function(c,b,e,d){if(!c)return;var a=new AsyncRequest().setURI(c).setData(b).setMethod('GET').setReadOnly(true).setHandler(function(f){this.fetchHandler(f,e,d);}.bind(this)).setFinallyHandler(function(){this.activeQueries--;if(!this.activeQueries)this.inform('activity',{activity:false});}.bind(this));a.setErrorHandler(this.asyncErrorHandler);a.send();if(!this.activeQueries)this.inform('activity',{activity:true});this.activeQueries++;},fetchHandler:function(b,c,a){this.addEntries(b.getPayload().entries,c,a);this.inform('fetchComplete',{response:b,value:c});this.respond(c,this.buildUids(a),true);},addEntries:function(b,f,c){var d=this.processEntries($A(b||[]),f);var a=this.buildUids(c,d);if(f){var e=this.getQueryCache();e[c]=a;}else this.fillCache(a);},processEntries:function(a,b){return a.map(function(d,c){var e=(d.uid=d.uid+'');if(this.data[e]){copy_properties(this.data[e],d);d=this.data[e];}else this.data[e]=d;if(d.index===undefined)d.index=c;d.query=b;return e;},this);},getEntry:function(a){return this.data[a]||null;},fillCache:function(b){var a=this.localCache;b.each(function(g){var d=this.data[g];if(!d||d.bootstrapped)return;d.bootstrapped=true;var f=this.getTokens(d);for(var c=0,e=f.length;c<e;++c){var h=f[c];if(!a.hasOwnProperty(h))a[h]=[];a[h].push(g);}},this);},getTokens:function(b){if(b.preparedTokens)return b.preparedTokens;var c=[];var d=b.tokens||[];for(var a in this._fields)c.push(b[a]||'');c=c.join(' ');return (b.preparedTokens=TypeaheadUtil.tokenize(c,d));},mergeUids:function(a,c,b,e){var d=function(f,g){return this.data[f].index-this.data[g].index;}.bind(this);return a.sort(d).concat(c,b);},buildUids:function(g,b){if(!g)return b||[];var e=TypeaheadUtil.tokenize(g,null,true);var a=this.buildCacheResults(e,this.localCache);var d=this.buildQueryResults(g,e);var c=this.mergeUids(a,d,b||[],e);var f=Object.from(this.exclusions);return c.filter(function(h){if(f.hasOwnProperty(h))return false;if(this.filter&&!this.filter(this.data[h]))return false;return (f[h]=true);},this);},buildData:function(f){var d=[];var c=this.numResults;for(var b=0;b<f.length&&c;++b){var e=f[b];var a=this.data[e];if(a){d.push(a);c--;}}return d;},findQueryCache:function(e){var b=0;var a=null;var d=this.getQueryCache();for(var c in d)if(e.indexOf(c)==0&&c.length>b){b=c.length;a=c;}return d[a]||[];},buildQueryResults:function(c,b){var a=this.findQueryCache(c);if(this.getQueryCache().hasOwnProperty(c))return a;return this.filterQueryResults(b,a);},filterQueryResults:function(b,a){return a.filter(function(c){return TypeaheadUtil.isPrefixMatch(b,this.getTokens(this.data[c]));},this);},buildCacheResults:function(m,a){var j=m.length;var g={};var o={};var h=[];for(var e=0;e<j;++e){var l=m[e],k=new RegExp('^'+TypeaheadUtil.escape(l));for(var i in a)if(!g.hasOwnProperty(i)&&k.test(i)){g[i]=true;var d=a[i];for(var f=0,c=d.length;f<c;++f){var n=d[f];if(e===0||(o.hasOwnProperty(n)&&o[n]==e))o[n]=e+1;}}}for(var b in o)if(o[b]==j)h.push(b);return j>1?this.filterQueryResults(m,h):h;},getQueryCache:function(){return this.queryCache;}});
  function Typeahead(b,d,a,c){this.args={data:b,view:d,core:a};DataStore.set(c,'Typeahead',this);this.element=c;}Typeahead.mixin('Arbiter',{init:function(a){this.init=bagofholding;this.getCore();this.proxyEvents();this.initBehaviors(a||[]);this.inform('init',this);this.data.bootstrap();this.core.focus();},getData:function(){if(!this.data){var a=this.args.data;this.data=a;this.data.init();}return this.data;},getView:function(){if(!this.view){var a=this.args.view;this.view=new window[a.ctor](a.node,a.options||{});this.view.init();}return this.view;},getCore:function(){if(!this.core){var a=this.args.core;this.core=new window[a.ctor](a.node,a.options||{});this.core.init(this.getData(),this.getView(),this.getElement());}return this.core;},getElement:function(){return this.element;},swapData:function(b){var a=this.core;this.data=this.args.data=b;b.init();if(a){a.data=b;a.initData();a.reset();}b.bootstrap();return b;},proxyEvents:function(){[this.data,this.view,this.core].each(function(a){a.subscribe(a.events,this.inform.bind(this));},this);},initBehaviors:function(a){if(window.TypeaheadBehaviors)a.each(function(b){(TypeaheadBehaviors[b]||bagofholding)(this);},this);}});
  function TypeaheadCore(a,b){this.element=$(a);copy_properties(this,b);}TypeaheadCore.mixin('Arbiter',{events:['blur','focus','reset','unselect'],keepFocused:true,resetOnSelect:false,setValueOnSelect:false,queryTimeout:250,preventFocusChangeOnTab:false,init:function(a,c,b){this.init=bagofholding;this.data=a;this.view=c;this.root=b;this.inputWrap=DOM.find(b,'div.wrap');this.hiddenInput=DOM.find(b,'input.hiddenInput');this.selectedText=null;if(this.setValueOnSelect&&CSS.hasClass(this.inputWrap,'selected'))this.selectedText=this.getValue();this.initView();this.initData();this.initEvents();this.initToggle();},initView:function(){this.view.subscribe('highlight',function(){this.element.focus();}.bind(this));this.view.subscribe('select',function(a,b){this.select(b.selected);}.bind(this));},initData:function(){this.data.subscribe('respond',function(a,b){if(b.value==this.getValue()&&!this.element.disabled)this.view.render(b.value,b.results,b.isAsync);}.bind(this));this.data.subscribe('activity',function(a,b){this.fetching=b.activity;if(!this.fetching)this.nextQuery&&this.performQuery();}.bind(this));},initEvents:function(){Event.listen(this.view.getElement(),{mouseup:this.viewMouseup.bind(this),mousedown:this.viewMousedown.bind(this)});var a={blur:bind(this,'blur'),focus:bind(this,'focus'),keyup:bind(this,'keyup'),keydown:bind(this,'keydown')};if(ua.firefox()){a.text=a.keyup;a.keypress=a.keydown;delete a.keydown;}Event.listen(this.element,a);Event.listen(this.element,'keypress',this.keypress.bind(this));},initToggle:function(){var b=this.root.parentNode,d=CSS.getStyle(b,'position')!='static'?b:this.root,c=this.view,a='uiTypeaheadFocused';this.subscribe('focus',function(){c.show();CSS.addClass(d,a);});this.subscribe('blur',function(){c.hide();CSS.removeClass(d,a);});},viewMousedown:function(){this.selecting=true;},viewMouseup:function(){this.selecting=false;},blur:function(){if(this.selecting){this.selecting=false;return;}this.inform('blur');},focus:function(){this.checkValue();this.inform('focus');},keyup:function(){if(!this.getValue())this.view.reset();this.checkValue();},keydown:function(event){if(!this.view.isVisible()||this.view.isEmpty()){this.checkValue.bind(this).defer();return;}switch(Event.getKeyCode(event)){case KEYS.TAB:this.handleTab(event);return;case KEYS.UP:this.view.prev();break;case KEYS.DOWN:this.view.next();break;case KEYS.ESC:this.view.reset();break;default:this.checkValue.bind(this).defer();return;}event.kill();},keypress:function(event){if(this.view.getSelection()&&Event.getKeyCode(event)==KEYS.RETURN){this.view.select();event.kill();}},handleTab:function(event){this.view.select();this.preventFocusChangeOnTab&&event.kill();},select:function(a){this.resetOnSelect?this.reset():this.view.reset();this.keepFocused?this.element.focus():this.element.blur();if(a&&this.setValueOnSelect){this.setValue(a.text);this.setHiddenValue(a.uid);this.selectedText=a.text;CSS.addClass(this.inputWrap,'selected');}},unselect:function(){if(this.setValueOnSelect){this.selectedText=null;CSS.removeClass(this.inputWrap,'selected');}this.setHiddenValue();this.inform('unselect',this);},enable:function(){this.element.disabled=false;CSS.removeClass(this.root,'uiTypeaheadDisabled');},disable:function(){this.element.disabled=true;CSS.addClass(this.root,'uiTypeaheadDisabled');},reset:function(){this.unselect();this.keepFocused?this.setValue():Input.reset(this.element);this.view.reset();this.inform('reset');},getElement:function(){return this.element;},setValue:function(a){this.value=a||'';Input.setValue(this.element,this.value);},setHiddenValue:function(a){this.hiddenInput.value=(a||a===0)?a:'';Arbiter.inform('Form/change',{node:this.hiddenInput});},getValue:function(){return Input.getValue(this.element);},getHiddenValue:function(){return this.hiddenInput.value||'';},checkValue:function(){var c=this.getValue();if(c==this.value)return;if(this.selectedText&&this.selectedText!=c)this.unselect();var b=(+new Date()),a=b-this.time;this.time=b;this.nextQuery=this.value=c;this.performQuery(a);},performQuery:function(a){if(this.selectedText)return;a=a||0;if(this.fetching&&a<this.queryTimeout){this.data.query(this.nextQuery,true);}else{this.data.query(this.nextQuery);this.nextQuery=null;}}});
  function TypeaheadAreaCore(a,b){this.parent.construct(this,a,b);this.matcher=new RegExp(this.matcher+'$');this.preventFocusChangeOnTab=true;}TypeaheadAreaCore.extend('TypeaheadCore');TypeaheadAreaCore.prototype={prefix:'',suffix:', ',matcher:"\\b[^,]*",select:function(a){this.parent.select(a);var e=this.element.value;var d=this.prefix+a.text+this.suffix;this.expandBounds(e,d);var b=e.substring(0,this.start);var c=e.substring(this.end);this.element.value=b+d+c;FormControl.setCaretPosition(this.element,b.length+d.length);},expandBounds:function(d,c){d=d.toLowerCase();c=c.toLowerCase();var a,b;a=this.start;b=d.substring(this.start,this.end);while(a>=0&&c.indexOf(b)>=0){this.start=a--;b=d.charAt(a)+b;}a=this.end;b=d.substring(this.start,this.end);while(a<=d.length&&c.indexOf(b)>=0){b=b+d.charAt(a);this.end=a++;}},getRawValue:function(){var b=this.parent.getValue();if(b==this.value)return b;var a=FormControl.getCaretPosition(this.element).start||0;return b.substring(0,a);},getValue:function(){var a=this.matcher.exec(this.getRawValue());if(!a)return '';this.start=a.index;this.end=a.index+a[0].length;return a[1]||a[0];}};
  function TypeaheadView(a,b){this.element=$(a);copy_properties(this,b);}TypeaheadView.mixin('Arbiter',{events:['highlight','render','reset','select'],renderer:'basic',autoSelect:false,init:function(){this.init=bagofholding;this.initializeEvents();this.reset();},initializeEvents:function(){Event.listen(this.element,{mouseup:this.mouseup.bind(this),mouseover:this.mouseover.bind(this)});},getElement:function(){return this.element;},mouseup:function(event){this.select(true);event.kill();},mouseover:function(event){if(this.visible)this.highlight(this.getIndex(event));},reset:function(a){if(!a)this.disableAutoSelect=false;this.index=-1;this.items=[];this.results=[];this.value='';this.element.innerHTML='';this.inform('reset');return this;},getIndex:function(event){return this.items.indexOf(Parent.byTag(event.getTarget(),'li'));},getSelection:function(){var a=this.results[this.index]||null;return this.visible?a:null;},isEmpty:function(){return !this.results.length;},isVisible:function(){return this.visible;},show:function(){CSS.show(this.element);this.visible=true;return this;},hide:function(){CSS.hide(this.element);this.visible=false;return this;},render:function(g,d,e){this.value=g;if(!d.length){this.reset(true);return;}this.inform('beforeRender',{results:d});var c=this.getDefaultIndex(d);if(this.index>0&&this.index!==this.getDefaultIndex(this.results)){var a=this.results[this.index];for(var b=0,f=d.length;b<f;++b)if(a.uid==d[b].uid){c=b;break;}}this.results=d;this.element.innerHTML=this.buildMarkup(d);this.items=this.getItems();this.highlight(c,false);this.inform('render',d);},getItems:function(){return DOM.scry(this.element,'li');},buildMarkup:function(c){var b,a=[];if(typeof this.renderer=="function"){a.push('<ul>');b=this.renderer;}else{a.push('<ul class="'+this.renderer+'">');b=TypeaheadRenderers[this.renderer];}c.each(function(d,e){a=a.concat(b(d,e));});a.push('</ul>');return a.join('');},getDefaultIndex:function(b){var a=(this.autoSelect&&!this.disableAutoSelect);return this.index<0&&!a?-1:0;},next:function(){this.highlight(this.index+1);},prev:function(){this.highlight(this.index-1);},highlight:function(a,b){this.selected&&CSS.removeClass(this.selected,'selected');if(a>this.items.length-1){a=-1;}else if(a<-1)a=this.items.length-1;if(a>=0&&a<this.items.length){this.selected=this.items[a];CSS.addClass(this.selected,'selected');}this.index=a;this.disableAutoSelect=(a==-1);if(b!==false)this.inform('highlight',{index:a,selected:this.results[a]});},select:function(a){var b=this.index,c=this.results[b];if(c)this.inform('select',{index:b,clicked:!!a,selected:c});}});
  add_properties('TypeaheadRenderers',{compact:function(c,e){var h=c.markup||htmlize(c.text),g=htmlize(c.subtext),a=htmlize(c.category),f=c.photo,b='',d=[];if(f)if(f instanceof Array){d=['<span class="splitpics clearfix">','<span class="splitpic leftpic">','<img src="',f[0],'" alt="" />','</span>','<span class="splitpic">','<img src="',f[1],'" alt="" />','</span>','</span>'];}else d=['<img src="',f,'" alt="" />'];if(c.type)b=' class="'+c.type+'"';return ['<li',b,'>',d.join(''),(h?'<span class="text">'+h+'</span>':''),'<div class="details"><span class="detailsContents">',(a?a:''),(g&&a?' &middot ':''),(g?g:''),'</span></div>','</li>'];}});
  
  if (window.Bootloader) { Bootloader.done(["S7T5H"]); }