/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  January 10th 2010 2:56:53 AM PST                             */
/*      Machine:  10.16.140.101                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/1aenvs9qjb34k4oo.pkg.js h:1pzsdkf1                        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/1aenvs9qjb34k4oo.pkg.js                                   */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/1aenvs9qjb34k4oo.pkg.js"]); }

var ChatUserInfos={};
function ChatTabActions(_L0){this._container=_L0;this._actions={};this._actionOrder=[];this._visibilityChanged=false;this._anyVisible=false;this.actionClass='action';}copy_properties(ChatTabActions.prototype,{anyVisible:function(){return this._anyVisible;},appendAction:function(_L0,_L1,_L2){this._addAction(_L0,_L1,_L2);this._actionOrder.push(_L0);return this;},prependAction:function(_L0,_L1,_L2){this._addAction(_L0,_L1,_L2);this._actionOrder.unshift(_L0);return this;},setVisible:function(_L0,_L1){var _L2=this._actions[_L0];if(_L2.visible!=_L1){_L2.visible=_L1;this._visibilityChanged=true;}return this;},refresh:function(){if(this._visibilityChanged){this._render();this._visibilityChanged=false;return true;}return false;},_render:function(){DOM.empty(this._container);var _L0=this._actions;var _L1=this._actionOrder;this._anyVisible=false;var _L2=[];for(var i=0;i<_L1.length;++i){var _L4=_L0[_L1[i]];if(_L4.visible){if(this._anyVisible)_L2.push($N('span',{className:'divider'},'|'));_L2.push(_L4.create_element());this._anyVisible=true;}}DOM.appendContent(this._container,_L2);this._container.style.display=this._anyVisible?'block':'none';},_addAction:function(_L0,_L1,_L2){if(typeof _L1=='string'){var _L3=_L1;_L1=function(){return $N('span',{className:this.actionClass},_L3);}.bind(this);}this._actions[_L0]={create_element:function(){var _L4=_L1();Event.listen(_L4,'click',_L2);return _L4;},visible:false};this._visibilityChanged=true;}});
function rand32(){return Math.floor(Math.random()*4294967295);}function verifyNumber(num){if(typeof num=='undefined'||isNaN(num)||num==Number.POSITIVE_INFINITY||num==Number.NEGATIVE_INFINITY)num=0;return num;}
var Sound=(function(){var _L0=false;var _L1='so_sound_player';return {init:function(){if(_L0)return;_L0=true;var _L2=document.createElement('div');_L2.id='sound_player_holder';document.body.appendChild(_L2);try{var _L3=new SWFObject('/swf/SoundPlayerHater.swf',_L1,'1px','1px',['9.0.159.0','10.0.22.87'],'#ffffff');_L3.addParam('allowscriptaccess','always');_L3.addParam('wmode','transparent');_L3.addVariable('swf_id',_L1);_L3.fallback_html=' ';_L3.write(_L2.id);window[_L1]=_L3;}catch(swfex){}},play:function(_L2,_L3){Sound.init();var uri=URI(_L2);if(!uri.getDomain())_L2=URI(env_get('static_base')).setPath(uri.getPath()).toString();var _L5=document[_L1]||window[_L1];var _L6;if(/\.mp3$/.test(_L2))if(_L5){if(!_L5.playSound&&_L5.length)_L5=_L5[0];if(_L5.playSound){_L5.playSound(_L2,!!_L3);return;}}_L6=ge('sound');if(!_L6){_L6=document.createElement('span');_L6.setAttribute('id','sound');DOM.getRootElement().appendChild(_L6);}_L6.innerHTML='<embed src="'+_L2+'" autostart="true" loop="false" '+'hidden="true" />';}};})();
function html_wordwrap(str,_L1,_L2){if(typeof _L1=='undefined')_L1=60;if(typeof _L2!='function')_L2=htmlize;var _L3=new RegExp("\\S{"+(_L1+1)+"}",'g');var _L4=0;var _L5=str;var _L6=[];var _L7=str.match(_L3);if(_L7)for(var i=0;i<_L7.length;i++){var _L9=_L7[i];var _La=_L4+_L5.indexOf(_L9);var _Lb=str.substring(_L4,_La);if(_Lb)_L6.push(_L2(_Lb));_L6.push(_L2(_L9)+'<wbr/>');_L4=_La+_L9.length;_L5=str.substring(_L4);}if(_L5)_L6.push(_L2(_L5));return _L6.join('');}function text_get_hyperlinks(str){if(typeof(str)!='string')return [];var _L1=str.match(/(?:(?:ht|f)tps?):\/\/[^\s"',]*[^\s"'.,?!]/ig);if(_L1&&_L1.length){var _L2={'>':'<',')':'(',']':'['};var _L3,_L4,pos=0,_L6,_L7,_L8,_L9;for(var i=0;i<_L1.length;i++){_L4=_L1[i];_L3=_L2[_L4[_L4.length-1]];if(_L3){_L6=str.indexOf(_L4);_L7=str.substr(pos,_L6);if(_L7.indexOf(_L3)!=-1)_L1[i]=_L4.substr(0,_L4.length-1);pos=_L6+_L4.length;}prev_link=_L4;}}return _L1;}function html_hyperlink(str,_L1,_L2,_L3){var _L4={'<':'>','*':'*','{':'}','[':']',"'":"'",'"':'"','#':'#','+':'+','-':'-','(':')'};if(typeof(str)=='undefined'||!str.toString)return '';if(typeof _L1!='function')_L1=htmlize;if(typeof _L2!='function')_L2=htmlize;var str=str.toString();var _L5=text_get_hyperlinks(str);var _L6=0;var _L7=str;var _L8=[];var _L7=str;if(_L5){var _L9=_L3?ge('post_form_id'):null;var _La=_L9?_L9.value:'';for(var i=0;i<_L5.length;i++){var _Lc=_L5[i];var _Ld=_L6+_L7.indexOf(_Lc);var _Le=_Lc.length;var _Lf=str.substring(_L6,_Ld);if(_Lf)_L8.push(_L1(_Lf));var _L10='';if(_Ld>0){var _L11=str[_Ld-1];if(typeof _L4[_L11]!='undefined'){var _L12=_L4[_L11];var _L13=_Lc.indexOf(_L12);if(_L13!=-1){_L10=_L1(_Lc.substring(_L13));_Lc=_Lc.substring(0,_L13);}}}var _L14=_L2(_Lc);if(_L3){var _L15="http://www.facebook.com/l.php?u="+URI.encodeComponent(_Lc)+'&h='+_La;}else var _L15=_Lc.replace(/"/g,'%22');_L8.push('<a href="'+_L15+'" target="_blank" rel="nofollow">'+_L14+'</a>'+_L10);_L6=_Ld+_Le;_L7=str.substring(_L6);}}if(_L7)_L8.push(_L1(_L7));return _L8.join('');}function nl2br(_L0){if(typeof(_L0)=='undefined'||!_L0.toString)return '';return _L0.toString().replace(/\n/g,'<br />');}function is_email(_L0){return /^([\w!.%+\-])+@([\w\-])+(?:\.[\w\-]+)+$/.test(_L0);}
var Emote={_initialized:false,_imageBase:null,_emoteMap:null,_emoteOrderMap:null,_imageURLs:null,_regex:null,_mapOverlay:null,initImageURL:function(_L0){Emote._imageURL=_L0;},initExtraEmoticons:function(_L0){Emote._mapOverlay=_L0;},_init:function(){var _L0=env_get('static_base');Emote._imageBase=_L0+'images/emote/';Emote._blankImgSrc=_L0+'images/blank.gif';var _L1=['smile','frown','tongue','grin','gasp','wink','glasses','sunglasses','grumpy','unsure','cry','devil','angel','kiss','heart','kiki','squint','confused','upset','pacman','colonthree'];Emote._emoteMap={':-)':['\\:\\-\\)','smile'],':)':['\\:\\)','smile'],':]':['\\:\\]','smile'],'=)':['=\\)','smile'],':-(':['\\:\\-\\(','frown'],':(':['\\:\\(','frown'],':[':['\\:\\[','frown'],'=(':['=\\(','frown'],':-P':['\\:\\-P','tongue'],':P':['\\:P','tongue'],':-p':['\\:\\-p','tongue'],':p':['\\:p','tongue'],'=P':['=P','tongue'],':-D':['\\:\\-D','grin'],':D':['\\:D','grin'],'=D':['=D','grin'],':-O':['\\:\\-O','gasp'],':O':['\\:O','gasp'],':-o':['\\:\\-o','gasp'],':o':['\\:o','gasp'],';-)':['\\;\\-\\)','wink'],';)':['\\;\\)','wink'],'8-)':['8\\-\\)','glasses'],'8)':['8\\)','glasses'],'B-)':['B\\-\\)','glasses'],'B)':['B\\)','glasses'],'8-|':['8\\-\\|','sunglasses'],'8|':['8\\|','sunglasses'],'B-|':['B\\-\\|','sunglasses'],'B|':['B\\|','sunglasses'],'>:(':['>\\:\\(','grumpy'],'>:-(':['>\\:\\-\\(','grumpy'],':/':['\\:/','unsure'],':-/':['\\:\\-/','unsure'],':\\':['\\:\\\\','unsure'],':-\\':['\\:\\-\\\\','unsure'],":'(":["\\:'\\(",'cry'],'3:)':['3\\:\\)','devil'],'3:-)':['3\\:\\-\\)','devil'],'O:)':['O\\:\\)','angel'],'O:-)':['O\\:\\-\\)','angel'],':-*':['\\:\\-\\*','kiss'],':*':['\\:\\*','kiss'],'<3':['<3','heart'],'^_^':['\\^_\\^','kiki'],'-_-':['\\-_\\-','squint'],'o.O':['o\\.O','confused'],'O.o':['O\\.o','confused'],'>:O':['>\\:O','upset'],'>:-O':['>\\:\\-O','upset'],'>:o':['>\\:o','upset'],'>:-o':['>\\:\\-o','upset'],':v':['\\:v','pacman'],':|]':['\\:\\|\\]','robot'],':3':['\\:3','colonthree'],'<(")':['<\\(\\"\\)','penguin'],':putnam:':['\\:putnam\\:','putnam'],'(^^^)':['\\(\\^\\^\\^\\)','shark']};if(Emote._mapOverlay)copy_properties(Emote._emoteMap,Emote._mapOverlay);var _L2=[];for(var _L3 in Emote._emoteMap)_L2.push(Emote._emoteMap[_L3][0]);var _L4='(?:^|\\s|\'|"|\\.)('+_L2.join('|')+')(?:\\s|\'|"|\\.|,|!|\\?|<br>|$)';Emote._regex=new RegExp(_L4);Emote._emoteOrderMap={};for(var i=0;i<_L1.length;i++)Emote._emoteOrderMap[_L1[i]]=i;Emote._initialized=true;},htmlEmote:function(str,_L1){if(typeof _L1!='function')_L1=htmlize;if(!Emote._initialized)Emote._init();var _L2=0;var _L3=str;var _L4=[];while(true){var _L5=Emote._regex.exec(_L3);if(!_L5||!_L5.length)break;var _L6=_L5[1];var _L7=Emote._emoteMap[_L6][1];var _L8=_L3.indexOf(_L6);var _L9=_L3.substring(0,_L8);if(_L9)_L4.push(_L1(_L9));_L4.push('<span class="emote_text">');_L4.push(_L6);_L4.push('</span><img class="emote_img" ');var _La;if(typeof(_La=Emote._emoteOrderMap[_L7])=='undefined'){_L4.push('src="');_L4.push(Emote._imageBase);_L4.push(_L7);_L4.push('.gif" ');}else{var _Lb=((_La*-16)-590);_L4.push('src="');_L4.push(Emote._blankImgSrc);_L4.push('" style="background:url(');_L4.push(Emote._imageURL);_L4.push(') ');_L4.push(_Lb);_L4.push('px -84px no-repeat" ');}_L4.push('alt="');_L4.push(_L6);_L4.push('" />');_L3=_L3.substring(_L8+_L6.length);}if(_L3)_L4.push(_L1(_L3));return _L4.join('');}};
function CookieManager(_L0,_L1,_L2){this.version=_L0;this.cookieName='presence';this.stripQuotes=_L1;this.base64Encode=_L2;this.storers={};}CookieManager.prototype={register:function(_L0,fn){this.storers[_L0]=fn;},store:function(){var _L0=this._getCookie();if(_L0&&_L0.v&&this.version<_L0.v){presence.versionShutdown();return;}var _L1={'v':this.version,'time':parseInt(presence.getTime()*.001)};for(var _L2 in this.storers)_L1[_L2]=this.storers[_L2]();var _L3=JSON.encode(_L1);if(this.stripQuotes)_L3=_L3.replace(/"([a-zA-Z0-9_]+?)":/g,'$1:');if(this.base64Encode)_L3='b'+Base64.encode(_L3);setCookie(this.cookieName,_L3,null);},_getCookie:function(){try{var _L0=getCookie(this.cookieName);if(_L0&&_L0.length>1&&_L0.charAt(0)=='b')_L0=Base64.decode(_L0.substring(1));_L0=_L0.replace(/([,{])([a-zA-Z0-9_]+?):/g,'$1"$2":');return _L0?JSON.decode(_L0):null;}catch(e){return null;}},getSubCookie:function(_L0){var _L1=this._getCookie();if(!_L1)return null;return _L1[_L0];}};
var ChannelRebuildReasons={Unknown:0,AsyncError:1,TooLong:2,Refresh:3,RefreshDelay:4,UIRestart:5,NeedSeq:6,PrevFailed:7,IFrameLoadGiveUp:8,IFrameLoadRetry:9,IFrameLoadRetryWorked:10,PageTransitionRetry:11};function ChannelManager(_L0,_L1,_L2,_L3,_L4){this.user=_L0;this.iframeCheckTime=16000;this.iframeCheckRetryTime=16000;this.iframeLoadMaxRetries=1;this.retryInterval=_L1;this.channelConfig=_L2;this._init(_L3);this.loginErrorGk=_L4;}function handleChanneliFrameMessageEvent(_L0){_L0=_L0||window.event;var _L1=(_L0.domain||_L0.origin);if(_L1.substring(_L1.length-13)!='.facebook.com'&&_L1.substring(_L1.length-15)!='://facebook.com'&&_L1!='facebook.com')return;handleChanneliFrameMessage(_L0.data);}function handleChanneliFrameMessage(iframeMsgStr){if(iframeMsgStr&&iframeMsgStr.charAt(0)=='{')channelManager.handleiFrameMessage(eval('('+iframeMsgStr+')'));}ChannelManager.prototype={_init:function(_L0){this.channels={};this.iframeHost=this.iframePort=null;this.isActionRequest=true;this.isReady=false;this.isRebuilding=false;this.iframeIsLoaded=false;this.iframeEverLoaded=false;this.iframeCheckFailedCount=0;this.permaShutdown=false;this.shouldClearSubdomain=false;this.subframe=ge('channel_iframe');this.postMessage=null;var _L1=presenceCookieManager.getSubCookie('ch');if(_L0){this.iframeSubdomain=null;}else{this.iframeSubdomain=0;if(_L1&&_L1.sub){for(var i=0;i<_L1.sub.length;i++)if(!_L1.sub[i]){this.iframeSubdomain=i;break;}if(i==_L1.sub.length)this.iframeSubdomain=_L1.sub.length;}}var _L3=ua.safari();this.pollForMessages=(_L3>523&&_L3<525);this.useRandomSubdomain=!!ua.ie();if(window.postMessage){if(window.addEventListener){window.addEventListener('message',handleChanneliFrameMessageEvent,false);}else window.onmessage=handleChanneliFrameMessageEvent;}else if(document.postMessage){document.addEventListener('message',handleChanneliFrameMessageEvent,false);}else Util.log('channel: no postMessage listener');presenceCookieManager.register('ch',this._getCookieInfo.bind(this));if(ua.firefox()){onbeforeunloadRegister(this._onUnload.bind(this));}else onunloadRegister(this._onUnload.bind(this));},sendiFrameMessage:function(msg){if(!this.postMessage)return;var _L1=JSON.encode(msg);try{this.postMessage(_L1,"*");}catch(e){presence.error('channel: error sending message "'+_L1+'" to iframe: '+e.toString());}},handleiFrameMessage:function(_L0){if(_L0.type=='init'){this.iframeLoaded();}else if(_L0.type=='channelMsg')this.handleChannelMsg(_L0.channel,_L0.seq,_L0.msg);},_onUnload:function(){this.shouldClearSubdomain=true;presence.doSync(true);},addChannel:function(_L0,seq,_L2,_L3,_L4,_L5){this.channels[_L0]={'currentSeq':seq,'nextSeq':0,'msgHandler':_L2,'startHandler':_L3,'shutdownHandler':_L4,'restartHandler':_L5};},_getCookieInfo:function(){var _L0={};if(this.iframeHost&&this.iframePort){_L0.h=this.iframeHost;_L0.p=this.iframePort;if(null!==this.iframeSubdomain){var _L1=presenceCookieManager.getSubCookie('ch');var _L2=(_L1&&_L1.sub)?_L1.sub:[];var _L3=_L2.length;if(this.shouldClearSubdomain){_L2[this.iframeSubdomain]=0;}else{_L2[this.iframeSubdomain]=1;for(var i=_L3;i<=this.iframeSubdomain;i++)if(!_L2[i])_L2[i]=0;}_L0.sub=_L2;}for(var _L5 in this.channels)_L0[_L5]=this.channels[_L5].currentSeq;}_L0.ri=this.retryInterval;return _L0;},stop:function(){this.stopped=true;this.setReady(false);},setReady:function(_L0){this.isReady=_L0;var msg={'type':'isReady','isReady':_L0,'isActionRequest':this.isActionRequest};if(_L0&&this.isActionRequest)this.isActionRequest=false;if(_L0)msg['channels']=this.channels;this.sendiFrameMessage(msg);},setActionRequest:function(_L0){this.sendiFrameMessage({'type':'isActionRequest','isActionRequest':_L0});},iframeLoad:function(_L0,_L1,_L2,_L3){this.isReady=_L3;this.iframeIsLoaded=false;this.iframePath=_L0;this.iframeHost=_L1;this.iframePort=_L2;var _L4;if(null===this.iframeSubdomain){_L4='';}else{_L4=this.iframeSubdomain;if(this.useRandomSubdomain)_L4+=''+rand32();_L4+='.';}var url='http://'+_L4+this.iframeHost+'.facebook.com:'+this.iframePort+this.iframePath;setTimeout(this._iframeCheck.bind(this),this.iframeCheckTime);if(this.subframe.contentDocument){try{this.subframe.contentDocument.location.replace(url);}catch(e){presence.error('channel: error setting location: '+e.toString());}}else if(this.subframe.contentWindow){this.subframe.src=url;}else if(this.subframe.document){this.subframe.src=url;}else presence.error('channel: error setting subframe url');presence.debug('channel: done with iframeLoad, subframe sent to '+url);},iframeLoaded:function(){if(!this.iframeIsLoaded){this.iframeIsLoaded=true;if(window.postMessage){if('object'==typeof window.postMessage){var _L0=this.subframe.contentWindow;this.postMessage=function(_L2,_L3){_L0.postMessage(_L2,_L3);};}else this.postMessage=bind(this.subframe.contentWindow,this.subframe.contentWindow.postMessage);}else if(document.postMessage){this.postMessage=bind(this.subframe.contentDocument,this.subframe.contentDocument.postMessage);}else this.postMessage=bind(this.subframe.contentWindow,this.subframe.contentWindow.handleChannelParentMessage);this.setReady(this.isReady);if(this.pollForMessages)this.msgCheckInterval=setInterval(this.handleChannelMsgCheck.bind(this),100);if(this.iframeCheckFailedCount){for(var c in this.channels)this.channels[c].restartHandler(false);this._sendDummyReconnect(ChannelRebuildReasons.IFrameLoadRetryWorked);}else for(var c in this.channels)this.channels[c].startHandler();this.iframeCheckFailedCount=0;this.iframeEverLoaded=true;}},_iframeCheck:function(){if(!this.iframeIsLoaded){presence.error("channel: uplink iframe never loaded; shutting down");this.iframeCheckFailedCount++;this.iframeHost=this.iframePort=0;presenceCookieManager.store();if(this.iframeCheckFailedCount<=this.iframeLoadMaxRetries){this.iframeCheckTime=this.iframeCheckRetryTime;this.iframePath=null;this.rebuild(ChannelRebuildReasons.IFrameLoadRetry);}else{for(var c in this.channels)this.channels[c].shutdownHandler();this._sendDummyReconnect(ChannelRebuildReasons.IFrameLoadGiveUp);}}else{this.retryInterval=0;presence.debug('channel: uplink iframe loaded fine');}},_sendDummyReconnect:function(_L0){var _L1=new AsyncRequest().setURI('/ajax/presence/reconnect.php').setData({reason:_L0,iframe_loaded:this.iframeEverLoaded}).setOption('suppressErrorHandlerWarning',true).setMethod('GET').setReadOnly(true);_L1.specifiesWriteRequiredParams()&&_L1.send();},_rebuildResponse:function(_L0){var _L1=_L0.getPayload();var _L2=_L1.user_channel;presence.debug('got rebuild response with channel '+_L2+', seq '+_L1.seq+', host '+_L1.host+', port '+_L1.port);this.channels[_L2].currentSeq=_L1.seq;this.channels[_L2].nextSeq=0;this.isRebuilding=false;if(_L1.path!=this.iframePath||_L1.host!=this.iframeHost||_L1.port!=this.iframePort){this.iframeLoad(_L1.path,_L1.host,_L1.port,true);}else this.setReady(true);presenceCookieManager.store();presenceUpdater.pauseUpdate();if(typeof chatOptions!='undefined')chatOptions.setVisibility(_L1.visibility);for(var c in this.channels)this.channels[c].restartHandler(true);presenceUpdater.resumeUpdate(['buddy_list']);},_retryRebuild:function(_L0,_L1){if(_L1){this.retryInterval=this.channelConfig.MAX_RETRY_INTERVAL;}else if(this.retryInterval==0){this.retryInterval=this.channelConfig.MIN_RETRY_INTERVAL;}else{this.retryInterval*=2;if(this.retryInterval>=this.channelConfig.MAX_RETRY_INTERVAL)this.retryInterval=this.channelConfig.MAX_RETRY_INTERVAL;}var _L2=this.retryInterval*(.75+Math.random()*.5);presence.warn('manager trying again in '+(_L2*.001)+' secs');setTimeout(this._rebuildSend.bind(this,_L0),this.retryInterval);},_rebuildError:function(_L0,_L1){for(var c in this.channels)this.channels[c].shutdownHandler(true);presence.error('got rebuild error: '+_L1.getErrorDescription());if(presence.checkMaintenanceError(_L1)){presence.warn('manager not trying again');}else if(presence.checkLoginError(_L1)){if(presence.inPopoutWindow||this.loginErrorGk){this._retryRebuild(ChannelRebuildReasons.PrevFailed,true);}else presence.warn('manager not trying again');}else this._retryRebuild(ChannelRebuildReasons.PrevFailed,false);},_rebuildTransportError:function(_L0,_L1){for(var c in this.channels)this.channels[c].shutdownHandler(true);presence.error('got rebuild transport error: '+_L1.getErrorDescription());this._retryRebuild(_L0,false);},_rebuildSend:function(_L0){if(typeof _L0!='number')_L0=ChannelRebuildReasons.Unknown;presence.debug('channel: sending rebuild');var _L1=new AsyncRequest().setURI('/ajax/presence/reconnect.php').setData({reason:_L0,iframe_loaded:this.iframeEverLoaded}).setHandler(this._rebuildResponse.bind(this)).setErrorHandler(this._rebuildError.bind(this,_L0)).setTransportErrorHandler(this._rebuildTransportError.bind(this,_L0)).setOption('suppressErrorAlerts',true).setMethod('GET').setReadOnly(true);return _L1.specifiesWriteRequiredParams()&&_L1.send();},rebuild:function(_L0){if(this.stopped)return;if(this.isRebuilding){presence.debug('channel: rebuild called, but already rebuilding');return;}this.setReady(false);this.isRebuilding=true;presence.debug('channel: rebuilding');if(_L0==ChannelRebuildReasons.RefreshDelay)this.retryInterval=this.channelConfig.MAX_RETRY_INTERVAL;setTimeout(this._rebuildSend.bind(this,_L0),this.retryInterval);},handleChannelMsgCheck:function(){if(this.pendingMsg){this._handleChannelMsg(this.pendingMsg.channel,this.pendingMsg.seq,this.pendingMsg.msg);this.pendingMsg=null;}},handleChannelMsg:function(_L0,seq,msg){if(this.pollForMessages){this.pendingMsg={channel:_L0,seq:seq,msg:msg};}else this._handleChannelMsg(_L0,seq,msg);},_handleChannelMsg:function(_L0,seq,msg){if(msg.type=='shutdown'||msg.type=='permaShutdown'){if(!window.loaded||this.permaShutdown)return;if(msg.type=='permaShutdown'){presence.warn('channel: got permaShutdown for all channels');this.permaShutdown=true;}else{presence.warn('channel: got shutdown for all channels');this.rebuild(msg.reason);}for(var c in this.channels)this.channels[c].shutdownHandler(true);}else{this.channels[_L0].currentSeq++;var _L4;if((_L4=this.channels[_L0].nextSeq)&&seq<_L4){presence.warn('ignoring a duplicate message ('+seq+')<('+_L4+') on '+_L0);return;}this.channels[_L0].nextSeq=parseInt(seq)+1;presence.pauseSync();try{this.channels[_L0].msgHandler(_L0,msg);}catch(e){presence.error('error in channel handlers: '+e.toString()+', msg: '+msg);}presence.resumeSync();}}};
function fbx_ab_log_click(_L0){var _L1={link_name:_L0};new AsyncSignal('/ajax/fbx_logging.php',_L1).send();}
function LiveMessageReceiver(_L0){this.eventName=_L0;this.subs=null;this.handler=bagofholding;this.shutdownHandler=null;this.restartHandler=null;this.registered=false;this.appId=1;}LiveMessageReceiver.prototype.setAppId=function(_L0){this.appId=_L0;return this;};LiveMessageReceiver.prototype.setHandler=function(_L0){this.handler=_L0;this._dirty();return this;};LiveMessageReceiver.prototype.setRestartHandler=function(_L0){this.restartHandler=_L0.shield();this._dirty();return this;};LiveMessageReceiver.prototype.setShutdownHandler=function(_L0){this.shutdownHandler=_L0.shield();this._dirty();return this;};LiveMessageReceiver.prototype._dirty=function(){if(this.registered){this.unregister();this.register();}};LiveMessageReceiver.prototype.register=function(){var _L0=function(_L1,_L2){return this.handler(_L2);}.bind(this);var _L1=PresenceMessage.getAppMessageType(this.appId,this.eventName);this.subs={};this.subs['main']=Arbiter.subscribe(_L1,_L0);if(this.shutdownHandler)this.subs['shut']=Arbiter.subscribe(PresenceMessage.SHUTDOWN,this.shutdownHandler);if(this.restartHandler)this.subs['restart']=Arbiter.subscribe(PresenceMessage.RESTARTED,this.restartHandler);this.registered=true;return this;};LiveMessageReceiver.prototype.unregister=function(){if(!this.subs)return this;for(var k in this.subs)if(this.subs[k])Arbiter.unsubscribe(this.subs[k]);this.subs=null;this.registered=false;return this;};LiveMessageReceiver.route=function(_L0){var _L1=function(_L2){var _L3=PresenceMessage.getAppMessageType(_L0.app_id,_L0.event_name);Arbiter.inform(_L3,_L2,Arbiter.BEHAVIOR_PERSISTENT);};if(_L0.hasCapture){new AsyncRequest().setHandler(function(r){_L1(r.getPayload());}).handleResponse(_L0.response);}else _L1(_L0.response);};
function Presence(_L0,_L1,_L2,_L3,_L4,_L5){this.user=_L0;this.name=_L1;this.firstName=_L2;this.sitevars=_L5;this.popoutURL=env_get('www_base')+'presence/popout.php';var _L6=Vector2.getViewportDimensions();this.maxTabOffset=37;var _L7=['fb_menubar','intern_bookmark_frame'];var div;for(var ii=0;ii<_L7.length;ii++)if(div=ge(_L7[ii]))this.maxTabOffset+=Vector2.getElementDimensions(div).y;this.maxTabHeight=_L6.y-this.maxTabOffset;this.updateServerTime(_L3);this.pageLoadTime=this.getTime();this._init(_L4);}Presence.prototype={minWidth:100,minHeight:100,defWidth:900,defHeight:650,defX:30,defY:30,cookiePollTime:2000,popoutHeartbeatTime:1000,popoutHeartbeatAllowance:4000,popoutHeartbeatFirstAllowance:15000,resizeStopTime:500,shutdownDelay:5000,restartDelay:3000,POPOUT_TYPE_CHAT:1,POPOUT_TYPE_VIDEOCHAT:2,_init:function(_L0){this.stateStorers=[];this.stateLoaders=[];this.windowID=rand32()+1;this.contentPaddings={'buddy_list':77,'presence_notifications':23,'presence_applications':99};this.contentResized={};this.holder=$('presence');this.holderUI=$('presence_ui');this.bar=$('presence_bar');this.popoutSidebar=ge('presence_popout_sidebar');this.popoutWidth=this.defWidth;this.popoutHeight=this.defHeight;this.cookiePoller=null;this.heartbeat=null;this.resizeTimeout=null;this.lastResized=0;this.stateUpdateTime=0;this.loaded=false;this.isShutdown=false;this.isShuttingDown=false;this.isRestarting=false;this.isPermaShutdown=false;this.shutdownTime=0;this.popoutClicked=false;this.popinClicked=false;this.justPoppedOut=false;this.syncPaused=0;this.disableUnfocus=null;this.tempTabCloseHandler=null;this.inPopoutWindow=_L0==this.POPOUT_TYPE_CHAT;this.inVideoChat=_L0==this.POPOUT_TYPE_VIDEOCHAT;this.inVideoChatWith=null;this.poppedOut=this.inPopoutWindow;presenceCookieManager.register('state',this._getCookieData.bind(this));if(this.inPopoutWindow){Util.fallbackErrorHandler=null;if(!this.inVideoChat)this.bar.style.marginRight='200px';if(!this.inVideoChat){onbeforeunloadRegister(this.popin.bind(this,false));onunloadRegister(this.popin.bind(this,false));}}Event.listen(window,'resize',this._windowOnResize.bind(this));Event.listen(window,'keypress',this._documentKeyPress.bind(this));Event.listen(document,'click',this._documentOnClick.bind(this));if(DOMScroll.usingScrollWrapper())DOMScroll.registerScrollChangeHandler(this._handleScrollChange.bind(this));Arbiter.subscribe(Arbiter.PAGE_TRANSITION,this.checkRebuild.bind(this));var _L1=ua.safari();this.isSafari2=(_L1&&_L1<500);this.isOpera=(ua.opera()>0);var ff=ua.firefox();this.isFF2=(ff&&ff<3);this.isWindows=ua.windows();this.load();this._windowOnResize.bind(this).defer();if(this.inPopoutWindow)setTimeout(this._windowOnResize.bind(this),3000);},updateServerTime:function(_L0){this.timeSkew=(new Date()).getTime()-_L0;},getTime:function(){return (new Date()).getTime()-this.timeSkew;},debug:function(msg){},warn:function(msg){Util.warn('chirp: '+msg);},error:function(msg){Util.error('chirp: '+msg);},inVideoCallTo:function(to){this.inVideoChatWith=to;},load:function(){var _L0=presenceCookieManager.getSubCookie('state');if(!_L0){this.debug('presence: got null state cookie, loading with current state');this._load(this._getCookieData());return;}try{this._load(_L0);}catch(e){this.error('presence: got load exception: '+e.toString());this._load(this._getCookieData());}},_load:function(_L0){this.syncPaused++;this.stateUpdateTime=verifyNumber(_L0.ut);this.popoutTime=verifyNumber(_L0.pt);this.poppedOut=!!_L0.p;if(this.poppedOut){if(this.inPopoutWindow){if(!this.heartbeat&&!this.inVideoChat)this.heartbeat=setInterval(this._popoutHeartbeat.bind(this),this.popoutHeartbeatTime);}else CSS.addClass(this.holder,'popped_out');}else if(!this.inVideoChat){if(this.inPopoutWindow){if(!this.loaded){this.poppedOut=true;this.doSync();}else if(!this.popinClicked){window.close();}else ;}else this.justPoppedOut=true;CSS.removeClass(this.holder,'popped_out');}if(!this.inPopoutWindow&&!this.cookiePoller)this.cookiePoller=setInterval(this._pollCookie.bind(this),this.cookiePollTime);this.state=_L0;for(var i=0;i<this.stateLoaders.length;i++)this.stateLoaders[i](_L0);this._handleResize.bind(this,0,0).defer();setTimeout(this._handleResize.bind(this,0,0),100);this.syncPaused--;this.loaded=true;},_pollCookie:function(){var _L0=presenceCookieManager.getSubCookie('state');if(!_L0)return;var _L1=this.popoutTime;if(_L0.ut>this.stateUpdateTime){this.load(_L0);return;}if(this.poppedOut&&!this.inPopoutWindow){var _L2=verifyNumber(_L0.pt);var _L3=(new Date()).getTime()-_L2;var _L4=this.popoutHeartbeatTime+this.popoutHeartbeatAllowance;if(this.justPoppedOut)if(_L2==_L1){_L4+=this.popoutHeartbeatFirstAllowance;}else this.justPoppedOut=false;this.popoutTime=_L2;if(_L3>_L4){this.poppedOut=false;this.doSync();}}},_popoutHeartbeat:function(){this._pollCookie();if(this.poppedOut)presenceCookieManager.store();},_getCookieData:function(){var _L0={p:this.poppedOut?1:0,ut:this.stateUpdateTime,pt:this.inPopoutWindow?(new Date()).getTime():this.popoutTime};for(var i=0;i<this.stateStorers.length;i++)_L0=this.stateStorers[i](_L0);this.state=_L0;return this.state;},doSync:function(_L0){if(this.syncPaused)return;if(_L0){this._doSync();}else this._doSync.bind(this).defer();},_doSync:function(){this.stateUpdateTime=(new Date()).getTime();presenceCookieManager.store();this._load(this.state);},pauseSync:function(){this.syncPaused++;},resumeSync:function(){this.syncPaused--;this.doSync();},handleMsg:function(_L0,obj){this._handleMsg.bind(this,_L0,obj).defer();},_handleMsg:function(_L0,obj){if(typeof obj=='string'){if(obj=='shutdown'){this.connectionShutdown();}else if(obj=='restart')if(this.isShutdown)this.restart();return;}if(this.isShutdown)return false;if(!obj.type)return;if(obj.type=='app_msg')if(obj.event_name=='beep_event'){Bootloader.loadComponents('beeper',function(){Beeper.ensureInitialized();LiveMessageReceiver.route(obj);});}else LiveMessageReceiver.route(obj);Arbiter.inform(PresenceMessage.getArbiterMessageType(obj.type),{sender:this,channel:_L0,obj:obj});},popout:function(){if(this.inVideoChat)return;if(this.inPopoutWindow||this.poppedOut){this.popin(true);return;}if(this.popoutClicked)return;this.popoutClicked=true;var w=window.open(this.popoutURL,"fbChatWindow","status=0,toolbar=0,location=0,menubar=0,"+"directories=0,resizable=1,scrollbars=0,"+"width="+this.popoutWidth+",height="+this.popoutHeight+","+"left="+this.defX+",top="+this.defY);CSS.removeClass(this.holder,'popped_out');this.poppedOut=true;this.justPoppedOut=true;this.popoutTime=(new Date()).getTime();this.doSync();this.popoutClicked=false;},popin:function(_L0){if(this.inVideoChat)return;if(typeof _L0=='undefined')_L0=true;if(this.inPopoutWindow){if(this.popinClicked)return;this.popinClicked=true;}this.poppedOut=false;this.doSync();if(this.inPopoutWindow&&_L0)window.close();},_windowOnResize:function(){this.contentResized={};var _L0=Vector2.getViewportDimensions();this._handleResize(_L0.x-this.virtPopoutWidth,_L0.y-this.virtPopoutHeight);if(!this.inPopoutWindow){this._updateMaxTabHeight();}else this.popoutHeight=_L0.y;},_updateMaxTabHeight:function(){this.maxTabHeight=Vector2.getViewportDimensions().y-this.maxTabOffset;if(DOMScroll.usingScrollWrapper()&&DOMScroll.getScrollState().x)this.maxTabHeight-=DOMScroll.getScrollbarSize();if(window.buddyList&&buddyList.buddyListOpen){buddyList.resizeTab();}else if(this.focusedWrapper&&this.focusedContent)this.tabContentResize(this.focusedWrapper,this.focusedContent);},_handleScrollChange:function(_L0,_L1){if(!DOMScroll.usingScrollWrapper())return;var _L2=DOMScroll.getScrollbarSize();var _L3=this.getHolderBottomPosition();var _L4=15+(_L1.is_scrolled.y?_L2:0);CSS.setStyle(this.holder,'bottom',_L3+'px');CSS.setStyle(this.holderUI,'marginRight',_L4+'px');if(typeof chatDisplay!='undefined')for(var id in chatDisplay.tabs)chatDisplay.tabs[id].adjustWrapperBottom();this._updateMaxTabHeight();},getHolderBottomPosition:function(){var _L0=0;if(DOMScroll.getScrollState().x){var _L1=DOMScroll.getScrollbarSize();_L0=_L1+(ua.osx()?1:0);}if(presence.isIE6)_L0--;return _L0;},_handleResize:function(dx,dy){var _L2=this.loaded?100:10;if(this.handleResizeTimer)clearTimeout(this.handleResizeTimer);this.handleResizeTimer=setTimeout(function(){this.virtPopoutWidth+=dx;this.virtPopoutHeight+=dy;this.popoutWidth=Math.max(this.virtPopoutWidth,this.minWidth);this.popoutHeight=Math.max(this.virtPopoutHeight,this.minHeight);Arbiter.inform(PresenceMessage.WINDOW_RESIZED,{sender:this});},_L2);},_stopResize:function(){if(this.virtPopoutWidth!=this.popoutWidth||this.virtPopoutHeight!=this.popoutHeight){this.virtPopoutWidth=this.popoutWidth;this.virtPopoutHeight=this.popoutHeight;this.doSync();}},_documentKeyPress:function(e){e=$E(e);var _L1=e?e.keyCode:-1;if(_L1==KEYS.ESC)Event.kill(e);},_documentOnClick:function(_L0){if(DOM.contains(this.holder,_L0.getTarget())||!DOM.contains(document,_L0.getTarget()))return;if((typeof buddyList!='undefined')&&buddyList.buddyListOpen){if(typeof buddyListDisplay!='undefined'&&buddyListDisplay.isFlyoutOpen()){buddyListDisplay.closeOpenFlyout();return;}if(!buddyList.isSticky())buddyList.closeTab();}else this.closeTab();},_unfocus:function(){if(this.focusedWrapper)hide(this.focusedWrapper);if(this.focusedTab){CSS.removeClass(ge(this.focusedTab),'focused');if(this.tempTabCloseHandler){this.tempTabCloseHandler();this.tempTabCloseHandler=null;}}this.wasFocusedTab=this.focusedTab;this.focusedTab=this.focusedWrapper=null;return this.wasFocusedTab;},unfocus:function(){var _L0=this._unfocus();if(_L0){this.disableUnfocus=_L0;setTimeout(function(){this.disableUnfocus=null;}.bind(this),50);}},toggleTab:function(_L0,_L1,_L2,_L3){var _L4=ge(_L0);var tab=ge(_L1);if(!_L4||!tab||_L1==this.disableUnfocus)return;if(_L4.style.display=='none'){this.openTab(_L0,_L1,_L2);if(_L3)fbx_ab_log_click('NOTIFICATIONS_TAB');}else this.closeTab();},closeTab:function(){var tab=this.focusedTab;if(!tab)return;var _L1=this.wasFocusedTab;this.unfocus();CSS.removeClass(tab,'focused');CSS.removeClass(this.holder,'tab_open');Arbiter.inform(PresenceMessage.TAB_CLOSED,{sender:this,tabID:tab});if(tab!=_L1&&_L1=='buddy_list_tab')buddyList.openTab();},openTabDelayed:function(_L0,_L1,_L2){this.openTab.bind(this,_L0,_L1,_L2).defer();},openTab:function(_L0,_L1,_L2){if(this.focusedTab==_L1)return;this._unfocus();this.focusedWrapper=_L0;this.focusedContent=_L2;this.focusedTab=_L1;this.disableUnfocus=this.focusedTab;setTimeout(function(){this.disableUnfocus=null;}.bind(this),50);if(_L2&&!this.contentResized[_L2]){ge(_L0).style.visibility='hidden';show(_L0);this.tabContentResize(_L0,_L2);ge(_L0).style.visibility='';}else show(_L0);CSS.addClass(ge(_L1),'focused');CSS.addClass(this.holder,'tab_open');Arbiter.inform(PresenceMessage.TAB_OPENED,{sender:this,tabID:_L1});},contentChanged:function(_L0){delete this.contentResized[_L0];},tabContentResize:function(_L0,_L1,_L2){if(this.poppedOut||this.inVideoChat)return;var _L3=ge(_L1);var _L4=ge(_L0);if(!_L3||!_L4)return;var _L5=_L3.parentNode;if(this.focusedWrapper==_L0)this.contentResized[_L1]=true;if(!this.contentPaddings[_L0]){var _L6=Vector2.getHiddenElementDimensions(_L4);var _L7=Vector2.getHiddenElementDimensions(_L5);this.contentPaddings[_L0]=_L6.y-_L7.y;}if(ua.ie()<8){_L5.style.height='auto';dimContent=Vector2.getHiddenElementDimensions(_L5);}else dimContent=Vector2.getHiddenElementDimensions(_L3);var _L8=this.maxTabHeight-this.contentPaddings[_L0];if(dimContent.y&&dimContent.y<_L8){CSS.removeClass(_L5,'scroll');_L5.style.height=_L2?(dimContent.y+'px'):'auto';}else{CSS.addClass(_L5,'scroll');_L5.style.height=_L8+'px';}},pauseOffClick:function(_L0){this.disableUnfocus=_L0;},resumeOffClick:function(){this.disableUnfocus=null;},renderLink:function(_L0,_L1,_L2){return '<a href="'+_L0+'"'+(this.inPopoutWindow||this.inVideoChat?' target="_blank"':'')+(_L2?_L2:'')+'>'+_L1+'</a>';},checkRebuild:function(){if(this.isShutdown&&!this.isPermaShutdown)channelManager.rebuild(ChannelRebuildReasons.PageTransitionRetry);},getErrorDescription:function(_L0){var _L1=_L0.getError();var _L2=_L0.getErrorDescription();if(!_L2)_L2=_tx("An error occurred.");if(_L1==kError_Async_NotLoggedIn)_L2=_tx("Your session has timed out. Please log in.");return _L2;},showAsyncError:function(_L0,_L1){if(typeof _L1=='undefined'||!_L1){var _L2=_tx("Chat");_L1=_tx("Facebook Chat Error");}var _L3=this.getErrorDescription(_L0);new ErrorDialog().showError(_L1,_L3);},showTransportError:function(_L0,_L1){if(typeof _L1=='undefined'||!_L1){var _L2=_tx("Chat");_L1=_tx("Facebook Chat Error");}var _L3=_tx("Could not connect to Facebook {Chat} at this time.",{'Chat':_tx("Chat")});new ErrorDialog().showError(_L1,_L3);this.warn("presence: got async transport error: "+_L0.getErrorDescription());},checkLoginError:function(_L0){var _L1=_L0.getError();if(_L1==kError_Async_NotLoggedIn||_L1==kError_Async_LoginChanged||_L1==kError_Async_CSRFCheckFailed||_L1==kError_Login_GenericError){this.loginShutdown();return true;}return false;},checkMaintenanceError:function(_L0){if(_L0.getError()==1356007){this.maintenanceShutdown();return true;}return false;},permaShutdown:function(){this.isPermaShutdown=true;this.shutdown();},loginShutdown:function(){var _L0=_tx("Your session has timed out. Please log in.");this.shutdown(false,_L0);},connectionShutdown:function(_L0){var _L1=_tx("Could not connect to Facebook {Chat} at this time.",{'Chat':_tx("Chat")});this.shutdown(_L0,_L1);},maintenanceShutdown:function(){var _L0=_tx("Facebook {Chat} is down for maintenance at this time.",{'Chat':_tx("Chat")});this.shutdown(false,_L0);channelManager.stop();},versionShutdown:function(){var _L0=_tx("Please refresh the page to get the latest version of Facebook {Chat}.",{'Chat':_tx("Chat")});this.shutdown(false,_L0);channelManager.stop();},shutdown:function(_L0,_L1){this.isRestarting=false;this.isShuttingDown=true;var now=(new Date()).getTime();this.shutdownTime=now;if(!_L0){this._shutdown(_L1,0);}else setTimeout(this._shutdown.bind(this,_L1,now),this.shutdownDelay);},_shutdown:function(_L0,_L1){if(!this.isShuttingDown&&_L1==this.shutdownTime)return;if(_L1&&this.isShutdown)return;if(typeof _L0!='string'||!_L0)_L0=_tx("Facebook {Chat} is experiencing technical problems.",{'Chat':_tx("Chat")});if(!this.inPopoutWindow){CSS.addClass(this.holder,'presence_error');set_inner_html($('presence_error_reason'),_L0);}else{if(this.shutdownErrorDialog)this.shutdownErrorDialog.hide();this.shutdownErrorDialog=new ErrorDialog().setTitle(_tx("Facebook Chat Error")).setBody(_L0).show();}if(this.isShutdown)return;this.warn("presence: shutting down");this.isShutdown=true;Arbiter.inform(PresenceMessage.SHUTDOWN,{sender:this});},restart:function(_L0){this.isShuttingDown=false;this.isRestarting=true;if(!_L0){this._restart(0);}else setTimeout(this._restart.bind(this,this.shutdownTime),this.restartDelay);},_restart:function(_L0){if(!this.isRestarting||(_L0&&_L0!=this.shutdownTime))return;this.debug("presence: restarting");this.isShutdown=false;this.load();Arbiter.inform(PresenceMessage.RESTARTED,{sender:this});if(!this.inPopoutWindow){CSS.removeClass(this.holder,'presence_error');}else if(this.shutdownErrorDialog)this.shutdownErrorDialog.hide();},start:function(){Arbiter.inform(PresenceMessage.STARTED,{sender:this});},registerStateStorer:function(fn){this.stateStorers.push(fn);},registerStateLoader:function(fn){this.stateLoaders.push(fn);},registerTempTabCloseHandler:function(_L0){this.tempTabCloseHandler=_L0;}};function getFirstName(_L0){var _L1=_L0.split(" ");var _L2=_L1[0];var _L3=_L2.length;if(typeof _L1[1]!='undefined'&&(_L3==1||(_L3==2&&_L2.indexOf('.')!=-1)||(_L3==3&&_L2.toLowerCase()=='the')))_L2+=' '+_L1[1];return _L2;}
function ChatTab(_L0,id,_L2,_L3,_L4,_L5){this.chatDisplay=_L0;this.id=id;this.name=_L2;this.messageTypes={'msg':{visible:true,user:true,preserveHistory:false},'online':{visible:true,user:false,preserveHistory:true}};this.arbiter=new Arbiter();Arbiter.inform(ChatTab.GLOBALMESSAGETYPE.NEWTAB,{tab:this});this.tabRef='chatDisplay.tabs['+this.id+']';this.firstName=_L3;this.tabDisabled=false;this.numMissed=_L4;this.missedTime=_L5;this.focused=false;this.lastLogItem=null;this.historyLoaded=false;this.pendingSentMsgs=[];this.failedSentMsgs=[];this.sendingDisplayMsgID=null;this.historyRequestID=0;this.bounceAnimation=null;this.convTextProcessor=this._processConvText.bind(this);this.convTextEmoteProcessor=this._processConvTextEmote.bind(this);this.minTextHeight=presence.inPopoutWindow?this.minTextHeightPopout:this.minTextHeightPopin;this.typingState=this.INACTIVE;this.typingRemoteState=this.INACTIVE;this.typingLastKeystrokeAt=null;this.typingNotifyTimer=null;this.typingCheckTimer=null;this.lastMessageAt=null;this.lastMessageHadOfflineResponse=false;this._buildUI();this.addPopoutChat(id);this.loadData();this.handleVisibility(true);Sound.init();if(presence.inVideoChat)this.videochat_swf=ge(CallCenter.call(this.id)._callSWFID());}copy_properties(ChatTab,{GLOBALMESSAGETYPE:{NEWTAB:'chattabs/newtab'},TABMESSAGETYPE:{HISTORYBEGIN:'chattabs/historybegin',HISTORYITER:'chattabs/historyiter',HISTORYEND:'chattabs/historyend',CREATETAB:'chattabs/createtab',RECEIVEMSG:'chattabs/receivemsg',DISPLAYCHAT:'chattabs/displaychat',USERINFOUPDATED:'chattabs/userinfoupdated'}});copy_properties(ChatTab.prototype,{pendingToLogCompareWindow:60000,sendingCheckDelay:55000,sendingDisplayDelay:4000,convWrapLimit:30,handleWidth:136,popinWidth:226,popinHeight:250,popoutWidthOffset:180,flPopoutWidthOffset:200,minTextHeightPopin:13,minTextHeightPopout:32,maxTextHeight:77,msgBunchTime:60000,maxHandleLen:16,maxTitleLen:20,bounceDuration:50,bounceOrgPosition:-3,typingNotifyDelay:1000,typingKeystrokeExpiry:7000,INACTIVE:0,TYPING:1,isTabVisible:function(){return this.focused&&(presence.inPopoutWindow||!presence.poppedOut)&&(this.chatInfo.clientWidth>20||presence.inPopoutWindow);},start:function(){this._popSendQueue();},restart:function(){this.getHistory(true);this.handleResize.bind(this).defer();},loadData:function(){if(ChatUserInfos[this.id]){this.updateUserInfo();this.arbiter.inform(ChatTab.TABMESSAGETYPE.USERINFOUPDATED,{userInfo:ChatUserInfos[this.id]});}else this.chatDisplay.loadInitialUserInfo(this.id,this.name,this.firstName);if(this.chatDisplay.histories[this.id])this._setHistory(this.chatDisplay.histories[this.id]);},_onHistoryInitialHandler:function(_L0,_L1){if(_L0!=this.historyRequestID){presence.debug("tabs: got old history async, ignoring");return false;}},_onHistoryResponse:function(_L0,_L1){var _L2=_L1.getPayload();var _L3=_L2.userInfo;var _L4=_L2.history;ChatUserInfos[this.id]=_L3;buddyList.updateItemDisplay(this.id);this.updateUserInfo();this.arbiter.inform(ChatTab.TABMESSAGETYPE.USERINFOUPDATED,{userInfo:_L3});if(_L2.fls)buddyList.setFlids(this.id,_L2.fls);if(_L2.overlay)buddyList.addOverlayInfo(_L2.overlay);if(!_L4){this._showHistoryError();return;}var _L5=false;if(this.pendingSentMsgs.length>0&&_L4.length>0){var _L6=this.pendingSentMsgs[0];for(var i=_L4.length-1;i>=0;i--){var _L8=_L4[i];if(_L8.to==this.id){var _L9=Math.abs(_L6.time-_L8.time);if(_L9<this.pendingToLogCompareWindow&&_L6.text==_L8.msg.text){this._setMsgInfoMarkup(_L6.msgID,'');this.pendingSentMsgs.shift();this._popSendQueue();this.poppedSendQueue=true;break;}}}var _La=_L4[_L4.length-1].time;for(var i=0;i<this.pendingSentMsgs.length;i++){var _L6=this.pendingSentMsgs[i];if(_L6.time<_La)_L6.time=(++_La);}}var _Lb=this.chatDisplay.histories[this.id];if(_Lb)if(_L4.length>0){var _Lc=_L4[_L4.length-1];var _Ld=_Lc.time;for(var i=0;i<_Lb.length;i++){var _L8=_Lb[i];if(_L8.time>_Ld)_L4.push(_L8);}}else _L4=_Lb;this._setHistory(_L4);this.chatDisplay.histories[this.id]=_L4;if(_L0)if(!_L5)this._popSendQueue();},_onHistoryError:function(_L0){this._showHistoryError();},_showHistoryError:function(){show(this.chatHistoryError);this.scrollToBottom();},getHistory:function(_L0){var _L1=++(this.historyRequestID);new AsyncRequest().setInitialHandler(this._onHistoryInitialHandler.bind(this,_L1)).setHandler(this._onHistoryResponse.bind(this,_L0)).setErrorHandler(this._onHistoryError.bind(this)).setTransportErrorHandler(this._onHistoryError.bind(this)).setMethod('GET').setReadOnly(true).setOption('suppressErrorAlerts',true).setData({'id':this.id}).setURI('/ajax/chat/history.php').send();},_setHistory:function(_L0){this.lastLogItem=null;var _L1='';var _L2=0;var _L3=[];Array.prototype.push.apply(_L3,this.failedSentMsgs);Array.prototype.push.apply(_L3,this.pendingSentMsgs);var _L4=0;var _L5=false;this.arbiter.inform(ChatTab.TABMESSAGETYPE.HISTORYBEGIN);for(var i=0;i<_L0.length;i++){var _L7=_L0[i];if(typeof this.messageTypes[_L7.type]==undefined)continue;if(!this.messageTypes[_L7.type].preserveHistory)_L5=true;for(;_L2<_L3.length;_L2++){var _L8=_L3[_L2];if(!this.messageTypes[_L8.type].preserveHistory)_L5=true;if(_L8.time>_L4&&_L8.time<=_L7.time){if(this.messageTypes[_L8.type].visible)_L1+=this._renderMsg(presence.user,this.id,_L8.time,_L8,_L8.msgID,_L8.isError,_L8.infoMarkup);}else break;}if(_L7.type=='msg'){_L1+=this._renderMsg(_L7.from,_L7.to,_L7.time,_L7.msg);}else if(_L7.type=='online'){_L1+=this._renderVisibilityChange(_L7.time,_L7.text);}else this.arbiter.inform(ChatTab.TABMESSAGETYPE.HISTORYITER,{item:_L7});this.lastLogItem=_L7;_L4=_L7.time;}this.arbiter.inform(ChatTab.TABMESSAGETYPE.HISTORYEND);for(;_L2<_L3.length;_L2++){var _L8=_L3[_L2];if(this.messageTypes[_L8.type].visible){_L1+=this._renderMsg(presence.user,this.id,_L8.time,_L8,_L8.msgID,_L8.isError,_L8.infoMarkup);this.lastLogItem={'type':_L8.type,'from':presence.user,'to':this.id,'time':_L8.time,'msg':_L8};}}hide(this.chatHistoryError);this.chatConvContent.innerHTML=_L1;this.scrollToBottom();if(this.actions.setVisible('clearHistory',_L5).refresh())this.handleResize();this.historyLoaded=true;},_onClearHistoryError:function(_L0){var _L1=_tx("Chat");presence.showAsyncError(_L0,_tx("Unable to clear {Chat} history.",{'Chat':_L1}));CSS.removeClass(this.tabHandle,'history_clearing');},_onClearHistoryResponse:function(_L0){CSS.removeClass(this.tabHandle,'history_clearing');var _L1=[];for(var i=0;i<this.chatDisplay.histories[this.id].length;i++){var _L3=this.chatDisplay.histories[this.id][i];if(typeof this.messageTypes[_L3.type]=='undefined'||this.messageTypes[_L3.type].preserveHistory)_L1.push(_L3);}this._setHistory(this.chatDisplay.histories[this.id]=_L1);},clearHistory:function(){CSS.addClass(this.tabHandle,'history_clearing');new AsyncRequest().setHandler(this._onClearHistoryResponse.bind(this)).setErrorHandler(this._onClearHistoryError.bind(this)).setTransportErrorHandler(this._onClearHistoryError.bind(this)).setData({'clear_history_id':this.id}).setURI(this.chatDisplay.settingsURL).send();},_isCurrentPendingSend:function(_L0){return (this.pendingSentMsgs.length>0&&_L0==this.pendingSentMsgs[0].msgID);},_onSendInitialHandler:function(_L0){this.lastMessageHadOfflineResponse=false;},_onSendResponse:function(_L0,_L1){var _L2=_L1.getPayload();if(this._isCurrentPendingSend(_L0)){var _L3=this.pendingSentMsgs[0];_L3.asyncSuccess=true;}if(_L2&&_L2.warning){var _L4=this._renderMsgWarningMarkup(_L2.warning.title+'<br />'+_L2.warning.body);this._setMsgInfoMarkup(_L0,_L4,'msg_warning');}},_onSendTransportError:function(_L0,_L1){if(!this._isCurrentPendingSend(_L0))return;},_onSendError:function(_L0,_L1){if(!this._isCurrentPendingSend(_L0))return;var _L2=_L1.getPayload();var _L3=_L1.getError();var _L4=presence.getErrorDescription(_L1);if(_L3==kError_Chat_SendOtherNotAvailable){this.lastMessageHadOfflineResponse=true;buddyList.setUnavailable(this.id);for(var i=0;i<this.pendingSentMsgs.length;i++){var msg=this.pendingSentMsgs[i];var _L7=ge('msg_'+this.id+'_'+msg.msgID);if(_L7){var _L8='rel="dialog"';var url=new URI(this.chatDisplay.messageURL).addQueryData({id:this.id,message:msg.text}).toString();var _La=presence.renderLink(url,_tx("send as a message"),_L8);var _Lb=_tx("{message} ({=send as a message})",{'message':this._renderMsgHtmlize(msg),'=send as a message':_La});set_inner_html(_L7,_Lb);}}}else if(_L3==kError_Chat_NotAvailable){this.lastMessageHadOfflineResponse=true;chatOptions.setVisibility(false);presence.doSync();}else if(_L3==kError_Chat_TooManyMessages){_L4=_L2.error.title;new ErrorDialog().showError(_L2.error.title,_L2.error.body);}else new ErrorDialog().showError(_L1.errorSummary,_L1.errorDescription);this._sendErrorAll(_L4);},_renderMsgWarningMarkup:function(_L0){return '<p class="chat_notice chat_msg_warning">'+_L0+'</p>';},_renderMsgErrorMarkup:function(_L0){return '<p class="chat_notice chat_msg_not_sent">'+_L0+'</p>';},_sendErrorAll:function(_L0){var _L1=this._renderMsgErrorMarkup(_L0);var _L2=true;while(this.pendingSentMsgs.length){var _L3=this.pendingSentMsgs.shift();_L3.isError=true;if(_L2)_L3.infoMarkup=_L1;this._setMsgInfoMarkup(_L3.msgID,_L1,'msg_error');this.failedSentMsgs.push(_L3);_L2=false;_L1='';}},_sendError:function(_L0,_L1){var _L2=this._renderMsgErrorMarkup(_L1);var _L3=this.pendingSentMsgs.shift();_L3.isError=true;_L3.infoMarkup=_L2;this._setMsgInfoMarkup(_L0,_L2,'msg_error');this.failedSentMsgs.push(_L3);this._popSendQueue();this._bumpSendingMessageDisplay(_L0);},_createMessage:function(_L0,_L1){var _L2=rand32()+1;var _L3=presence.getTime();if(this.lastLogItem&&_L3<this.lastLogItem.time)_L3=this.lastLogItem.time+1;var _L4={text:_L0,msgID:_L2,type:_L1,time:_L3,asyncSuccess:false,isError:false,errorMarkup:''};return _L4;},_flushSmallQueue:function(){if(this.pendingSentMsgs.length==1)this._sendMessage(this.pendingSentMsgs[0],!channelManager.iframeEverLoaded);},_updateChatActivity:function(_L0,msg){this.lastLogItem={'type':_L0.type,'from':presence.user,'to':this.id,'time':_L0.time,'msg':msg};this.chatDisplay.chatActivityTime=(new Date()).getTime();presence.doSync();},sendInput:function(){var _L0=this.chatInput.value;if(!_L0||!_L0.match(/[^\s]/))return;if(this.actions.setVisible('clearHistory',true).refresh())this.handleResize();this.chatInput.value='';var _L1=this._createMessage(_L0,'msg');this.pendingSentMsgs.push(_L1);this._flushSmallQueue();var msg={'text':_L0};var _L3=this._renderMsg(presence.user,this.id,_L1.time,msg,_L1.msgID);this._addConvMarkup(_L3);this._updateChatActivity(_L1,msg);this._resetTypingState();},notifyTypingState:function(_L0){if(_L0!=this.typingRemoteState){this.typingRemoteState=_L0;presence.debug('tabs: notifyTyping('+_L0+')');if(!channelManager.iframeEverLoaded)return;var _L1={'typ':_L0,'to':this.id};new AsyncRequest().setHandler(bagofholding).setErrorHandler(bagofholding).setTransportErrorHandler(bagofholding).setData(_L1).setURI('/ajax/chat/typ.php').send();}},_sendMessage:function(_L0,_L1){_L0.time=presence.getTime();if(this.lastLogItem&&_L0.time<this.lastLogItem.time)_L0.time=this.lastLogItem.time+1;clearTimeout(this.sendingDisplayTimeout);clearTimeout(this.checkMessageSentTimeout);this.sendingDisplayTimeout=setTimeout(this._checkMessageSentShort.bind(this,_L0.msgID),this.sendingDisplayDelay);this.checkMessageSentTimeout=setTimeout(this._checkMessageSentLong.bind(this,_L0.msgID),this.sendingCheckDelay);if(_L1)return;var _L2=_L0.msgID;var _L3=this.chatDisplay.histories[this.id];var _L4=null;if(_L3)for(var i=_L3.length-1;i>0;i--)if(_L3[i].type=='msg'){_L4=_L3[i].time;break;}var _L6={msg_id:_L2,client_time:_L0.time,to:this.id,num_tabs:this.chatDisplay.numTabs,pvs_time:_L4};if(_L0.type=='video'){_L6.action=_L0.action;_L6.uid=_L0.uid;var _L7='/ajax/chat/video.php';}else{_L6.msg_text=_L0.text;var _L7='/ajax/chat/send.php';}new AsyncRequest().setInitialHandler(this._onSendInitialHandler.bind(this)).setHandler(this._onSendResponse.bind(this,_L2)).setErrorHandler(this._onSendError.bind(this,_L2)).setTransportErrorHandler(this._onSendTransportError.bind(this,_L2)).setData(_L6).setURI(_L7).send();},_popSendQueue:function(){if(this.pendingSentMsgs.length==0)return;var _L0=this.pendingSentMsgs[0];this._sendMessage(_L0);},_checkMessageSentShort:function(_L0){if(this._isCurrentPendingSend(_L0))this._setSendingDisplay(this.pendingSentMsgs[0]);},_checkMessageSentLong:function(_L0){if(this._isCurrentPendingSend(_L0))if(this.pendingSentMsgs[0].asyncSuccess){this._sendErrorAll(_tx("Could not connect to Facebook {Chat} at this time.",{'Chat':_tx("Chat")}));}else if(channelManager.iframeIsLoaded){presence.error('tabs: send took too long; resending and invalidating old one');this._sendMessage(this.pendingSentMsgs[0]);}else{presence.error("tabs: send took too long, but iframe isn't yet loaded.  will check again later.");setTimeout(this._checkMessageSentLong.bind(this,this.pendingSentMsgs[0].msgID),this.sendingCheckDelay);}},_bumpSendingMessageDisplay:function(_L0){if(_L0==this.sendingDisplayMsgID){this._setMsgInfoMarkup(_L0,'');if(this.pendingSentMsgs.length>0)this._setSendingDisplay(this.pendingSentMsgs[0]);}},_setSendingDisplay:function(_L0){this.sendingDisplayMsgID=_L0.msgID;_L0.infoMarkup='<p class="chat_notice sending">'+_tx("Sending:")+'</p>';this._setMsgInfoMarkup(_L0.msgID,_L0.infoMarkup);},_setMsgInfoMarkup:function(_L0,_L1,_L2){var _L3=ge('msg_'+this.id+'_'+_L0);if(!_L3)return;var _L4=ge('pending_'+this.id+'_'+_L0);if(_L4)_L4.innerHTML=_L1;if(_L2)CSS.addClass(_L3,_L2);this.scrollToBottom();},updateUserInfo:function(){this.chatInfoPic.src=ChatUserInfos[this.id].thumbSrc;CSS.removeClass(this.chatInfo,'hidden');},tabHitAreaOnClick:function(){if(this.suppressHeaderCollapse)return;if(!presence.inVideoChat)if(presence.inPopoutWindow){this.chatDisplay.focusTab(this.id,this.name,this.firstName);}else this.chatDisplay.toggleTab(this.id,this.name,this.firstName);this.chatDisplay.doStopBlinking();},showChat:function(){if(presence.inVideoChat){animation(this.chatWrapper).to('right','0').duration(300).ease(animation.ease.end).go();animation(this.videochat_swf).to('marginRight','226px').duration(300).ease(animation.ease.end).go();this.arbiter.inform(ChatTab.TABMESSAGETYPE.DISPLAYCHAT,{visible:true});}},tabXOnClick:function(e){if(presence.inVideoChat){animation(this.chatWrapper).to('right','-228px').duration(300).ease(animation.ease.end).go();animation(this.videochat_swf).to('marginRight','0').duration(300).ease(animation.ease.end).go();this.arbiter.inform(ChatTab.TABMESSAGETYPE.DISPLAYCHAT,{visible:false});}else{this.chatDisplay.closeTab(this.id);this.chatDisplay.doStopBlinking();}$E(e).kill();return false;},headerLinkMouseOver:function(){CSS.addClass(this.chatHeader,'suppress_hover');this.suppressHeaderCollapse=true;},headerLinkMouseOut:function(){CSS.removeClass(this.chatHeader,'suppress_hover');this.suppressHeaderCollapse=false;},chatConvOnMouseDown:function(_L0){_L0=$E(_L0);if(_L0.button!=0)return;this.chatDisplay.doStopBlinking();},chatConvOnMouseUp:function(){if(DOM.getSelectionSupported()&&(DOM.getSelection()==''))this.focusChatInput();},focusChatInput:function(){if(!this.tabDisabled&&this.isTabVisible())this.chatInput.focus();},_buildUI:function(){var _L0='missed_count_'+this.id;var _L1='chat_window_wrapper_'+this.id;var _L2='chat_conv_'+this.id;var _L3='chat_history_error_'+this.id;var _L4='chat_header_'+this.id;var _L5='chat_info_'+this.id;var _L6='chat_info_pic_'+this.id;var _L7='chat_conv_content_'+this.id;var _L8='chat_input_'+this.id;var _L9='chat_shadow_input_'+this.id;var _La='chat_toolbox_'+this.id;var _Lb=_tx("Chat");var _Lc=htmlize(this.trimName(this.maxHandleLen));var _Ld=htmlize(this.trimName(this.maxTitleLen));var _Le=' onmouseover="'+this.tabRef+'.headerLinkMouseOver();" onmouseout="'+this.tabRef+'.headerLinkMouseOut();"';var _Lf=this.chatDisplay.profileURL+'?id='+this.id;var _L10=presence.renderLink(_Lf,'<img class="chat_info_pic" id="'+_L6+'" title="View Profile" style="display:block;">',_Le);var _L11=presence.renderLink(_Lf,_Ld,_Le);var _L12=['<div class="tab_button_div" ','onmouseover="CSS.addClass(this, \'hover\')" ','onmouseout="CSS.removeClass(this, \'hover\')">','<div title="',_tx("Show\/Hide {Chat} Window",{'Chat':_Lb}),'" ','class="tab_hit_area" ','onclick="',this.tabRef,'.tabHitAreaOnClick()">','<div class="tab_name">','<span>',_Lc,'</span>','<img src="http://static.ak.fbcdn.net/images/spacer.gif"','class="tab_availability" alt="',_Lc,'"/>','</div>','</div>','<div class="tab_count" id="',_L0,'"></div>','<div title="',_tx("Close {Chat} Window",{'Chat':_Lb}),'" ','class="tab_x" ','onclick="',this.tabRef,'.tabXOnClick(event)" ','onmouseover="CSS.addClass(this, \'hover\')" ','onmouseout="CSS.removeClass(this, \'hover\')">','</div>','<div class="chat_window_wrapper" id="',_L1,'">','<div class="chat_window">','<div class="chat_header" id="',_L4,'" onclick="',this.tabRef,'.tabHitAreaOnClick()">','<div class="header_buttons">','<a title="',_tx("Close {Chat} Window",{'Chat':_Lb}),'" ','class="close" ','onmouseover="CSS.addClass($(\'',_L4,'\'), \'suppress_hover\')" ','onmouseout="CSS.removeClass($(\'',_L4,'\'), \'suppress_hover\')" ','onclick="',this.tabRef,'.tabXOnClick(event)">','</a>','<a title="',_tx("Hide {Chat} Window",{'Chat':_Lb}),'" ','class="minimize">','</a>','</div>',_L10,'<div class="chat_header_name">',_L11,'</div>','</div>','<div class="chat_info" id="',_L5,'">','&nbsp;','</div>','<div id="',_La,'" class="toolbox">','<div class="chat_actions"></div>','</div>','<div class="chat_conv" id="',_L2,'" ','onmousedown="',this.tabRef,'.chatConvOnMouseDown(event)" ','onmouseup="',this.tabRef,'.chatConvOnMouseUp()">','<div class="chat_notice" id="',_L3,'" style="display:none">',_tx("Couldn't retrieve chat history"),'</div>','<div class="chat_conv_content" id="',_L7,'"></div>','</div>','<div class="chat_input_div">','<textarea class="chat_shadow_input" id="',_L9,'"></textarea>','<div class="chat_input_icon"></div>','<textarea class="chat_input" id="',_L8,'" ','onclick="chatDisplay.doStopBlinking()" ','onkeydown="return ',this.tabRef,'.inputKeyDown(event)" ','onkeypress="return ',this.tabRef,'.inputKeyPress(event)" ','></textarea>','<div class="chat_input_border"></div>','</div>','</div>','</div>','</div>'];this.tabHandle=document.createElement('div');var _L13=ge('chat_tab_bar');var _L14=null;for(var id in this.chatDisplay.tabs)_L14=this.chatDisplay.tabs[id];if(_L14){_L13.insertBefore(this.tabHandle,_L14.tabHandle);}else _L13.appendChild(this.tabHandle);this.tabHandle.id='tab_handle_'+this.id;CSS.setClass(this.tabHandle,'tab_handle');this.tabHandle.style.width=this.handleWidth+'px';this.tabHandle.style.display='block';this.tabHandle.innerHTML=_L12.join('');this.tabCount=ge(_L0);this.chatWrapper=ge(_L1);this.chatConv=ge(_L2);this.chatHistoryError=ge(_L3);this.chatHeader=ge(_L4);this.chatInfo=ge(_L5);this.chatInfoPic=ge(_L6);this.chatConvContent=ge(_L7);this.chatInput=ge(_L8);this.chatShadowInput=ge(_L9);this.toolbox=ge(_La);var _L16=DOM.find(this.toolbox,'div.chat_actions');this.actions=new ChatTabActions(_L16);this.actions.appendAction('clearHistory',_tx("Clear {Chat} History",{'Chat':_Lb}),this.clearHistory.bind(this));this.arbiter.inform(ChatTab.TABMESSAGETYPE.CREATETAB,{toolbox:this.toolbox});this.actions.refresh();this.popoutChatTabs=presence.inPopoutWindow?ge('open_chats'):null;this.adjustWrapperBottom();this._updateNumMissedDisplay();},adjustWrapperBottom:function(){if(presence.isFF2){var _L0=presence.getHolderBottomPosition();CSS.setStyle(this.chatWrapper,'bottom',(_L0+24)+'px');}},show:function(){this.tabHandle.style.display='block';},hide:function(){this.tabHandle.style.display='none';},inputKeyDown:function(_L0){_L0=$E(_L0);this.chatDisplay.doStopBlinking();if(this.chatDisplay.gatedFeatures.typ_send)this._updateTyping.bind(this).defer();if(_L0.keyCode==KEYS.RETURN&&!_L0.shiftKey)if(this.chatInput.value)this.sendInput();if(_L0.keyCode==KEYS.DELETE||_L0.keyCode==KEYS.BACKSPACE)this.handleResize.bind(this).defer();},inputKeyPress:function(_L0){_L0=$E(_L0);this.handleResize.bind(this).defer();if(_L0.keyCode==KEYS.RETURN&&!_L0.shiftKey){_L0.returnValue=false;return false;}},_updateTyping:function(){var _L0=this.typingState;if(this.chatInput.value.length==0){if(_L0==this.INACTIVE){}else this._typingTransition(this.INACTIVE);}else if(_L0==this.TYPING){this._recordKeystroke();}else if(_L0==this.INACTIVE){this._typingTransition(this.TYPING);this._recordKeystroke();}},_recordKeystroke:function(){this.typingLastKeystrokeAt=new Date();if(!this.typingCheckTimer)this.typingCheckTimer=setTimeout(this._checkTyping.bind(this),this.typingKeystrokeExpiry);},_checkTyping:function(){var _L0=this.typingLastKeystrokeAt.valueOf()+this.typingKeystrokeExpiry;var now=new Date().valueOf();if(now>_L0){this._typingTransition(this.INACTIVE);}else{clearTimeout(this.typingCheckTimer);this.typingCheckTimer=setTimeout(this._checkTyping.bind(this),_L0-now+10);}},_typingTransition:function(_L0){clearTimeout(this.typingCheckTimer);this.typingCheckTimer=null;typingLastKeystrokeAt=null;presence.debug('typing:'+this.typingState+' -> '+_L0);this.typingState=_L0;clearTimeout(this.typingNotifyTimer);this.typingNotifyTimer=setTimeout(this.notifyTypingState.bind(this,_L0),this.typingNotifyDelay);},_resetTypingState:function(){presence.debug('typing: ** RESET **');this.typingState=this.INACTIVE;this.typingRemoteState=this.INACTIVE;this.typingLastKeystrokeAt=null;clearTimeout(this.typingNotifyTimer);this.typingNotifyTimer=null;clearTimeout(this.typingCheckTimer);this.typingCheckTimer=null;},trimName:function(_L0){var _L1=this.name;if(_L1.length>_L0)_L1=_L1.substring(0,_L0-2)+'...';return _L1;},handleVisibility:function(_L0){var _L1=chatOptions.visibility;if(chatOptions.visibility){this._enableTab(true,false,_L1,_L0);}else this._disableTab(true,_L1,_L0);this.handleBuddyAvailability(!_L0&&_L1,_L0);},handleBuddyAvailability:function(_L0,_L1){if(!chatOptions.visibility)return;var _L2=buddyList.getAvailability(this.id);if(_L2){this._enableTab(false,_L2.i,_L0,_L1);}else this._disableTab(false,_L0,_L1);},_enableTab:function(_L0,_L1,_L2,_L3){_L3=_L3||false;var _L4=this.tabDisabled;this.tabDisabled=false;if(presence.inPopoutWindow){CSS.removeClass(this.popoutTab,'disabled');CSS.conditionClass(this.popoutTab,'idle',_L1);}CSS.removeClass(this.tabHandle,'disabled');CSS.conditionClass(this.tabHandle,'idle',_L1);if((_L0&&!_L3)||(!_L0&&_L4&&!_L2))this._newVisibilityChange(_L0,_L3,true);},_disableTab:function(_L0,_L1,_L2){_L2=_L2||false;var _L3=this.tabDisabled;this.tabDisabled=true;if(presence.inPopoutWindow){CSS.addClass(this.popoutTab,'disabled');CSS.removeClass(this.popoutTab,'idle');}CSS.addClass(this.tabHandle,'disabled');CSS.removeClass(this.tabHandle,'idle');if((_L0||_L2||!_L3)&&!this.lastMessageHadOfflineResponse&&!_L1)this._newVisibilityChange(_L0,_L2,false);},handleResize:function(){var _L0;var _L1;var _L2;var _L3;var _L4=31;var _L5=this.toolbox.childNodes;for(var i=0;i<_L5.length;++i){var _L7=_L5[i];if(shown(_L7))_L4+=Vector2.getElementDimensions(_L7).y;}if(presence.inVideoChat||presence.inPopoutWindow){var _L8=33;_L4+=Vector2.getElementDimensions(this.chatInfo).y-_L8;}if(presence.inVideoChat){var _L9=226;_L0=_L9;_L1=_L9-28;_L2=_L9-16;_L3=presence.popoutHeight-77;}else if(presence.inPopoutWindow){var _La=(presence.popoutWidth>330)?presence.popoutWidth:330;_L0=_La-this.flPopoutWidthOffset;_L1=_La-this.flPopoutWidthOffset-28;_L2=_La-this.flPopoutWidthOffset-16;var _Lb=Vector2.getElementDimensions(ge('popout_chat_tabs')).y;_L3=presence.popoutHeight-_Lb-33;}else{_L0=this.popinWidth;_L1=this.popinWidth-28;_L2=this.popinWidth-8;_L3=this.popinHeight;}this.chatShadowInput.style.width=this.chatInput.style.width=_L1+'px';this.chatShadowInput.value=this.chatInput.value;var _Lc=this.chatShadowInput.scrollHeight;if(!_Lc||presence.isOpera){_Lc=this.minTextHeight;if(this.chatInput.value){var re=new RegExp('([\n]|[^\n]{'+parseInt(_L1/8)+'})','g');var _Le=this.chatInput.value.match(re);if(_Le)_Lc=(_Le.length+1)*this.minTextHeight;}if(presence.isSafari2)_Lc+=8;}if(ua.ie())_Lc-=6;if(_Lc>this.maxTextHeight){_Lc=this.maxTextHeight;}else if(_Lc<this.minTextHeight)_Lc=this.minTextHeight;if(presence.isSafari2){_L4-=7;}else if(ua.ie()<7)if(this.tabDisabled)_L4+=4;if(!presence.inPopoutWindow||ua.ie()){this.chatHeader.style.width=_L0+'px';this.chatInfo.style.width=(_L0-55)+'px';this.chatConv.style.width=_L0+'px';}this.chatInput.style.height=_Lc+'px';this.chatConv.style.height=Math.max(0,(_L3-_L4-_Lc))+'px';this.scrollToBottom();},isUserScrolled:function(){return (this.chatConv.scrollHeight>this.chatConv.scrollTop+this.chatConv.clientHeight);},scrollToBottom:function(){this.chatConv.scrollTop=this.chatConv.scrollHeight;},unfocus:function(){this.focused=false;CSS.removeClass(this.tabHandle,'focused');},focus:function(_L0,_L1){if(this.focused)return;CSS.addClass(this.tabHandle,'focused');this.focused=true;if(!_L0){this._onFocusUIActions();setTimeout(this._onFocusUIActions.bind(this),100);}if(!this.historyLoaded)this.getHistory(false);this._updateNumMissed(0);this._stopBounce();},_onFocusUIActions:function(){this.handleResize();if(ua.ie()<7&&presence.inPopoutWindow)this.chatWrapper.style.top='67px';this.focusChatInput();},_startBounce:function(){if(presence.isFF2&&presence.isWindows)return;this.bounceAnimation=animation(this.tabCount).to('top',-11).duration(this.bounceDuration+40).checkpoint().to('top',this.bounceOrgPosition).duration(this.bounceDuration).checkpoint().to('top',-11).duration(this.bounceDuration+40).checkpoint().to('top',this.bounceOrgPosition).duration(this.bounceDuration).checkpoint().to('top',-7).duration(this.bounceDuration).checkpoint().to('top',-5).duration(this.bounceDuration).checkpoint().to('top',this.bounceOrgPosition).duration(this.bounceDuration).checkpoint().go();},_stopBounce:function(){if(this.bounceAnimation){this.bounceAnimation.stop();this.bounceAnimation=null;}},close:function(){this.tabHandle.parentNode.removeChild(this.tabHandle);this.closePopoutChat();},addPopoutChat:function(id){if(this.popoutChatTabs){this.popoutTab=document.createElement('div');this.popoutTab.id='popout_tab_'+this.id;this.popoutTab.className='popout_tab_button'+(this.chatDisplay.gatedFeatures.typ_show?'':' vanilla')+((id==this.chatDisplay.focused)?' highlight':'');var _L1='popout_missed_'+this.id;this.popoutTab.innerHTML='<div class="popout_tab_hit_area" onclick="'+this.tabRef+'.tabHitAreaOnClick();">'+'<div id="'+_L1+'" class="popout_tab_count"></div>'+'<div class="popout_tab_name">'+this.name+'</div>'+'<div class="popout_tab_status"></div>'+'<a class="popout_tab_x" href="#" onclick="'+this.tabRef+'.tabXOnClick(event)"></a>'+'</div>';this.popoutChatTabs.appendChild(this.popoutTab);this.popoutTabCount=ge(_L1);CSS.addClass(document.body,'active_chats');show(ge('popout_chat_tabs'));}},closePopoutChat:function(){if(this.popoutChatTabs){this.popoutChatTabs.removeChild(this.popoutTab);if(this.popoutChatTabs.childNodes.length<=0){hide(ge('popout_chat_tabs'));CSS.removeClass(document.body,'active_chats');}}},selectPopoutChat:function(){CSS.addClass(this.popoutTab,'highlight');},deselectPopoutChat:function(){CSS.removeClass(this.popoutTab,'highlight');},_newVisibilityChange:function(_L0,_L1,_L2){var _L3=presence.getTime();var _L4;if(_L0){if(_L2){_L4=_tx("You are online.",{'name':this.firstName});}else _L4=_tx("You are not online.",{'name':this.firstName});}else if(_L2){_L4=_tx("{name} is online.",{'name':this.firstName});}else _L4=_tx("{name} is offline.",{'name':this.firstName});var _L5={'type':'online','time':_L3,'text':_L4};var _L6=this.chatDisplay.getHistory(this.id,true);_L6.push(_L5);var _L7=this._renderVisibilityChange(_L3,_L4);this._addConvMarkup(_L7);this.lastLogItem=_L5;},newTyping:function(_L0){var _L1=_L0.from;var to=_L0.to;var typ=_L0.st;if(!this.chatDisplay.gatedFeatures.typ_show){return;}else if((new Date()-this.lastMessageAt)<this.typingNotifyDelay)return;presence.debug('typing from '+_L1+': '+typ);var _L4=(typ==this.TYPING)&&(this.numMissed==0);if(to!=this.id){if(presence.inPopoutWindow)CSS.conditionClass(this.popoutTab,'typing',_L4);CSS.conditionClass(this.tabHandle,'typing',_L4);buddyList.setAvailable(this.id);}},_isChatMessage:function(_L0){return;typeof this.messageTypes[_L0.type]!='undefined'&&this.messageTypes[_L0.type].user;},newMsg:function(_L0){var _L1=_L0.from;var to=_L0.to;var _L3=_L0.type;var msg=_L0.msg;var _L5=msg.time;var _L6=msg.clientTime;var _L7=msg.msgID;var _L8=true;this.lastMessageAt=new Date();var _L9=this.chatDisplay.getHistory(this.id,true);var _La=null;for(var i=_L9.length-1;i>=0;i--)if(this._isChatMessage(_L9[i])){_La=_L9[i];break;}if(_La&&_L5<=_La.time){var _Lc=false;for(var i=0;i<_L9.length;i++)if(this._isChatMessage(_L9[i])&&_L5==_L9[i].time){_Lc=true;break;}if(_Lc){presence.warn('tabs: already had this msg');return;}for(var i=_L9.length-1;i>=0;i--){var _Ld=_L9[i];if(this._isChatMessage(_Ld)&&(_Ld.to!=to||(!_Ld.msg.clientTime||_Ld.msg.clientTime<_L6)))break;}presence.warn('tabs: merging new msg due to out-of-order server timestamp');if(i==_L9.length-1){this.chatDisplay.histories[this.id].push(_L0);}else{_L9.splice(i+1,0,_L0);this._setHistory(_L9);_L8=false;}}else this.chatDisplay.histories[this.id].push(_L0);if(to!=this.id){if(this.chatDisplay.gatedFeatures.sound&&chatOptions.getSetting('sound'))Sound.play('/sound/pop.mp3',true);buddyList.setAvailable(this.id);if(!this.focused){this._updateNumMissed(this.numMissed+1,_L5);this._startBounce();}if(presence.inPopoutWindow)CSS.removeClass(this.popoutTab,'typing');CSS.removeClass(this.tabHandle,'typing');}else{this._updateNumMissed(0,_L5);for(var i=0;i<this.pendingSentMsgs.length;i++)if(_L7==this.pendingSentMsgs[i].msgID){var _Le=this.pendingSentMsgs.splice(i,1);this._bumpSendingMessageDisplay(_L7);this._popSendQueue();_L8=false;break;}}this.arbiter.inform(ChatTab.TABMESSAGETYPE.RECEIVEMSG,{type:_L3,msgItem:_L0});_L8=this.messageTypes[_L3].visible&&_L8;if(_L8){var _Lf=this._renderMsg(_L1,to,_L5,msg);this._addConvMarkup(_Lf);if(this.actions.setVisible('clearHistory',true).refresh())this.handleResize();this.lastLogItem=_L0;}},getInputElemId:function(){return 'chat_input_'+this.id;},_updateNumMissed:function(_L0,_L1){if(_L0==this.numMissed||(_L1&&_L1<=this.missedTime))return;if(_L0>99)_L0=99;this.numMissed=_L0;this.missedTime=_L1;this._updateNumMissedDisplay();},_updateNumMissedDisplay:function(){this.tabCount.innerHTML=this.numMissed;if(this.numMissed>0){if(this.popoutTabCount){this.popoutTabCount.style.display='block';this.popoutTabCount.innerHTML=this.numMissed;}else chatTabSlider.updateMissedCount();CSS.addClass(this.tabHandle,'highlight');this.tabCount.style.display='block';}else{if(this.popoutTabCount){this.popoutTabCount.style.display='none';}else chatTabSlider.updateMissedCount();CSS.removeClass(this.tabHandle,'highlight');this.tabCount.style.display='none';}},_addConvMarkup:function(_L0){var _L1=this.isUserScrolled();this.chatConvContent.innerHTML+=_L0;if(!_L1)this.scrollToBottom();},_renderDateBreak:function(_L0){var _L1=new Date();_L1.setTime(_L0);var _L2=false;var _L3=new Date();if(this.lastLogItem)_L3.setTime(this.lastLogItem.time);if(_L1.getDate()!=_L3.getDate()||_L1.getMonth()!=_L3.getMonth())_L2=true;var _L4='';if(_L2){var _L5='date_divider';if(!this.lastLogItem)_L5+=' first';_L4='<div class="'+_L5+'">'+renderDate(_L1,!presence.inPopoutWindow)+'</div>';}return _L4;},_renderVisibilityChange:function(_L0,_L1){var _L2=this._renderDateBreak(_L0);_L2+='<div class="visibility_change">'+'<span class="time_stamp">'+chatDisplay.renderServerTime(_L0)+'</span>'+_L1+'</div>';return _L2;},_renderMsg:function(_L0,to,_L2,msg,_L4,_L5,_L6){var _L7=_L0!=this.id;var _L8=_L7&&_L0==to;var _L9=_L7&&!_L8?'self':'other';var _La=this._renderDateBreak(_L2);if(!_La&&this.lastLogItem&&this.lastLogItem.type=='msg'&&this.lastLogItem.from==_L0&&_L2-this.lastLogItem.time<this.msgBunchTime){}else{var _Lb=ChatUserInfos[_L0];var pic=_Lb&&presence.inPopoutWindow?'<img src="'+_Lb.thumbSrc+'" class="pic" />':'';var _Ld=_L7?htmlize(presence.firstName):presence.renderLink(this.chatDisplay.profileURL+'?id='+this.id,htmlize(this.firstName));var _Le=chatDisplay.renderServerTime(_L2);_La+='<h5 class="'+_L9+'">'+pic+' <span class="time_stamp ts_'+_L9+'">'+_Le+'</span>'+_Ld+'</h5>';}if(_L4||_L6){var _Lf=_L4?' id="pending_'+this.id+'_'+_L4+'"':'';_La+='<div'+_Lf+' class="pic_padding">'+(_L6?_L6:'')+'</div>';}var _L10=_L4?' id="msg_'+this.id+'_'+_L4+'"':'';msgClasses='p_'+_L9+' pic_padding'+(_L5?' msg_error':'');_La+='<p'+_L10+' class="'+msgClasses+'">'+this._renderMsgHtmlize(msg)+'</p>';return _La;},_renderMsgHtmlize:function(msg){return html_hyperlink(msg.text||'',this._processStyledText.bind(this,this.convTextEmoteProcessor),this.convTextProcessor,true);},_processStyledText:function(_L0,str){return _L0(str).replace(/\b_([^_\*]+)_\b/g,'<u>$1</u>').replace(/(\s|^)\*([^_\*]+)\*(?=$|\s)/g,'$1<b>$2</b>');},_processConvText:function(str){return html_wordwrap(str,this.convWrapLimit);},_processConvTextEmote:function(str){return Emote.htmlEmote(str,this.convTextProcessor);}});function renderDate(_L0,_L1){if(_L1){var _L2=new Date();_L2.setHours(0);_L2.setMinutes(0);_L2.setSeconds(0);_L2.setMilliseconds(0);var _L3=24*60*60*1000;var _L4=_L2.getTime()-_L0.getTime();if(_L4<=0){return _tx("Today");}else if(_L4<_L3)return _tx("Yesterday");}var _L5='';switch(_L0.getMonth()){case 0:_L5=_tx("January");break;case 1:_L5=_tx("February");break;case 2:_L5=_tx("March");break;case 3:_L5=_tx("April");break;case 4:_L5=_tx("May");break;case 5:_L5=_tx("June");break;case 6:_L5=_tx("July");break;case 7:_L5=_tx("August");break;case 8:_L5=_tx("September");break;case 9:_L5=_tx("October");break;case 10:_L5=_tx("November");break;case 11:_L5=_tx("December");break;}return _tx("{month} {date}",{'month':_L5,'date':_L0.getDate()});}
function ChatDisplay(_L0,_L1,_L2,_L3,_L4){this.histories=_L0;this.everSentMessage=_L1;this.user=presence.user;var _L5=env_get('www_base');this.profileURL=_L5+'profile.php';this.messageURL=_L5+'gigaboxx/dialog/MessageComposer.php';this.settingsURL='/ajax/chat/settings.php';this.gatedFeatures=_L4;this.useUICookieCache=_L4['ui_cookie_cache'];this.renderServerTime=this.gatedFeatures['24h_times']?this._renderServerTime24hr:this._renderServerTime12hr;this._init(_L2,_L3);}ChatDisplay.prototype={blinkTime:1500,initialBlinkDelay:3000,_init:function(_L0,_L1){this.loaded=false;this.tabs={};this.numTabs=0;this.lastFocused=null;this.newMsgNames=[];this.newMsgNamesIndex=0;this.blinkingTimer=null;this.windowIsFocused=true;this.chatActivityTime=0;if(this.useUICookieCache){this.uiChangeTime=0;this.uiCookieCacheTime=(Env['rep_lag']+presence.sitevars.CHAT_UI_COOKIE_CACHE_WINDOW)*1000;}this.favIcon=null;this.altFavIcon=null;this.initialFocusedChat=_L1;this.initialActiveChats=_L0;presence.registerStateStorer(this._store.bind(this));presence.registerStateLoader(this._load.bind(this));var _L2=['unfocus_chat','focus_chat','close_chat','msg','video','typ'].map(PresenceMessage.getArbiterMessageType);Arbiter.subscribe(_L2,this._handlePresenceMessage.bind(this));Arbiter.subscribe(PresenceMessage.STARTED,this.start.bind(this));Arbiter.subscribe(PresenceMessage.SHUTDOWN,this.shutdown.bind(this));Arbiter.subscribe(PresenceMessage.RESTARTED,this.restart.bind(this));Arbiter.subscribe(ChatOptions.VISIBILITY_CHANGED,this.handleVisibility.bind(this));Arbiter.subscribe(ChatBuddyList.AVAILABILITY_CHANGED,this._onBuddyAvailability.bind(this));Arbiter.subscribe(PresenceMessage.WINDOW_RESIZED,this.handleResize.bind(this));Event.listen(window,'focus',this.onWindowFocus.bind(this));Event.listen(window,'blur',this.onWindowBlur.bind(this));},onWindowFocus:function(){this.isWindowFocused=true;this.doStopBlinking();},onWindowBlur:function(){this.isWindowFocused=false;},start:function(){for(var id in this.tabs)this.tabs[id].start();},shutdown:function(){this._stopBlinking();},restart:function(){for(var id in this.tabs)this.tabs[id].restart();},loadInitialUserInfo:function(id,_L1,_L2){if(ChatUserInfos[id])return;ChatUserInfos[id]={'name':_L1,'firstName':_L2,'thumbSrc':''};},_loadInitialTabs:function(_L0,_L1){var _L2=null;for(var id in _L0){if(presence.inVideoChat&&id!=presence.inVideoChatWith)continue;if(!_L2)_L2=id;if(this.tabs[id])continue;var _L4=_L0[id];var _L5,_L6;if(ChatUserInfos[id]){_L5=ChatUserInfos[id].name;_L6=ChatUserInfos[id].firstName;}else{_L5=_L4.n;if(!_L5){Util.warn('chat display: trying to load chat tab '+id+', but don\'t have the name');continue;}_L6=_L4.fn?_L4.fn:getFirstName(_L5);}var _L7=_L4.m||0;var _L8=_L4.t||0;this.tabs[id]=new ChatTab(this,id,_L5,_L6,_L7,_L8);this.numTabs++;}if(presence.inVideoChat&&!_L2){_L1=presence.inVideoChatWith;}else if(presence.inPopoutWindow&&!_L1)_L1=_L2;if(_L1&&(_L1!=this.focused))this._focusTab(_L1);},load:function(){this._load(presence.state);},_load:function(_L0){var _L1=false;if(_L0){if(this.blinkingTimer&&_L0.sb)this._stopBlinking();this.chatActivityTime=verifyNumber(_L0.ct)*1000;if(this.useUICookieCache){var now=presence.getTime();this.uiChangeTime=Math.max(this.uiChangeTime,verifyNumber(_L0.uct)*1000);if(!this.loaded)if(now-this.uiChangeTime<this.uiCookieCacheTime){if(now-_L0.ut>60*60*1000)for(var id in _L0.t)_L0.t[id].m=0;presence.debug('chatDisplay: loading tabs from cookie cache');this._loadInitialTabs.bind(this,_L0.t,_L0.f).defer();_L1=true;}}}if(!this.loaded&&!_L1){presence.debug('chatDisplay: loading tabs from server state');this._loadInitialTabs.bind(this,this.initialActiveChats,this.initialFocusedChat).defer();this.initialFocusedChat=this.initialActiveChats=false;}this.loaded=true;},_store:function(_L0){_L0.ct=Math.floor(this.chatActivityTime*.001);_L0.sb=(this.blinkingTimer==null)?1:0;if(this.useUICookieCache){_L0.t={};_L0.f=null;_L0.uct=0;var now=presence.getTime();if(now-this.uiChangeTime<this.uiCookieCacheTime){for(var id in this.tabs){var tab=this.tabs[id];_L0.t[id]={n:tab.name,m:tab.numMissed};if(tab.firstName!=getFirstName(tab.name))_L0.t[id].fn=tab.firstName;}_L0.f=this.focused;_L0.uct=Math.floor(this.uiChangeTime*.001);}}return _L0;},handleResize:function(){if(!this.focused)return;var tab=this.tabs[this.focused];tab.handleResize();},_sendTabStateChange:function(_L0){_L0['window_id']=presence.windowID;new AsyncRequest().setURI(this.settingsURL).setData(_L0).setHandler(this._onCheckTabStateChangeResponse.bind(this)).setErrorHandler(bagofholding).setTransportErrorHandler(bagofholding).send();},_onCheckTabStateChangeResponse:function(_L0){var _L1=_L0.getPayload();if(_L1.overlay)buddyList.addOverlayInfo(_L1.overlay);},reloadTabs:function(){for(var id in this.tabs)this.tabs[id].loadData();},_closeTab:function(id){if(!this.tabs[id])return;if(this.focused==id)if(presence.inPopoutWindow){var _L1=null;var _L2=false;for(var _L3 in this.tabs)if(_L3!=id){_L1=_L3;if(_L2)break;}else if(_L1){break;}else _L2=true;if(_L1){var _L4=this.tabs[_L1];this._focusTab(_L1);}else this.focused=null;}else this.focused=null;this.tabs[id].close();delete this.tabs[id];this.numTabs--;chatTabSlider.close(id);},uiChanged:function(){if(this.useUICookieCache){this.uiChangeTime=presence.getTime();presence.doSync();}},closeTab:function(id){this._closeTab(id);this._sendTabStateChange({'close_chat':id});this.uiChanged();},showVideoChatTab:function(){if(presence.inVideoChat)this.tabs[this.focused].showChat();},_unfocus:function(){if(!this.focused)return false;if(presence.inPopoutWindow)this.tabs[this.focused].deselectPopoutChat();this.tabs[this.focused].unfocus();this.focused=null;return true;},unfocus:function(){var _L0=this._unfocus();if(_L0){this._sendTabStateChange({'unfocus_chat':1});this.uiChanged();}this.lastFocused=null;},unfocusNoSync:function(){this._unfocus();},refocus:function(){if(!this.lastFocused||!this.tabs[this.lastFocused])return null;this._focusTab(this.lastFocused);},_focusTab:function(id,_L1,_L2){if(id==this.focused||presence.inVideoChat&&id!=presence.inVideoChatWith)return;if(!this.tabs[id]){if(typeof _L1=='undefined'){if(!ChatUserInfos[id]||!ChatUserInfos[id].name){presence.warn("chat: couldn't create tab "+id+" since no name is specified");return;}_L1=ChatUserInfos[id].name;_L2=ChatUserInfos[id].firstName;}this.tabs[id]=new ChatTab(this,id,_L1,_L2,0);this.numTabs++;chatTabSlider.addTab(id);}chatTabSlider.gotoTab(id);if(this.focused){this.tabs[this.focused].unfocus();if(presence.inPopoutWindow)this.tabs[this.focused].deselectPopoutChat();}this.focused=id;this.lastFocused=id;if(this.focused){var _L3=this.loaded;(function(){var _L4=!presence.inPopoutWindow&&presence.poppedOut;if(this.tabs[this.focused])this.tabs[this.focused].focus(_L4,_L3);if(presence.inPopoutWindow)this.tabs[id].selectPopoutChat();}).bind(this).defer();}},focusTab:function(id,_L1,_L2){presence.pauseSync();this._focusTab(id,_L1,_L2);this._sendTabStateChange({'focus_chat':id});this.uiChanged();this.chatActivityTime=(new Date()).getTime();this.doStopBlinking();presence.resumeSync();},toggleTab:function(id,_L1,_L2){if(this.focused==id){this.unfocus();}else this.focusTab(id,_L1,_L2);},doBlink:function(){if(!this.favIcon){var _L0=document.getElementsByTagName('link');for(var i=0;i<_L0.length;i++)if(_L0[i].rel=='shortcut icon'){this.favIcon=_L0[i];this.altFavIcon=document.createElement('link');this.altFavIcon.rel='shortcut icon';this.realTitle=document.title;break;}}if(this.favIcon.parentNode){if(this.newMsgNames&&this.newMsgNames.length>0){if(this.newMsgNamesIndex>=this.newMsgNames.length)this.newMsgNamesIndex=0;var _L2=this.newMsgNames[this.newMsgNamesIndex++];document.title=_tx("New message from {name}!",{'name':_L2});}else document.title=_tx("New message!");var p=this.favIcon.parentNode;p.removeChild(this.favIcon);p.appendChild(this.altFavIcon);}else{document.title=this.realTitle;var p=this.altFavIcon.parentNode;p.removeChild(this.altFavIcon);p.appendChild(this.favIcon);}},doStopBlinking:function(_L0){if(this.blinkingTimer||_L0){this._stopBlinking();presence.doSync();}},_stopBlinking:function(){if(this.blinkingTimer){if(this.favIcon&&!this.favIcon.parentNode)this.doBlink();clearInterval(this.blinkingTimer);this.blinkingTimer=null;this.newMsgNames=[];this.newMsgNamesIndex=0;}},_onBuddyAvailability:function(_L0,_L1){this.handleBuddyAvailability(_L1.justCameOnline);},handleBuddyAvailability:function(_L0){for(var id in this.tabs)this.tabs[id].handleBuddyAvailability(_L0);},_handlePresenceMessage:function(_L0,_L1){var obj=_L1.obj;if(obj.window_id==presence.windowID)return;if(obj.from){if(obj.from==this.user){var id=obj.to;}else var id=obj.from;var tab=this.tabs[id];}switch(obj.type){case 'unfocus_chat':if(!presence.inVideoChat)this._unfocus();break;case 'focus_chat':if(!presence.inVideoChat)this._focusTab(obj.id);break;case 'close_chat':if(!presence.inVideoChat)this._closeTab(obj.id);break;case 'msg':case 'video':if(this.inVideoChat&&(obj.from==presence.inVideoChatWith||obj.to==presence.inVideoChatWith))break;if(obj.from==this.user){var _L5=obj.to_name;var _L6=obj.to_first_name?obj.to_first_name:getFirstName(_L5);}else{var _L5=obj.from_name;var _L6=obj.from_first_name?obj.from_first_name:getFirstName(_L5);}this.loadInitialUserInfo(id,_L5,_L6);var _L7=(obj.from==this.user);buddyList.setAvailable(id,_L7);if(!tab){tab=this.tabs[id]=new ChatTab(this,id,_L5,_L6,0);this.numTabs++;chatTabSlider.addTab(id);if(!this.focused){this.focusTab(id);}else tab.getHistory();}if(presence.inPopoutWindow||!presence.poppedOut)if(_L7){this.doStopBlinking(true);}else if(this.isWindowFocused){setTimeout(this.doStopBlinking.bind(this,true),500);}else if(!presence.isOpera){this.newMsgNames.push(tab.firstName);if(!this.blinkingTimer)this.blinkingTimer=setTimeout(function(){this.blinkingTimer=setInterval(this.doBlink.bind(this),this.blinkTime);}.bind(this),this.initialBlinkDelay);}obj.time=obj.msg.time;tab.newMsg(obj);break;case 'typ':if(tab){tab.newTyping(obj);}else presence.debug('typing message ignored');break;default:break;}},handleVisibility:function(){for(var id in this.tabs)this.tabs[id].handleVisibility();},getHistory:function(id,_L1){_L1=_L1||false;if(!this.histories[id]&&_L1)this.histories[id]=[];return this.histories[id];},_renderServerTime12hr:function(_L0){var _L1=new Date();_L1.setTime(_L0+presence.timeSkew);var _L2=_L1.getHours();var _L3='am';if(_L2>=12){_L3='pm';_L2-=12;}if(_L2==0)_L2=12;var _L4=_L1.getMinutes();if(_L4<10)_L4='0'+_L4;var _L5=_L2+':'+_L4+_L3;return _L5;},_renderServerTime24hr:function(_L0){var _L1=new Date();_L1.setTime(_L0+presence.timeSkew);var _L2=_L1.getHours();if(_L2<10)_L2='0'+_L2;var _L3=_L1.getMinutes();if(_L3<10)_L3='0'+_L3;var _L4=_L2+':'+_L3;return _L4;}};function chat_simple_popout(){window.open(presence.popoutURL,"fbChatWindow","status=0,toolbar=0,location=0,menubar=0,"+"directories=0,resizable=1,scrollbars=0,"+"width="+Presence.prototype.defWidth+",height="+Presence.prototype.defHeight+",left="+Presence.prototype.defX+",top="+Presence.prototype.defY);}
function ChatBuddyListTypeahead(obj,_L1,_L2,_L3){this.curStr='';this.clearDiv=null;this.focused=false;this.selected=null;this.selectedIndex=0;this.selectableCount=0;this.minBuddyCount=buddyList.flMode?20:10;this.flid=_L2;this.excludedIds=_L3;this.id=ChatBuddyListTypeahead.numTypeaheads++;this.obj=obj;this.obj.typeahead=this;this.placeholderText=obj.value;this.inputDiv=_L1;this.shouldShowClear=!presence.isSafari2;if(!this.shouldShowClear)obj.onmousedown=this._onmousedown.bind(this);addEventBase(this.obj,'focus',this._onfocus.bind(this));addEventBase(this.obj,'blur',this._onblur.bind(this));addEventBase(this.obj,'keyup',function(e){e=$E(e);var _L5=e?e.keyCode:-1;this._onkeyup.bind(this,_L5).defer();}.bind(this));this.captureSubmit();this.buildIndex();Arbiter.subscribe(ChatBuddyList.AVAILABILITY_CHANGED,this.buildIndex.bind(this));}ChatBuddyListTypeahead.numTypeaheads=0;ChatBuddyListTypeahead.mixin({buildIndex:function(){this.availableListIDs=buddyList.getSortedListUI(this.flid);this.firstLetterIndex={};for(var i=0;i<this.availableListIDs.length;i++){var id=this.availableListIDs[i];var _L2=typeahead_source.tokenize(ChatUserInfos[id].name);for(var _L3=0;_L3<_L2.length;_L3++){if(!this.firstLetterIndex[_L2[_L3][0]])this.firstLetterIndex[_L2[_L3][0]]={};this.firstLetterIndex[_L2[_L3][0]][id]=true;}}this._refreshAvailableList();if(buddyList.availableCount<this.minBuddyCount){hide(this.inputDiv);this.resetSearch(true);}else{show(this.inputDiv);this.search.bind(this,true).defer();}},_onfocus:function(e){this.focused=true;this.captureSubmit();},_onblur:function(e){this.focused=false;if(this.curStr=='')this.hideClear();},_getAvailableListIDs:function(){if(!this.availableIDs)this._refreshAvailableList();return this.availableIDs;},_refreshAvailableList:function(){var ids=this.availableListIDs;if(this.excludedIds)ids=ids.filter((function(id){return this.excludedIds[id]!=1;}).bind(this));this.availableIDs=ids;},_onmousedown:function(){setTimeout(function(){this._onkeyup(0);}.bind(this),100);},_onkeyup:function(_L0){switch(_L0){case KEYS.ESC:if(''==this.curStr){buddyList.closeTab();}else this.resetSearch(true);break;case undefined:case KEYS.LEFT:case KEYS.RIGHT:return false;break;case KEYS.UP:this.upArrowPress();break;case KEYS.DOWN:this.downArrowPress();break;case KEYS.RETURN:this.select();break;case KEYS.BACKSPACE:case 0:default:if(this.search())this.resetSearch(true);break;}},focusInput:function(){if(buddyList.availableCount&&buddyList.availableCount>this.minBuddyCount)this.obj.focus();this.resetSearch();},captureSubmit:function(){if((!this.capturedForm||this.capturedSubstitute!=this.capturedForm.onsubmit)&&this.obj.form){this.capturedForm=this.obj.form;this.captured_event=this.obj.form.onsubmit;this.capturedSubstitute=this.obj.form.onsubmit=function(){return false;}.bind(this.obj.form);}},resetSearch:function(_L0){if(!this.obj)return false;if(!this.obj.value||_L0){this.curStr='';this.obj.value='';this.hideClear();}this.selected=null;this.selectedIndex=-1;this.showAll();this.hideClear();buddyList.unfreezeTabSize();},search:function(_L0){var _L1=this.obj.value;if(_L1==this.placeholderText)return true;var str=typeahead_source.flatten_string(_L1);if(!_L0&&str==this.curStr)return false;this.curStr=str;var _L3=typeahead_source.tokenize(str).sort(typeahead_source._sort);if(!_L3[0])return true;var _L4=this.firstLetterIndex[_L3[0][0]];buddyList.freezeTabSize();this.showClear();buddyList.suppressNonFriendInfoInBuddyList(this.flid);this.getMatchingFriends(_L4,_L3);this.selected=null;this.selectMatchingFriends();return false;},getMatchingFriends:function(_L0,_L1){var _L2=0;var _L3;var _L4=this._getAvailableListIDs();for(var i=0;i<_L4.length;i++){var id=_L4[i];var _L7=ChatUserInfos[id].name;if(_L0!=undefined&&_L0[id]&&typeahead_source.check_match(_L1,_L7)){var _L8=typeahead_source.highlight_found(_L7,this.curStr);buddyList.getBuddyItemName(id,this.flid).setContent(HTML(_L8));buddyList.showBuddyItem(id,false,this.flid);_L2++;if(!_L3)_L3=id;}else{CSS.removeClass(buddyList.getBuddyItem(id,this.flid),'selected');buddyList.hideBuddy(id,this.flid);}}if(_L2>0){buddyList.hideEmptySearch(this.flid);if(_L2==1||(_L1.length==1&&_L1[0].length==1)){this.selected=_L3;this.selectedIndex=0;CSS.addClass(buddyList.getBuddyItem(_L3,this.flid),'selected');}}else buddyList.showEmptySearch(this.flid);},selectMatchingFriends:function(){this.selectableCount=0;var _L0=this._getAvailableListIDs();for(var i=0;i<_L0.length;i++){var id=_L0[i];var _L3=buddyList.getBuddyItem(id,this.flid);if(_L3&&CSS.getStyle(_L3,'display')!='none'){if(this.selectedIndex==this.selectableCount){this.selected=id;CSS.addClass(_L3,'selected');Vector2.scrollIntoView(_L3);}else CSS.removeClass(_L3,'selected');this.selectableCount++;}}},downArrowPress:function(){this.selectedIndex++;var max=this.selectableCount-1;if(this.selectedIndex>max)this.resetSearch();this.selectMatchingFriends();},upArrowPress:function(){this.selectedIndex--;if(this.selectedIndex<0)this.selectedIndex=0;this.selectMatchingFriends();},showAll:function(){this.obj.value='';buddyList.hideEmptySearch(this.flid);var _L0=this._getAvailableListIDs();for(var i=0;i<_L0.length;i++){var id=_L0[i];var _L3=buddyList.getBuddyItem(id,this.flid);if(_L3){buddyList.updateBuddyItemName(id,this.flid);CSS.removeClass(buddyList.getBuddyItem(id,this.flid),'selected');buddyList.showBuddyItem(id,true,this.flid);}}buddyList.unsuppressNonFriendInfoInBuddyList(this.flid);},showClear:function(){if(this.clearDiv==null&&this.shouldShowClear){this.clearDiv=document.createElement('div');this.clearDiv.setAttribute('id','clear_search'+this.id);DOM.setContent(this.clearDiv,HTML('<a href="#" class="hide"></a>'));var _L0=DOM.find(this.clearDiv,'a');_L0.listen('click',(function(){this.resetSearch(true);return false;}).bind(this));this.inputDiv.appendChild(this.clearDiv);}},hideClear:function(){if(ge('clear_search'+this.id)){this.clearDiv=null;this.inputDiv.removeChild(ge('clear_search'+this.id));}},select:function(){if(this.selected!=null){CSS.removeClass(buddyList.getBuddyItemName(this.selected,this.flid),'selected');buddyList.itemOnClick(this.selected,this.flid);this.resetSearch(true);}}});
function PresenceUpdater(){this.timerGranularity=presence.sitevars.UPDATE_GRANULARITY?presence.sitevars.UPDATE_GRANULARITY*1000:60000;this._init();}PresenceUpdater.prototype={_init:function(){this.handlers=[];this.updatePaused=0;this.updateNumber=0;this._runTimer();bind(Arbiter,Arbiter.inform,PresenceMessage.PRESENCE_UPDATER_READY,true,Arbiter.BEHAVIOR_STATE).defer();},register:function(_L0,_L1,_L2,_L3,_L4){this.handlers.push({'asyncParam':_L0,'checkCB':_L1,'responseCB':_L2,'errorCB':_L3,'transportErrorCB':_L4});},_runTimer:function(){clearTimeout(this.timer);this.timer=setTimeout(this.checkForUpdate.bind(this,false,[],false),this.timerGranularity);},forceUpdate:function(_L0){if(this.updatePaused)return;if(_L0!==undefined&&_L0.length>0){this.checkForUpdate(false,_L0,false);}else this.checkForUpdate(true,[],false);},pauseUpdate:function(){this.updatePaused++;},resumeUpdate:function(_L0){this.updatePaused--;this.forceUpdate(_L0);},checkForUpdate:function(_L0,_L1,_L2){if(!_L2)clearTimeout(this.timer);if(presence.isShutdown){if(!_L2)this._runTimer();return;}var _L3=presence.getTime();var _L4=[];var _L5={user:presence.user};for(var i=0;i<this.handlers.length;i++){var _L7=this.handlers[i];var _L8=_L0||(_L1.indexOf(_L7.asyncParam)!=-1);var _L9=_L7.checkCB(_L3,_L5,_L8);if(_L9){_L5[_L7.asyncParam]=1;_L4.push(_L7);}}if(_L4.length>0){this._sendUpdate(_L5,_L4,_L2);}else if(!_L2)this._runTimer();},runHandler:function(_L0){this.checkForUpdate(false,[_L0],true);},_initialHandler:function(_L0,_L1){if(_L0!=this.updateNumber)return false;},_onResponse:function(_L0,_L1,_L2){var _L3=_L2.getPayload();presence.updateServerTime(_L3.time);var _L4=presence.getTime();for(var i=0;i<_L0.length;i++){var _L6=_L0[i];var _L7=_L3[_L6.asyncParam];if(typeof _L7=='undefined'||!_L7){_L6.errorCB(_L2);}else _L6.responseCB(_L7,_L4);}presenceCookieManager.store();if(!_L1)this._runTimer();},_onError:function(_L0,_L1){for(var i=0;i<_L0.length;i++)_L0[i].errorCB(_L1);this._runTimer();},_onTransportError:function(_L0,_L1){for(var i=0;i<_L0.length;i++)_L0[i].transportErrorCB(_L1);this._runTimer();},_sendUpdate:function(_L0,_L1,_L2){this.updateNumber++;var uri=_L0['notifications']?'/ajax/presence/update.php':'/ajax/chat/buddy_list.php';var _L4=URI.getRequestURI().getQueryData();var _L5={};for(key in _L4)if(key.indexOf('buddy')==0)_L5[key]=_L4[key];if(_L5)uri=new URI(uri).setQueryData(_L5);this.async=new AsyncRequest().setInitialHandler(this._initialHandler.bind(this,this.updateNumber)).setHandler(this._onResponse.bind(this,_L1,_L2)).setErrorHandler(this._onError.bind(this,_L1)).setTransportErrorHandler(this._onTransportError.bind(this,_L1)).setOption('suppressErrorAlerts',true).setData(_L0).setURI(uri).send();}};
function ChatBuddyList(){this.user=presence.user;this.shouldRender=true;this.haveFullList=false;this.errorMode=false;this.shouldShowLoading=false;this.availableCount=0;this.availableList={};this.sortedList=[];this.listChanged=false;this.updateTime=0;this.flMode=false;this.flData={};this.otherFriendsFlid='-1';this.botsFlid='-2';this.stopUpdates=false;this.flSortableGroup=null;this.reorderingLists=false;this.sortables={};this.flOpts={};this.externalFlids=[];this.updateOverlay={};this.visibilityRatio={};this.justCameOnline=false;this.maxNameLen=20;this.backgroundColor='#fff';}copy_properties(ChatBuddyList,{OVERLAY_ONLINE:0,OVERLAY_IDLE:1,OVERLAY_OFFLINE:-1,DEFAULT_OPTS:{fullDisplay:true,excludeIds:{}},BUDDY_LIST_INITIALIZED:'buddylist/initialized',BUDDY_CLICKED:'buddylist/buddy_clicked',AVAILABILITY_CHANGED:'buddylist/availability-changed',UPDATER_NAME:'buddy_list'});ChatBuddyList.prototype={maxItemsToAnimate:10,highlightColor:'#fffbe2',expandAnimDuration:400,compactItemHeight:20,fullItemHeight:26,initError:function(){this.errorMode=true;this._init();},initNoRender:function(_L0,_L1,_L2,_L3,_L4,_L5,_L6){this.shouldRender=false;this.shouldShowLoading=true;this.availableCount=_L0;this.availableList=_L1;this.updateTime=_L2;this.listChanged=_L3;this.updateOverlay=_L6;this.flMode=_L4;this.flData=_L5;this._init();if(presence.inPopoutWindow)this._forceUpdate.bind(this,false).defer();},initFullList:function(_L0,_L1,_L2,_L3,_L4,_L5){this.availableList=_L0;this.updateTime=_L1;this.listChanged=_L2;this.haveFullList=true;this.flMode=_L3;this.flData=_L4;this.updateOverlay=_L5;this.availableCount=count(this.availableList);this._init();},_init:function(){this.loaded=false;this.poppedOut=presence.poppedOut;this.buddyListOpen=false;this.updateDiff=0;this.rendered=false;this.showingError=false;this.numRequestFailures=0;for(var id in this.availableList)this.availableList[id].i=this.availableList[id].i?1:0;this.tabID='buddy_list_tab';this.wrapperID='buddy_list';this.contentID='buddy_list_content';this.tabDiv=ge(this.tabID);this.wrapperDiv=ge(this.wrapperID);this.contentDiv=ge(this.contentID);this.buddyListError=ge('buddy_list_error');this.buddyCountSpan=ge('buddy_count');presenceUpdater.register(ChatBuddyList.UPDATER_NAME,this._checkUpdater.bind(this),this._onUpdaterResponse.bind(this),this._onUpdaterError.bind(this),this._onUpdaterError.bind(this));presenceCookieManager.register('bl',this._getCookieData.bind(this));presence.registerStateStorer(this._storeState.bind(this));presence.registerStateLoader(this._loadState.bind(this));Arbiter.subscribe(PresenceMessage.getArbiterMessageType('fl_settings'),this._handleFLMessage.bind(this));Arbiter.subscribe(ChatOptions.VISIBILITY_CHANGED,this._handleVisibility.bind(this));this.setCompactDisplay(chatOptions.getSetting('compact_buddylist'));this._loadState(presence.state);this._postInit.bind(this).defer();Arbiter.subscribe(Arbiter.LIST_EDITOR_LISTS_CHANGED,this._flManagerHandler.bind(this));},_postInit:function(){if(presence.inPopoutWindow)this._firstRender();if(chatOptions.visibility)this._updateCount();this.updateDiff=this._computeUpdateTimeDiff();this._mergeOverlay();Arbiter.inform(ChatBuddyList.BUDDY_LIST_INITIALIZED,{},Arbiter.BEHAVIOR_PERSISTENT);},_storeState:function(_L0){_L0.blo=this.buddyListOpen?1:0;_L0.bvt=parseInt(this.buddyViewTime*.001);return _L0;},_loadState:function(_L0){this.buddyViewTime=verifyNumber(_L0.bvt)*1000;var _L1=!!_L0.blo;if(!presence.poppedOut&&this.poppedOut){this._showLoading();this._forceUpdate(false);}this.poppedOut=presence.poppedOut;var fn=null;if(!this.poppedOut)if(_L1){fn=this.openTab.bind(this);}else fn=this.closeTab.bind(this);if(fn)if(this.loaded){fn();}else fn.defer();this.loaded=true;},setCompactDisplay:function(_L0){this.isCompactDisplay=_L0;if(this.isCompactDisplay){this.itemHeight=this.compactItemHeight;}else this.itemHeight=this.fullItemHeight;if(this.rendered)this._render();},_handleVisibility:function(){if(chatOptions.visibility){this._showLoading();this._show();this._forceUpdate(true);this.justCameOnline=true;}else this._hide();},_handleFLMessage:function(_L0,_L1){var obj=_L1.obj;this.setVisibilityRatio({});if(!this._flChanged(obj.fl_mode,obj.fl_data))return;this._onFlChange(obj.fl_mode,obj.fl_data);},_flChanged:function(_L0,_L1){return (_L0!=this.flMode||!are_equal(_L1,this.flData));},_massageNowAvailableList:function(_L0,_L1,_L2){for(var id in _L0){var _L4=_L0[id];if(_L1!=this.flMode){if(_L1){delete _L4.fl;}else _L4['fl']=[this.otherFriendsFlid];}else{var _L5=_L4.fl||[];for(var i=0;i<_L5.length;i++){var _L7=_L5[i];if(typeof this.flData[_L7]=='undefined')_L4.fl.remove(_L7);}if(_L4.fl&&_L4.fl.length==0)_L4.fl=[this.otherFriendsFlid];}_L0[id]=_L4;}return _L0;},_onFlChange:function(_L0,_L1){if(!this.rendered){this.flMode=_L0;this.flData=_L1;return;}var _L2=[];var _L3=[];var _L4=[];var _L5=[];if(this.flMode&&this.flMode==_L0){var _L6=this._groupAvailableListByFl(true);for(var _L7 in _L1)if(typeof this.flData[_L7]=='undefined'){if(_L1[_L7].h)continue;_L2.push(_L7);_L4.push(_L7);}else if(this.flData[_L7].h!=_L1[_L7].h){if(_L1[_L7].h){_L3.push(_L7);}else{_L2.push(_L7);if(_L1[_L7].o)_L4.push(_L7);}}else if(this.flData[_L7].o!=_L1[_L7].o)if(_L1[_L7].o){_L4.push(_L7);}else _L5.push(_L7);for(var _L7 in this.flData)if(typeof _L1[_L7]=='undefined')_L3.push(_L7);this.flMode=_L0;if(_L3.length!=0)this._removeFlidsFromBuddyList(_L3,_L6);if(_L5.length!=0)this._goOfflineToLists(_L5,true);this.flData=_L1;if(_L2.length!=0)this._addFlidsToDOM(_L2,_L6);if(_L4.length!=0)this._goOnlineToLists(_L4,true);}else if(this.flMode&&this.flMode!=_L0){var _L6=this._groupAvailableListByFl(true);_L3=keys(this.flData);this.flMode=_L0;this.flData=_L1;this._addFlidsToDOM([null]);this._removeFlidsFromBuddyList(_L3,_L6);this._forceUpdate(false);}else{for(var _L7 in _L1){if(_L1[_L7].h)continue;_L2.push(_L7);if(_L1[_L7].o)_L4.push(_L7);}this.flMode=_L0;this.flData=_L1;this._removeFlidsFromDOM([null]);if(_L2.length>0)this._addFlidsToDOM(_L2);if(_L4.length>0)this._goOnlineToLists.bind(this,_L4,true).defer();}},_addFlidsToDOM:function(_L0,_L1){_L1=_L1||this._groupAvailableListByFl(true);var _L2=this._getRenderedFriendLists();var _L3=_L2[0];var _L4=$('buddy_list_parent');for(var i=0;i<_L0.length;i++){var _L6=_L0[i];if(this.flMode&&_L6){var _L7=DOM.create('div',{'id':this._getFriendListId(_L6),'className':this._getFriendListItemClasses(_L6,_L1)});DOM.setContent(_L7,HTML(this._renderFriendListHeader(_L6)));DOM.appendContent(_L7,HTML(this._renderFriendListContent(_L6,[])));if(_L3==_L6){_L4.prependContent(_L7);}else{var _L8=_L2.indexOf(_L6);var _L9=_L2[_L8-1];DOM.insertAfter(ge(this._getFriendListId(_L9)),_L7);}this._addFlSortable(_L6);this._initFlidSortable(_L6,[]);}else _L4.prependContent(HTML(this._renderFriendListContent(null,[])));}this._addFriendListListeners(_L0);},_removeFlidsFromDOM:function(_L0){for(var i=0;i<_L0.length;i++){var _L2=_L0[i];if(_L2){if(ge(this._getFriendListId(_L2))){DOM.remove($(this._getFriendListId(_L2)));this._removeFlSortable(_L2);this._destroyFlidSortable(_L2);}}else{DOM.remove($(this._getAvailableMarkerId(_L2)));DOM.remove($(this._getIdleMarkerId(_L2)));}}},loadTypeahead:function(){this.typeahead=new ChatBuddyListTypeahead($("buddy_list_typeahead_input"),$("buddy_list_typeahead"));},getContentWrapper:function(){return this.contentDiv.parentNode;},resizeTab:function(_L0){if(this.resizeFrozen)if(_L0){this.resizeFrozen=false;}else return;presence.tabContentResize(this.wrapperID,this.contentID);},freezeTabSize:function(_L0){if(this.resizeFrozen||this.showingError)return;this.resizeFrozen=true;if(_L0===undefined)_L0=true;presence.tabContentResize(this.wrapperID,this.contentID,_L0);},unfreezeTabSize:function(){if(!this.resizeFrozen)return;this.resizeFrozen=false;this.resizeTab();presence.contentChanged(this.contentID);},_hide:function(){if(!presence.inPopoutWindow){CSS.addClass(presence.holder,'buddy_list_hidden');this.closeTab();DOM.setContent(this.buddyCountSpan,_tx("Chat (Offline)"));}},_show:function(){if(presence.inPopoutWindow){CSS.removeClass(presence.popoutSidebar,'buddy_list_hidden');}else{CSS.removeClass(presence.holder,'buddy_list_hidden');this.openTab();this._updateCount();}},toggleTab:function(){if(!this.buddyListOpen){this.openTab(true);}else this.closeTab();},_goOnline:function(){chatOptions.sendVisibility(true);},openTab:function(_L0){if(this.buddyListOpen)return;if(CSS.hasClass(presence.holder,'buddy_list_hidden')){this._goOnline();return;}if(!this.rendered){var _L1=this.availableList;this.availableList={};this.shouldShowLoading=true;this._firstRender();presence.openTab(this.wrapperID,this.tabID);this.availableList=_L1;if(this.haveFullList){this._render.bind(this).defer();setTimeout(this._availableListChanged.bind(this,true),10);}}else presence.openTab(this.wrapperID,this.tabID,this.contentID);this.buddyListOpen=true;setTimeout(this._openTabPostProcess.bind(this,_L0),50);},_openTabPostProcess:function(_L0){this.buddyViewTime=(new Date()).getTime();var _L1=(presence.getTime()-this.updateTime)*.001;if(this.showingError||_L1>presence.sitevars.BUDDY_VIEW_FETCH_WINDOW)this._forceUpdate(false);presence.doSync();if(_L0&&this.typeahead)this.typeahead.focusInput();},closeTab:function(){if(!this.buddyListOpen)return;this.buddyListOpen=false;presence.toggleTab(this.wrapperID,this.tabID,this.contentID);if(chatOptions.visibility)setTimeout(this._closeTabPostProcess.bind(this),50);buddyListDisplay.closeOpenFlyout();this.exitReorderingFlMode();},_closeTabPostProcess:function(){if(this.typeahead)this.typeahead.resetSearch(true);this.buddyViewTime=(new Date()).getTime();presence.doSync();},_mergeOverlay:function(){if(!this.haveFullList)return;var _L0=presence.getTime();var _L1={};var _L2=[];for(var id in this.updateOverlay)if(_L0<this.updateOverlay[id].exp){var _L4=this.availableList[id];if(!ChatUserInfos[id])continue;if(this.updateOverlay[id].ol!=ChatBuddyList.OVERLAY_OFFLINE){if(!_L4){_L4={i:0};if(this.flMode)_L4.fl=[this.otherFriendsFlid];_L1[id]=_L4;}else ;}else _L2.push(id);}else delete this.updateOverlay[id];if(!is_empty(_L1)||!is_empty(_L2))this._updateAvailableListWithDiff(_L1,_L2);},getAvailability:function(id){if(id==this.user)return chatOptions.visibility;if(typeof this.availableList[id]!='undefined'){return this.availableList[id];}else return null;},setAvailable:function(id,_L1){this._manageOverlay(id,ChatBuddyList.OVERLAY_ONLINE);this._addToBuddyList([id],_L1);},_addToBuddyList:function(ids,_L1){var _L2={};var _L3=[];for(var i=0;i<ids.length;i++){var id=ids[i];var _L6=this.getAvailability(id);if(_L6&&(_L6.i==0||_L1))continue;_L2[id]={i:0};if(this.flMode)if(this.availableList[id]&&this.availableList[id].fl){_L2[id]['fl']=this.availableList[id].fl;}else _L2[id]['fl']=[this.otherFriendsFlid];if(_L6&&_L6.i==1)_L3.push(id);}this._updateAvailableListWithDiff(_L2,_L3);},setFlids:function(id,_L1){if(!this.getAvailability(id))return;if(this.availableList[id].fl[0]==this.otherFriendsFlid){var _L2={};_L2[id]=this.availableList[id];_L2[id]['fl']=_L1;this._updateAvailableListWithDiff(_L2,[],this.otherFriendsFlid);}},setUnavailable:function(id){this._manageOverlay(id,ChatBuddyList.OVERLAY_OFFLINE);this._removeFromBuddyList([id]);},_removeFromBuddyList:function(ids,_L1){var _L2=[];for(var i=0;i<ids.length;i++){var id=ids[i];if(!this.getAvailability(id))continue;_L2.push(id);}if(_L2.length>0)this._updateAvailableListWithDiff({},_L2,_L1);},addOverlayInfo:function(_L0){for(var id in _L0)this._manageOverlay(id,_L0[id].ol);this._mergeOverlay();},_manageOverlay:function(id,_L1){var exp=presence.getTime()+60000;this.updateOverlay[id]={'ol':_L1,'exp':exp};if(this.rendered)presenceCookieManager.store();},hideBuddy:function(id,_L1){var _L2;if(_L1){_L2=[_L1];}else _L2=this._getUserFlids(id,null,true);this._toggleBuddy(id,false,_L2);},_toggleBuddy:function(id,_L1,_L2){var _L3=_L1?'block':'none';var _L4,_L5;for(var i=0;i<_L2.length;i++){var _L7=_L2[i];_L4=ge(this._getBuddyListItemId(id,_L7));if(_L4)_L4.style.display=_L3;if(_L1&&(_L5=ge(this._getFriendListId(_L7))))CSS.removeClass(_L5,'suppress');}},showBuddyItem:function(id,_L1,_L2){_L1=_L1||false;var _L3;if(_L2){_L3=[_L2];}else{var _L3=this._getUserFlids(id,null,true);if(_L3.length>1&&!_L1){var _L4=_L3.slice(1);this._toggleBuddy(id,false,_L4);_L3=[_L3[0]];}}this._toggleBuddy(id,true,_L3);},getBuddyItem:function(id,_L1){_L1=this._getUserFlid(id,_L1);return ge(this._getBuddyListItemId(id,_L1));},getBuddyItemName:function(id,_L1){_L1=this._getUserFlid(id,_L1);return ge(this._getBuddyListItemNameId(id,_L1));},updateBuddyItemName:function(id,_L1){var _L2=ChatUserInfos[id];var _L3=_L2.name;var _L4;if(_L3.length>this.maxNameLen){_L4=_L3.substring(0,this.maxNameLen-2)+'...';}else _L4=_L3;this.getBuddyItemName(id,_L1).innerHTML=_L4;},_getUserFlid:function(id,_L1){if(_L1===null||_L1===undefined){var _L2=this._getUserFlids(id);_L1=_L2[0];}return _L1;},showEmptySearch:function(_L0){show(this._getEmptySearchId(_L0));},hideEmptySearch:function(_L0){hide(this._getEmptySearchId(_L0));},_getSortedList:function(){if(this.sortedList.length==0&&count(this.availableList)==this.availableCount){this._pruneUsersWithoutDisplayInfo(this.availableList);this.sortedList=this._sort(keys(this.availableList));}return this.sortedList;},_pruneUsersWithoutDisplayInfo:function(_L0){for(var id in _L0)if(!ChatUserInfos[id]){Util.log("pruned user "+id+" without display info");delete _L0[id];}},getSortedListUI:function(_L0){if(!_L0&&this.flMode){var _L1=this._groupAvailableListByFl(true);var _L2=[];for(var _L0 in _L1)_L2=_L2.concat(_L1[_L0]);return unique(_L2);}return this._getSortedList();},getFriendLists:function(){var res={};copy_properties(res,this.flData);delete res[this.otherFriendsFlid];delete res[this.botsFlid];return res;},_getRenderedFriendLists:function(){var _L0=[];for(var _L1 in this.flData)if(!this.flData[_L1].h)_L0.push(_L1);return _L0;},_getFriendListsInChat:function(){var _L0=this._getRenderedFriendLists();_L0.remove(this.otherFriendsFlid);_L0.remove(this.botsFlid);return _L0;},suppressNonFriendInfoInBuddyList:function(_L0){this._updateNonFriendInfoInBuddyList(_L0,true);},unsuppressNonFriendInfoInBuddyList:function(_L0){this._updateNonFriendInfoInBuddyList(_L0,false);},_updateNonFriendInfoInBuddyList:function(_L0,_L1){var _L2=_L0?[_L0]:this._getGlobalFlids(true);var _L3,_L4;for(var i=0;i<_L2.length;i++){var _L0=_L2[i];if(_L3=ge(this._getIdleMarkerId(_L0)))CSS.conditionClass(_L3,'suppress',_L1);if(_L0&&(_L4=ge(this._getFriendListId(_L0))))CSS.conditionClass(_L4,'suppress',_L1);}},_updateCount:function(){if(this.buddyCountSpan&&!presence.inPopoutWindow){var _L0=_tx("{Chat} {number-available}",{'Chat':_tx("Chat"),'number-available':'<span class="buddy_count_num">(<strong>'+this.availableCount+'</strong>)</span>'});this.buddyCountSpan.innerHTML=_L0;}},setVisibilityRatio:function(cvr){this.visibilityRatio=cvr;presence.doSync();},_getCookieData:function(){var _L0={};for(var id in chatDisplay.tabs)if(this.availableList[id])_L0[id]=this.availableList[id];var _L2={'ac':this.availableCount,'ut':parseInt(this.updateTime*.001),'ud':parseInt(this.updateDiff),'lc':this.listChanged?1:0,'cvr':this.visibilityRatio};if(!is_empty(this.updateOverlay))_L2.uo=this.updateOverlay;if(!is_empty(_L0))_L2.al=_L0;return _L2;},_computeUpdateTimeDiff:function(){if(!chatOptions.visibility||(presence.poppedOut&&!presence.inPopoutWindow))return Math.round(presence.sitevars.BUDDY_MAX_TIME);var _L0=presence.sitevars.BUDDY_BASE_TIME;var now=presence.getTime();if(!chatDisplay.everSentMessage)_L0+=presence.sitevars.BUDDY_COST_NEVER_SENT_MESSAGE;if(!this.listChanged)_L0+=presence.sitevars.BUDDY_COST_NO_LIST_CHANGE;if(chatTabSlider.numTabs==0)_L0+=presence.sitevars.BUDDY_COST_NO_CHAT_TABS;var _L2=(now-chatDisplay.chatActivityTime)/60000;if(_L2>presence.sitevars.BUDDY_MAX_ACTIVITY_MINS)_L2=presence.sitevars.BUDDY_MAX_ACTIVITY_MINS;_L0+=(presence.sitevars.BUDDY_COST_CHAT_ACTIVITY/presence.sitevars.BUDDY_MAX_ACTIVITY_MINS)*_L2;if(!presence.poppedOut){var _L3=(now-presence.pageLoadTime)/60000;if(_L3<_L2){if(_L3>presence.BUDDY_MAX_ACTIVITY_MINS)_L3=presence.BUDDY_MAX_ACTIVITY_MINS;_L0+=(presence.sitevars.BUDDY_COST_PAGE_ACTIVITY/presence.sitevars.BUDDY_MAX_ACTIVITY_MINS)*_L3;}if(!this.buddyListOpen){var _L4=(now-this.buddyViewTime)/60000;if(_L4>presence.sitevars.BUDDY_MAX_ACTIVITY_MINS)_L4=presence.sitevars.BUDDY_MAX_ACTIVITY_MINS;_L0+=(presence.sitevars.BUDDY_COST_VIEW_ACTIVITY/presence.sitevars.BUDDY_MAX_ACTIVITY_MINS)*_L4;}}if(!_L0||_L0>presence.sitevars.BUDDY_MAX_TIME)_L0=presence.sitevars.BUDDY_MAX_TIME;return Math.round(_L0);},_checkUpdater:function(_L0,_L1,_L2){this.updateDiff=this._computeUpdateTimeDiff();if(_L2||(chatOptions.visibility&&!this.stopUpdates&&(_L0-this.updateTime)>this.updateDiff*1000)){_L1.popped_out=presence.poppedOut;_L1.available_list=this.haveFullList?this.availableList:{};_L1.force_render=this.shouldRender;return true;}},_forceUpdate:function(_L0){this.shouldRender=true;var _L1=_L0?undefined:[ChatBuddyList.UPDATER_NAME];presenceUpdater.forceUpdate(_L1);},updateUserInfos:function(_L0){copy_properties(ChatUserInfos,_L0);},_collapseItem:function(id,_L1,_L2,_L3){if(this.flMode&&_L3){var _L4=[_L3];}else var _L4=this._getUserFlids(id,_L1);for(var i=0;i<_L4.length;i++){var _L3=_L4[i];var _L6=ge(this._getBuddyListItemId(id,_L3));if(_L6){_L6.id=this._getBuddyListWasItemId(id,_L3);if(_L2)animation(_L6).to('height','0px').duration(this.expandAnimDuration).go();this._removeSortable(id,_L4[i]);}}},_expandItem:function(id,_L1,_L2,_L3,_L4,_L5,_L6){var _L7=ge(this._getBuddyListItemId(id,_L1));if(!_L7){var _L7=HTML(this._renderItem(id,_L1,_L3)).getRootNode();}else if(_L3)CSS.addClass(_L7,'idle');var _L8=(this.isCompactDisplay?this.compactItemHeight:this.itemHeight);var _L9=this._getFlOpts(_L1);if(!_L9.fullDisplay)_L8=this.compactItemHeight;if(!_L4){_L7.style.height=_L8+'px';DOM.insertAfter(_L2,_L7);}else{_L7.style.height='0px';DOM.insertAfter(_L2,_L7);var _La=animation(_L7);if(_L5)_La.duration(this.expandAnimDuration+500).checkpoint();_La.from('height','0').to('height',_L8+'px').duration(this.expandAnimDuration);if(_L6===undefined)_L6=!_L3;if(_L6){_L7.style.backgroundColor=this.highlightColor;_La.checkpoint().duration(3000).checkpoint().to('backgroundColor',this.backgroundColor).duration(500);}_La.go();}this._addSortable(id,_L1);return _L7;},_clearWasAvailableItems:function(_L0,_L1,_L2){if(!this.rendered)return;for(var i=0;i<_L0.length;i++){var id=_L0[i];if(_L1[id]){if(this.flMode&&_L2){var _L5=[_L2];}else var _L5=this._getUserFlids(id,_L1[id]);for(var j=0;j<_L5.length;j++){var _L7=ge(this._getBuddyListWasItemId(id,_L5[j]));if(_L7){DOM.remove(_L7);delete _L7;}}}}this._showBuddyListEmptyItem();},_showBuddyListEmptyItem:function(){var _L0=ge(this._getBuddyListEmptyItemId());if(_L0)CSS.conditionClass(_L0,'hide_empty_item',this.availableCount!=0);},_hideBuddyListEmptyItem:function(){var _L0=ge(this._getBuddyListEmptyItemId());if(_L0)CSS.addClass(_L0,'hide_empty_item');},_updateAvailableListWithDiff:function(_L0,_L1,_L2){if(this.stopUpdates)return;var id,_L4;var _L5=false;var _L6={};var _L7={};var _L8=(_L2!=null);this._pruneUsersWithoutDisplayInfo(_L0);for(var i=0;i<_L1.length;i++){var uid=_L1[i];if(this.availableList[uid]){_L5=true;_L6[_L1[i]]=this.availableList[uid];if(_L2&&this.flMode&&this.availableList[uid].fl.length>1){this.availableList[uid].fl.remove(_L2);_L7[uid]=1;continue;}delete this.availableList[uid];}}this._hideBuddyListEmptyItem();var _Lb=keys(_L0);var _Lc=!_L2&&!this.showingError&&!presence.isSafari2&&(_L1.length+_Lb.length<this.maxItemsToAnimate);if(this.rendered){for(var i=0;i<_L1.length;i++)if(_L6[_L1[i]])this._collapseItem(_L1[i],_L6[_L1[i]],_Lc,_L2);var _Ld=_Lc?this.expandAnimDuration:0;setTimeout(this._clearWasAvailableItems.bind(this,_L1,_L6,_L2),_Ld);}var _Le=this.sortedList;if(this.haveFullList)this.sortedList=[];this._sort(_Lb,_L0);var _Lf=_Lb.shift();var _L10=_Le.shift();var _L11=this._compareFunction.bind(this,null);var _L12={},_L13={},_L14={},_L15={},_L16={};var _L17=[];if(this.shouldRender){_L17=this._getGlobalFlids();for(var i=0;i<_L17.length;i++){var _L2=_L17[i];_L12[_L2]=_L14[_L2]=this._getAvailableMarkerId(_L2);_L13[_L2]=this._getIdleMarkerId(_L2);_L15[_L2]=_L16[_L2]=false;}}var _L18=false;var _L19=function(id,_L2,_L4){var _L22=this._getBuddyListItemId(id,_L2);if(_L4){_L13[_L2]=_L22;}else _L14[_L2]=_L22;_L15[_L2]=_L15[_L2]||_L4;_L16[_L2]=_L16[_L2]||!_L4;};var _L1a=_L19.bind(this);while(true){if(_L10&&_L6[_L10]&&!_L7[_L10]){_L10=_Le.shift();continue;}if(_L10&&_Lf){if(_L10==_Lf){_L10=_Le.shift();continue;}if(_L11(_L10,_Lf,this.availableList[_L10].i,_L0[_Lf].i)<0){id=_L10;}else id=_Lf;}else if(_L10){id=_L10;}else if(_Lf){id=_Lf;}else break;if(id==_L10){_L10=_Le.shift();_L4=this.availableList[id].i;if(this.shouldRender){var _L1b=this._getUserFlids(id);for(var i=0;i<_L1b.length;i++)_L1a(id,_L1b[i],_L4);}}else{_Lf=_Lb.shift();if(this.shouldRender&&this.availableList[id]){var _L1c=this._getUserFlids(id,this.availableList[id],_L8);for(var i=0;i<_L1c.length;i++){var _L2=_L1c[i];var elem=ge(this._getBuddyListItemId(id,_L2));if(elem){this._removeSortable(id,_L2);DOM.remove(elem);}}}this.availableList[id]=_L0[id];if(this.shouldRender){_L4=_L0[id].i;var _L1b=this._getUserFlids(id,null,_L8);for(var i=0;i<_L1b.length;i++){var _L2=_L1b[i];var _L1e=_L4?ge(_L13[_L2]):ge(_L14[_L2]);if(!_L1e)_L1e=ge(_L12[_L2]);this._expandItem(id,_L2,_L1e,_L4,_Lc,_L5);_L18=true;_L1a(id,_L2,_L4);}}}if(this.haveFullList)this.sortedList.push(id);}if(this.shouldRender){for(var i=0;i<_L17.length;i++){var _L2=_L17[i];var _L1f=ge(this._getIdleMarkerId(_L2));if(_L1f)if(_L15[_L2]&&_L16[_L2]){CSS.removeClass(_L1f,'hide_idle_marker');}else CSS.addClass(_L1f,'hide_idle_marker');}var _L20=0;if(_Lc){var _L21=_L18;if(_L21)_L20+=this.expandAnimDuration;if(_L5){_L20+=this.expandAnimDuration;if(_L21)_L20+=500;}}setTimeout(this.resizeTab.bind(this),_L20);this._resetFlidClasses();}this._availableListChanged(_L18);},_sort:function(ids,_L1){_L1=_L1||this.availableList;var _L2=this._compareFunction.bind(this,_L1);ids.sort(_L2);return ids;},_compareFunction:function(_L0,id1,id2,_L3,_L4){if(typeof _L3=='undefined')_L3=_L0[id1].i;if(typeof _L4=='undefined')_L4=_L0[id2].i;if(_L3^_L4)return _L3?1:-1;var _L5=ChatUserInfos[id1].name.toLowerCase();var _L6=ChatUserInfos[id2].name.toLowerCase();return (_L5<_L6)?-1:1;},_availableListChanged:function(_L0){if(this.haveFullList)this.availableCount=count(this.availableList);for(var id in this.availableList)this.availableList[id].i=this.availableList[id].i?1:0;if(this.rendered)presenceCookieManager.store();presence.contentChanged(this.contentID);if(!_L0)this.resizeTab();this._updateCount();Arbiter.inform(ChatBuddyList.AVAILABILITY_CHANGED,{sender:this,justCameOnline:this.justCameOnline});this.justCameOnline=false;},_onUpdaterResponse:function(_L0,_L1){if(this.shouldRender&&!_L0.forcedRender)return;this.updateTime=_L1;if(!chatOptions.visibility||this.stopUpdates)return;var _L2=this.haveFullList;var _L3=this._flChanged(_L0.flMode,_L0.flData);var _L4=is_empty(_L0.nowAvailableList);this.numRequestFailures=0;this.errorMode=false;this._hideError();this.listChanged=_L0.listChanged;this.updateUserInfos(_L0.userInfos);if((_L2&&_L3)||_L4){}else{this.flMode=_L0.flMode;this.flData=_L0.flData;}if(this.shouldRender){this.haveFullList=true;if(!this.rendered)this._firstRender();}else{this.availableCount=_L0.availableCount;this._updateCount();}if(!_L2||_L0.wasAvailableIDs.length||!_L4){for(var id in this.updateOverlay)if(_L1<this.updateOverlay[id].exp){if(_L2||!this.availableList[id]){delete _L0.nowAvailableList[id];}else _L0.nowAvailableList[id]=this.availableList[id];for(var i=0;i<_L0.wasAvailableIDs.length;i++)if(id==_L0.wasAvailableIDs[i]){_L0.wasAvailableIDs.splice(i,1);break;}}else delete this.updateOverlay[id];if(_L2){if(_L3&&!_L4)_L0.nowAvailableList=this._massageNowAvailableList(_L0.nowAvailableList,_L0.flMode,_L0.flData);this._updateAvailableListWithDiff(_L0.nowAvailableList,_L0.wasAvailableIDs);if(_L3)this._onFlChange(_L0.flMode,_L0.flData);}else{this.availableList=_L0.nowAvailableList;this._availableListChanged(true);if(this.shouldRender)this._render();}}else{this._availableListChanged.bind(this).defer();if(_L3&&_L4)this._onFlChange(_L0.flMode,_L0.flData);}},_onUpdaterError:function(_L0){this.numRequestFailures++;if(this.numRequestFailures>1){this.updateTime=presence.getTime();this.availableCount=0;this._updateCount();this._updateAvailableListWithDiff({},keys(this.availableList));this._showLoadError();}},itemOnClick:function(id,_L1){var _L2;if((_L2=ge(this._getBuddyListItemId(id,_L1)))&&_L2.activeDrag)return;presence.pauseSync();chatDisplay.focusTab(id);if(!this.isSticky())this.closeTab();if(this.typeahead)this.typeahead.resetSearch(true);Arbiter.inform(ChatBuddyList.BUDDY_CLICKED,{flid:_L1,id:id});presence.resumeSync();},_renderItem:function(id,_L1,_L2){var _L3=ChatUserInfos[id];var _L4=_L3.name;var _L5=_L3.thumbSrc;var _L6;if(_L4.length>this.maxNameLen){_L6=_L4.substring(0,this.maxNameLen-2)+'...';}else _L6=_L4;var _L7='';if(_L2)_L7=_tx("Idle");if(_L1){var _L8=sprintf('buddyList.itemOnClick(%d, \'%s\')',id,_L1);}else var _L8=sprintf('buddyList.itemOnClick(%d)',id);var _L9=['<a href="#" class="clearfix friend',(_L2?' idle':''),'" title="',_L7,'"','onclick="',_L8,';return false;" id="',this._getBuddyListItemId(id,_L1),'">'];var _La=!this.isCompactDisplay;var _Lb=this._getFlOpts(_L1);_La&=_Lb.fullDisplay;if(_La)_L9=_L9.concat('<img src="',_L5,'" width="22px" height="22px" />');_L9=_L9.concat('<span id="',this._getBuddyListItemNameId(id,_L1),'">',htmlize(_L6),'</span>','</a>');return _L9.join('');},_groupAvailableListByFl:function(_L0,_L1){if(!this.flMode||!this.flData)return null;_L0=_L0||false;_L1=_L1||false;var _L2={};for(var _L3 in this.flData)_L2[_L3]=[];if(_L1)return _L2;var _L4=function(id){var _L9=this.availableList[id].fl;if(_L9)for(var j=0;j<_L9.length;++j){var _L3=_L9[j];_L2[_L3].push(id);}};var _L5=_L4.bind(this);if(_L0){var _L6=this._getSortedList();for(var i=0;i<_L6.length;i++)_L5(_L6[i]);}else for(var id in this.availableList)_L5(id);return _L2;},_listNameInUse:function(_L0){for(var _L1 in this.flData)if(this.flData[_L1].n==_L0)return true;return false;},keyPressNewListInput:function(e){if(Event.getKeyCode(e)==KEYS.RETURN){var e=$E(e);var _L1=e.getTarget().value;if(this._listNameInUse(_L1)){new ErrorDialog().showError(_tx("An error occurred."),_tx("You cannot have two lists with the same name. Please create a unique name for this list."));return;}var _L2={'create':_L1};this._saveBuddyListSetting(_L2,function(){for(var _L3 in this.flData)if(this.flData[_L3].n==_L1){Vector2.scrollIntoView($(this._getFriendListId(_L3)));break;}}.bind(this));return e.kill();}},handleFlInChat:function(_L0,_L1){buddyListDisplay.closeOpenFlyout();if(_L0){this._unHideFriendListFromChat(_L1);}else this._hideFriendListFromChat(_L1);},_unHideFriendListFromChat:function(_L0){var _L1=this._getFriendListsInChat().length==0;var _L2=[_L0];var _L3={'unhide_from_chat':1,'flids':_L2};this.flData[_L0].h=0;this._saveBuddyListSetting(_L3,function(){this._showEmptyListMomentarily(_L0);Vector2.scrollIntoView($(this._getFriendListId(_L0)));}.bind(this));if(_L1){this._onFlChange(true,this.flData);}else this._addFlidsToDOM(_L2);},_hideFriendListFromChat:function(_L0){var _L1=this._getFriendListsInChat().length==1;var _L2=[_L0];var _L3={'hide_from_chat':1,'flids':_L2};this.flData[_L0].h=1;this._saveBuddyListSetting(_L3);if(_L1){this._onFlChange(false,this.flData);}else this._removeFlidsFromBuddyList(_L2);},_friendListHandleSwitchThrown:function(_L0){var _L1=this.flData[_L0].o;if(_L1){this._goOfflineToLists([_L0]);}else this._goOnlineToLists([_L0]);},_friendListHandleSwitchMouseDown:function(_L0){var evt=Event.listen(document,'mouseup',function(){evt.remove();this._friendListHandleSwitchThrown(_L0);}.bind(this));},_friendListHandleMouseOver:function(_L0){if(this.reorderingLists)return;CSS.addClass($(this._getFriendListId(_L0)),'hover');},_friendListHandleMouseOut:function(_L0){CSS.removeClass($(this._getFriendListId(_L0)),'hover');},_saveBuddyListSetting:function(_L0,_L1){_L0['user']=this.user;_L1=_L1||bagofholding;new AsyncRequest().setData(_L0).setURI('/ajax/chat/buddy_list_settings.php').setHandler(this._onBuddyListSettingSave.bind(this,_L1)).setFinallyHandler(function(){buddyListDisplay.closeOpenFlyout();}).send();},_goOnlineToLists:function(_L0,_L1){_L1=_L1||false;var _L2={'online_to_list':1,'flids':_L0,'read_only':_L1};this._handleFlVisibilityChange(_L0,1);this._saveBuddyListSetting(_L2);},_handleFlVisibilityChange:function(_L0,_L1,_L2){for(var i=0;i<_L0.length;i++){var _L4=_L0[i];var _L5=ge(this._getFriendListId(_L4));if(!_L5)continue;this.flData[_L4].o=_L1;if(_L1){CSS.addClass(_L5,'online');CSS.removeClass(_L5,'offline');if(_L4==this.otherFriendsFlid)this._showEmptyListMomentarily(_L4);}else{CSS.addClass(_L5,'offline');CSS.removeClass(_L5,'online');}var _L6=DOM.find(_L5,'div.titletip strong');DOM.setText(_L6,this._getFriendListTooltipText(_L4));_L2&&_L2(_L4);}},_showEmptyListMomentarily:function(_L0){this.shownEmptyFlids=this.shownEmptyFlids||{};this.shownEmptyFlids[_L0]=1;var _L1=ge(this._getFriendListId(_L0));if(_L1)CSS.addClass(_L1,'show_empty_list');(function(){delete this.shownEmptyFlids[_L0];var _L1=ge(this._getFriendListId(_L0));if(_L1)CSS.removeClass(_L1,'show_empty_list');}).bind(this).defer(8000);},_goOfflineToLists:function(_L0,_L1){_L1=_L1||false;var _L2=this._groupAvailableListByFl();this._handleFlVisibilityChange(_L0,0,function(_L4){var _L5=_L2[_L4];this._removeFromBuddyList(_L5,_L4);}.bind(this));if(!_L1){var _L3={'offline_to_list':1,'flids':_L0};this._saveBuddyListSetting(_L3);}},_removeFlidsFromBuddyList:function(_L0,_L1){_L1=_L1||this._groupAvailableListByFl(true);if(!_L1)return;var _L2={};for(var i=0;i<_L0.length;i++){var _L4=_L0[i];var ids=_L1[_L4];if(!ids)continue;for(var j=0;j<ids.length;j++){var id=ids[j];var _L8={};_L8['i']=this.availableList[id].i;_L8['fl']=this.availableList[id].fl.clone();if(this.flMode){_L8.fl.remove(_L4);if(_L8.fl.length==0)_L8.fl.push(this.otherFriendsFlid);}else delete _L8.fl;_L2[id]=_L8;}}if(!is_empty(_L2))this._updateAvailableListWithDiff(_L2,[]);this._removeFlidsFromDOM(_L0);},_onBuddyListSettingSave:function(_L0,_L1){var _L2=_L1.getPayload();if(_L2){if(_L2.availableList){this.updateUserInfos(_L2.userInfos);var _L3;if(_L2.flids&&_L2.flids.length==1)_L3=_L2.flids[0];this._updateAvailableListWithDiff(_L2.availableList,[],_L3);}if(_L2.flData){var _L4;if(typeof _L2.flMode!='undefined'){_L4=_L2.flMode;}else _L4=true;this._onFlChange(_L4,_L2.flData);this._resetFlidClasses();}_L0&&_L0();}},_flManagerHandler:function(_L0,_L1){},_resetFlidClasses:function(){if(!this.flMode)return;var _L0=this._groupAvailableListByFl();for(var _L1 in this.flData){var _L2=ge(this._getFriendListId(_L1));if(_L2)CSS.setClass(_L2,this._getFriendListItemClasses(_L1,_L0));}},_getFriendListItemClasses:function(_L0,_L1){var _L2=this.flData[_L0].o;var _L3=this.flData[_L0].h;var _L4=['friend_list'];if(_L2){_L4.push('online');}else _L4.push('offline');if(!_L3&&this.shownEmptyFlids&&this.shownEmptyFlids[_L0])_L4.push('show_empty_list');if(is_empty(_L1[_L0]))if(this.availableCount!=0&&(this.flData[_L0].c==0||_L0==this.otherFriendsFlid)){_L4.push('empty_friend_list');}else if(_L2)_L4.push('hide_friend_list');if(_L0==this.otherFriendsFlid){_L4.push('compact_friend_list');_L4.push('other_friends_list');}if(this.reorderingLists&&(_L0==this.otherFriendsFlid||_L0==this.botsFlid))_L4.push('suppress');return _L4.join(' ');},_renderFriendListHeader:function(_L0){var _L1=this.flData[_L0].n;var _L2=this.flData[_L0].o;var _L3='';var _L4=typeof this.flData[_L0].s!='undefined';if(!_L4&&_L0!=this.otherFriendsFlid)var _L3='<a href="/friends/ajax/edit_list.php?list_id='+_L0+'" '+'rel="dialog-post">'+_tx("edit")+'</a>';var _L5=['<div class="friendlist_name">','<span class="title"><a href="#">',htmlize(_L1),'</a></span>','<span class="edit_link">',_L3,'</span>','</div>'];if(!_L4)_L5.push('<div class="switch"><a class="online_status" ','>','<div class="titletip"><strong>',this._getFriendListTooltipText(_L0),'</strong></div>','</a>','</div>');return _L5.join('');},_getFriendListTooltipText:function(_L0){return this.flData[_L0].o?_tx("Go offline"):_tx("Go online");},registerExternalFriendList:function(_L0){if(!this.rendered)this._firstRender();var _L1='xfl_'+this.externalFlids.length;this.externalFlids.push(_L1);this.flOpts[_L1]=_L0;return _L1;},_renderFriendListContent:function(_L0,ids){var _L2;var _L3=this.flMode&&_L0;if(_L3){_L2=['<div id="',this._getFriendListContainerId(_L0),'"','class="friend_list_container">'];}else _L2=[];_L2.push('<div id="',this._getAvailableMarkerId(_L0),'" class="suppress"></div>');var _L4=[];var _L5=false,_L6=false;for(var j=0;j<ids.length;j++){var id=ids[j];var _L9=this.availableList[id].i;var _La=[this._renderItem(id,_L0,_L9)];if(_L9){_L5=true;_L4=_L4.concat(_La);}else{_L6=true;_L2=_L2.concat(_La);}}var _Lb=(_L5&&_L6)?'':' hide_idle_marker';_L2.push('<div id="',this._getIdleMarkerId(_L0),'" class="subheader',_Lb,'"></div>');_L2=_L2.concat(_L4);if(_L3)_L2.push('</div>');return _L2.join('');},_addFriendListListeners:function(_L0){if(!this.flMode)return;_L0=_L0||this._getRenderedFriendLists();for(var i=0;i<_L0.length;i++){var _L2=_L0[i];if(typeof this.flData[_L2].s!='undefined')continue;var _L3=$(this._getFriendListId(_L2));Event.listen(_L3,'mouseover',this._friendListHandleMouseOver.bind(this,_L2));Event.listen(_L3,'mouseout',this._friendListHandleMouseOut.bind(this,_L2));var _L4=DOM.find(_L3,'a.online_status');Event.listen(_L4,'mousedown',this._friendListHandleSwitchMouseDown.bind(this,_L2));}},_renderBuddyContent:function(){var _L0=(this.availableCount?'hide_empty_item':'');var _L1=['<div id="buddy_list_all" class="subgroup">',this.renderEmptySearch(),'<div id="buddy_list_parent" class="list_select">','<div id="',this._getBuddyListEmptyItemId(),'" class="info_text ',_L0,'">',_tx("No one is available to chat."),'</div>'];var _L2;var _L3={};if(this.flMode){_L2=keys(this.flData);_L3=this._groupAvailableListByFl(true);}else _L2=[null];for(var i=0;i<_L2.length;++i){var _L5=_L2[i];var ids=[];if(this.flMode&&_L5){if(this.flData[_L5].h)continue;_L1.push('<div id="',this._getFriendListId(_L5),'"','class="',this._getFriendListItemClasses(_L5,_L3),'">',this._renderFriendListHeader(_L5));ids=_L3[_L5];}else ids=this._getSortedList();_L1.push(this._renderFriendListContent(_L5,ids));if(this.flMode&&_L5)_L1.push('</div>');}_L1.concat(['</div>','</div>']);return _L1.join('');},renderEmptySearch:function(_L0){var _L1='<div id="'+this._getEmptySearchId(_L0)+'" class="info_text" style="display:none">'+_tx("Could not find that friend online.")+'</div>';return _L1;},_render:function(){this._getSortedList();CSS.conditionClass(this.contentDiv,'compact',this.isCompactDisplay);var _L0=this._renderBuddyContent();if(this.rendered)CSS.addClass(this.contentDiv,'hidden');this.contentDiv.innerHTML=_L0;presence.contentChanged(this.contentID);if(this.rendered){CSS.addClass(this.wrapperDiv,'presence_menu_offscreen');this._hideError();CSS.removeClass(this.contentDiv,'hidden');this.resizeTab();CSS.removeClass(this.wrapperDiv,'presence_menu_offscreen');this._initDragging();this._addFriendListListeners();}if(this.errorMode)this._showLoadError();if(this.shouldShowLoading){this._showLoading();this.shouldShowLoading=false;}},_firstRender:function(){this._render();this.rendered=true;this.loadTypeahead();},updateItemDisplay:function(id){var _L1=this.availableList[id];if(!_L1)return;var _L2=this._getUserFlids(id);for(var i=0;i<_L2.length;i++){var _L4=_L2[i];var _L5=ge(this._getBuddyListItemId(id,_L4));if(!_L5)return;_L5=HTML(this._renderItem(id,_L4,_L1.i)).getRootNode();}},_showLoadError:function(){this._showError(_tx("Could not load available friends."));},_showLoading:function(){this._showError(_tx("Loading..."));},_hideError:function(){this.showingError=false;CSS.removeClass(this.wrapperDiv,'error');},_showError:function(_L0){this.showingError=true;set_inner_html(this.buddyListError,_L0);CSS.addClass(this.wrapperDiv,'error');},isSticky:function(){return chatOptions.getSetting('sticky_buddylist');},enterReorderingFlMode:function(){if(this.reorderingLists)return;this.reorderingLists=true;CSS.addClass(this.wrapperDiv,'reorder_fl');var _L0=this._getRenderedFriendLists();this.flSortableGroup=new SortableGroup();for(var i=0;i<_L0.length;i++){var _L2=_L0[i];if(_L2==this.otherFriendsFlid||_L2==this.botsFlid){CSS.addClass(this._getFriendListId(_L2),'suppress');}else this._addFlSortable(_L2);}var _L3=$N('div',{id:'reorder_fl_alert'},[$N('span',{className:'helper_text'},_tx("Drag lists to re-order.")),$N('input',{type:'button',className:'inputbutton',value:_tx("Finished re-ordering"),onclick:this.exitReorderingFlMode.bind(this)})]);DOM.insertBefore(_L3,this.contentDiv);this.freezeTabSize(false);},exitReorderingFlMode:function(){if(!this.reorderingLists)return;this._reorderFlids();DOM.remove($('reorder_fl_alert'));CSS.removeClass(this.wrapperDiv,'reorder_fl');var _L0=this._getRenderedFriendLists();for(var i=0;i<_L0.length;i++){var _L2=_L0[i];if(_L2==this.otherFriendsFlid||_L2==this.botsFlid){CSS.removeClass(this._getFriendListId(_L2),'suppress');}else this._removeFlSortable(_L2);}this.reorderingLists=false;this.unfreezeTabSize.bind(this).defer(50);this.flSortableGroup.destroy();this.flSortableGroup=null;},_addFlSortable:function(_L0){if(this.flSortableGroup!=null){this.flSortableGroup.addSortable(_L0,$(this._getFriendListId(_L0)));animation($(this._getFriendListContainerId(_L0))).to('height','0px').to('opacity',0).from(1).blind().hide().ease(animation.ease.end).duration(300).go();}},_removeFlSortable:function(_L0){if(this.flSortableGroup!=null){this.flSortableGroup.removeSortable(_L0);var _L1;if(_L1=ge(this._getFriendListContainerId(_L0)))animation(_L1).to('height','auto').from('0px').to('opacity',1).from(0).blind().show().ease(animation.ease.end).duration(300).go();}},_reorderFlids:function(){var _L0={'reorder':1,'flids':this.flSortableGroup.getOrder()};this._saveBuddyListSetting(_L0);},_getDragKey:function(id,_L1){return id+'_'+_L1;},_initDragging:function(){if(!this.flMode)return;var _L0=this._groupAvailableListByFl();this.sortables={};var _L1=this._getRenderedFriendLists();for(var i=0;i<_L1.length;i++){var _L3=_L1[i];var ids=_L0[_L3];this._initFlidSortable(_L3,ids);}},_initFlidSortable:function(_L0,ids){if(!_L0||!this.flMode)return;if(this.flData[_L0].s)return;var _L2=head(this.sortables);this.sortables[_L0]=new SortableGroup();if(_L2)_L2.link(this.sortables[_L0]);var _L3=$N('div',{id:this._getEmptyListDropZoneId(_L0),className:'list_drop_zone'},$N('span',{className:'list_drop_zone_inner'},_tx("Drag a friend here to add")));var _L4=$(this._getFriendListContainerId(_L0));this.sortables[_L0].addEmptyMessage(_L3,_L4).setBoundingBox(this._getBoundingBox()).setDragOverCallback(this._dragOverHandler.bind(this)).setDropCallback(this._dropHandler.bind(this)).setGrabCallback(this._grabHandler.bind(this));for(var j=0;j<ids.length;j++)this._addSortable(ids[j],_L0);},_getBoundingBox:function(){return Rect.newFromVectors(new Vector2(0,0),Vector2.getElementDimensions(this.contentDiv));},_destroyFlidSortable:function(_L0){if(!_L0||!this.flMode)return;if(this.sortables&&this.sortables[_L0]){this.sortables[_L0].destroy();delete this.sortables[_L0];}},_addSortable:function(id,_L1){if(!_L1||!this.flMode||!this.flData[_L1])return;if(this.flData[_L1].s)return;if(!this.sortables[_L1])return;var key=this._getDragKey(id,_L1);if(this.sortables[_L1].keyExists(key))return;this.sortables[_L1].addSortable(key,ge(this._getBuddyListItemId(id,_L1)));},_removeSortable:function(id,_L1,_L2){if(!_L1||!this.flMode)return;if(this.sortables[_L1])this.sortables[_L1].removeSortable(this._getDragKey(id,_L2||_L1));},_dragOverHandler:function(_L0,_L1){if(CSS.hasClass(_L1,'list_drop_zone')){var _L2=this._extractFlid(_L1.id);var _L3=$(this._getFriendListId(_L2));CSS.addClass(_L3,'drag_over');}},_grabHandler:function(key){CSS.addClass($('buddy_list_parent'),'drag_active');},_dropHandler:function(key){CSS.removeClass($('buddy_list_parent'),'drag_active');var _L1=key.split('_');if(_L1.length!=2)return;var id=_L1[0];var _L3=_L1[1];var _L4=$(this._getBuddyListItemId(id,_L3));if(!_L4)return;var _L5=this._extractFlid(_L4.parentNode.id);if(_L5==_L3){this._updateUIAfterDragging(id,_L3,_L3,_L4);}else{if(this.flData[_L3].s||this.flData[_L5].s){this._updateUIAfterDragging(id,_L3,_L3,_L4);return;}var _L6=this.availableList[id].fl;var _L7=false;var _L8=false;var _L9=false;if(_L5==this.otherFriendsFlid){_L8=true;if(_L6.length==1){this.availableList[id].fl=[this.otherFriendsFlid];}else{this.availableList[id].fl.remove(_L3);_L9=true;DOM.remove(_L4);Vector2.scrollIntoView(this.getBuddyItem(id));}}else if(_L6.length==1){this.availableList[id].fl=[_L5];_L7=_L3!=this.otherFriendsFlid;}else{_L7=true;this.availableList[id].fl.push(_L5);this.availableList[id].fl.remove(_L3);}if(_L9||this._updateUIAfterDragging(id,_L3,_L5,_L4)){var _La;if(_L8){_La={'remove_fl':true,'old_flid':_L3,'drag_uid':id};}else if(_L7){_La={'move_fl':true,'new_flid':_L5,'old_flid':_L3,'drag_uid':id};}else _La={'add_fl':1,'new_flid':_L5,'drag_uid':id};this._saveBuddyListSetting(_La);}}this._resetFlidClasses();},_updateUIAfterDragging:function(id,_L1,_L2,_L3){var _L4=this._groupAvailableListByFl(true);var _L5=_L4[_L2];var _L6=_L5.indexOf(id);var _L7;if(_L6==-1){return false;}else if(_L6==0){_L7=$(this._getAvailableMarkerId(_L2));}else _L7=$(this._getBuddyListItemId(_L5[_L6-1],_L2));(function(){var _L8,_L9=false;if(_L5.length!=1)_L8=showHight=true;var _La=this._expandItem(id,_L2,_L7,this.availableList[id].i,_L8,false,_L9);if(_L1!=_L2){DOM.remove(_L3);this._removeSortable(id,_L2,_L1);}Vector2.scrollIntoView(_La);}).bind(this).defer(500);return true;},_getGlobalFlids:function(_L0){var _L1=this.flMode&&this.flData?keys(this.flData):[null];return _L0?_L1:_L1.concat(this.externalFlids);},_getUserFlids:function(id,_L1,_L2){_L1=_L1||this.availableList[id];var _L3=_L1.fl?_L1.fl:[null];if(!_L2){if(!_L1.allFlids)_L1.allFlids=this._addExternalFlids(id,_L3);_L3=_L1.allFlids;}return _L3;},_addExternalFlids:function(id,_L1){_L1=_L1.concat();for(var i=0;i<this.externalFlids.length;i++){var _L3=this.externalFlids[i];var _L4=this._getFlOpts(_L3);if(!_L4.excludeIds[id])_L1.push(_L3);}return _L1;},_getFlOpts:function(_L0){return this.flOpts[_L0]||ChatBuddyList.DEFAULT_OPTS;},_getAvailableMarkerId:function(_L0){return this._encodeFlid('buddy_list_avail_marker',_L0);},_getIdleMarkerId:function(_L0){return this._encodeFlid('buddy_list_idle_marker',_L0);},_getEmptyListDropZoneId:function(_L0){return this._encodeFlid('buddy_list_drop_zone',_L0);},_getBuddyListItemId:function(id,_L1){return this._encodeFlid('buddy_list_item_'+id,_L1);},_getBuddyListItemNameId:function(id,_L1){return this._encodeFlid('buddy_list_item_name_'+id,_L1);},_getBuddyListWasItemId:function(id,_L1){return this._encodeFlid('buddy_list_was_item_'+id,_L1);},_getEmptySearchId:function(_L0){return this._encodeFlid('buddy_list_empty_search',_L0);},_getBuddyListEmptyItemId:function(){return 'buddy_list_empty_item';},_encodeFlid:function(_L0,_L1){return _L1?(_L1+'_'+_L0):_L0;},_getFriendListId:function(_L0){return this._encodeFlid('friend_list_item',_L0);},_extractFlid:function(id){return id.split('_').shift();},_getFriendListContainerId:function(_L0){return this._encodeFlid('friend_list_container',_L0);},debugPrintUpdateOverlay:function(){Util.log("buddyList.updateOverlay =");var uo=this.updateOverlay;for(var id in uo)Util.log(id+": st = "+uo[id].ol+", expires in = "+(uo[id].exp-presence.getTime()));}};
function ChatBuddyListDisplay(_L0){this.openFlyout=null;this.openControl=null;this.panelID=_L0;if(presence.inPopoutWindow){this._init();}else this.arbiterInit=Arbiter.subscribe(PresenceMessage.TAB_OPENED,this._onTabOpen.bind(this));}ChatBuddyListDisplay.prototype={_onTabOpen:function(_L0,_L1){var tab=_L1.tabID;if(tab&&tab=='buddy_list_tab'){Arbiter.unsubscribe(this.arbiterInit);this._init();}},_init:function(){this.buddyListPanel=$(this.panelID,true);var _L0=this._clickControlPanel.bind(this,'buddy_list_panel_lists_control','buddy_list_panel_lists_flyout',this._getListsFlyoutContent.bind(this));Event.listen(DOM.find(this.buddyListPanel,'#buddy_list_panel_lists_control a'),'click',_L0);var _L1=this._clickControlPanel.bind(this,'buddy_list_panel_settings_control','buddy_list_panel_settings_flyout',this._getChatSettingsNodes.bind(this));Event.listen(DOM.find(this.buddyListPanel,'#buddy_list_panel_settings_control a'),'click',_L1);},_clickVisibilityToggle:function(){chatOptions.toggleVisibility();this.closeOpenFlyout();},_clickReorderLists:function(){buddyList.enterReorderingFlMode();this.closeOpenFlyout();},_clickControlPanel:function(_L0,_L1,_L2){if(this.openFlyout){if(this.openFlyout==_L1){this.closeOpenFlyout();}else{this.closeOpenFlyout();this._openFlyout(_L0,_L1,_L2());}}else this._openFlyout(_L0,_L1,_L2());return false;},_openFlyout:function(_L0,_L1,_L2){DOM.setContent($(_L1),_L2);CSS.removeClass(_L1,'hidden_elem');CSS.addClass(_L0,'flyout_open');if(!presence.poppedOut){var _L3=Vector2.getElementDimensions($(_L1)).y;var _L4=Vector2.getElementDimensions(buddyList.getContentWrapper()).y;if(_L3>_L4)CSS.addClass(_L1,'flyout_reversed');}this.openFlyout=_L1;this.openControl=_L0;},isFlyoutOpen:function(){return this.openFlyout;},closeOpenFlyout:function(){if(!this.openFlyout)return;CSS.addClass(this.openFlyout,'hidden_elem');CSS.removeClass(this.openFlyout,'flyout_reversed');CSS.removeClass(this.openControl,'flyout_open');this.openFlyout=null;this.openControl=null;},_getListsFlyoutContent:function(){var _L0=$N('input',{className:'inputtext',type:'text'});_L0.listen('keypress',buddyList.keyPressNewListInput.bind(buddyList));new TextInputControl(_L0).setPlaceholderText(_tx("Type a list name"));var _L1=$N('div',{className:'new_list'},[$N('span',{},_tx("Create a new list:")),_L0]);var _L2=$N('div',{className:'text'},_tx("Display these lists in Chat:"));var _L3=buddyList.getFriendLists();var _L4=new UISelectList();_L4.setCallback(buddyList.handleFlInChat.bind(buddyList));for(var _L5 in _L3)_L4.addItem(_L3[_L5].n,!_L3[_L5].h,_L5);return [_L2,_L4.getElement(),_L1];},_renderListSettingToggle:function(_L0,_L1,_L2){return this._renderToggle('list_online_'+_L0,_L1,_L2,'list_online_checkbox_'+_L0,function(_L3,evt){buddyList.handleFlInChat(_L0,_L3);});},_renderChatSettingToggle:function(_L0,_L1,_L2){return this._renderToggle('chat_setting_'+_L0,_L1,_L2,'chat_setting_checkbox_'+_L0,function(_L3,evt){this.sendSettingChange(_L0,_L3.checked);}.bind(this));},_renderToggle:function(_L0,_L1,_L2,_L3,_L4){var _L5=$N('input',{type:'checkbox',id:_L3,name:_L3});_L5.checked=_L1;_L5.defaultChecked=_L1;_L5.listen('click',_L4.bind(this,_L5));var _L6=$N('label',{},_L2);_L6.setAttribute('for',_L3);return $N('div',{className:'chat_setting clearfix',id:_L0},[$N('div',{className:'input_box'},[$N('span',{className:'show_loading'},$N('img',{src:'/images/loaders/indicator_blue_small.gif'})),$N('span',{className:'hide_loading'},_L5)]),_L6]);},_getChatSettingsNodes:function(){var _L0=[];if(this.buddyListPanel){var _L1=$N('a',{className:'go_offline_control'},[$N('div',{className:'menu_icon'}),$N('span',{},_tx("Go offline"))]);_L1.listen('click',this._clickVisibilityToggle.bind(this));var _L2=$N('div',{className:'options_actions'},_L1);if(buddyList._getFriendListsInChat().length>1){var _L3=$N('a',{className:'list_reorder_control'},[$N('div',{className:'menu_icon'}),$N('span',{},_tx("Re-order lists"))]);_L3.listen('click',this._clickReorderLists.bind(this));_L2.appendChild(_L3);}var _L4=$N('a',{className:'list_popout_control'},[$N('div',{className:'menu_icon'}),$N('span',{},(presence.poppedOut?_tx("Pop in Chat"):_tx("Pop Out Chat")))]);_L4.listen('click',presence.popout.bind(presence));_L2.appendChild(_L4);_L0.push(_L2);_L0.push($N('hr',{className:'menu_divider'}));}var _L5=[{name:'sound',label:_tx("Play Sound for New Messages")},{name:'sticky_buddylist',label:_tx("Keep Online Friends Window Open")},{name:'compact_buddylist',label:_tx("Show names only in online friends")}];for(var i=0;i<_L5.length;i++)_L0.push(this._renderChatSettingToggle(_L5[i].name,chatOptions.getSetting(_L5[i].name),_L5[i].label));return _L0;},_onSettingChangeResponse:function(_L0,_L1,_L2){chatOptions.setSetting(_L0,_L1);CSS.removeClass($('chat_setting_'+_L0),'chat_setting_loading');presence.doSync();},_onSettingChangeError:function(_L0,_L1){presence.showAsyncError(_L1,_tx("Couldn't change that setting"));CSS.removeClass($('chat_setting_'+_L0),'chat_setting_loading');},sendSettingChange:function(_L0,_L1){CSS.addClass($('chat_setting_'+_L0),'chat_setting_loading');var _L2={};_L2[_L0]=_L1;new AsyncRequest().setHandler(this._onSettingChangeResponse.bind(this,_L0,_L1)).setErrorHandler(this._onSettingChangeError.bind(this,_L0)).setTransportErrorHandler(this._onSettingChangeError.bind(this,_L0)).setData(_L2).setURI(chatDisplay.settingsURL).send();}};
function ChatOptions(_L0,_L1){this.visibility=_L0;this.settings=_L1;this._init();}copy_properties(ChatOptions,{VISIBILITY_CHANGED:'chat/visibility-changed'});ChatOptions.prototype={_init:function(){presence.registerStateStorer(this._storeState.bind(this));presence.registerStateLoader(this._loadState.bind(this));},_storeState:function(_L0){_L0.vis=this.visibility;_L0.bls=this.getSetting('sticky_buddylist');_L0.blc=this.getSetting('compact_buddylist');_L0.snd=this.getSetting('sound');return _L0;},_loadState:function(_L0){if(_L0.vis!=this.visibility)this.setVisibility(_L0.vis);this.setSetting('sticky_buddylist',_L0.bls);this.setSetting('compact_buddylist',_L0.blc);this.setSetting('sound',_L0.snd);},setVisibility:function(_L0){if(_L0==this.visibility)return;this.visibility=_L0;if(_L0){channelManager.isActionRequest=true;channelManager.rebuild(ChannelRebuildReasons.UIRestart);}else channelManager.setReady(false);Arbiter.inform(ChatOptions.VISIBILITY_CHANGED,{sender:this});},_onVisibilityResponse:function(_L0,_L1){presence.pauseSync();this.setVisibility(_L0);if(!presence.inPopoutWindow&&!_L0)chatDisplay.unfocus();presence.resumeSync();if(presence.poppedOut)presence.popout();},_onVisibilityError:function(_L0){var _L1=_tx("Chat");presence.showAsyncError(_L0,_tx("Couldn't set {Chat} availability",{'Chat':_L1}));},toggleVisibility:function(){this.sendVisibility(!this.visibility);},sendVisibility:function(_L0){if(this.visibility==_L0)return;this.visibilityAsync=new AsyncRequest().setHandler(this._onVisibilityResponse.bind(this,_L0)).setErrorHandler(this._onVisibilityError.bind(this)).setTransportErrorHandler(this._onVisibilityError.bind(this)).setData({'visibility':_L0}).setURI(chatDisplay.settingsURL).send();},getSetting:function(_L0){return this.settings[_L0];},setSetting:function(_L0,_L1){if(this.getSetting(_L0)==_L1)return;if(_L0=='compact_buddylist')buddyList.setCompactDisplay(_L1);this.settings[_L0]=_L1;}};
function ChatTabSlider(){this.handleWidth=141;this.animationTime=210;this._init();}ChatTabSlider.prototype={_init:function(){this.org_s=0;this.numToShow=0;this.numShift=1;this.shiftByNumTabs=false;this.timer=null;this.skipAnimation=false;this.chatWidth=null;this.tabPos={};this.chat=ge('chat');this.chatTabBar=ge('chat_tab_bar');this.nextTab=ge('chat_next_tab');this.prevTab=ge('chat_previous_tab');this.nextCounter=ge('next_count');this.prevCounter=ge('prev_count');this.numNext=0;this.numPrev=0;this.prevTabs={};this.nextTabs={};this.numMissedNextCounter=ge('next_num_missed');this.numMissedPrevCounter=ge('prev_num_missed');presence.registerStateLoader(this._load.bind(this));presence.registerStateStorer(this._store.bind(this));Arbiter.subscribe(PresenceMessage.WINDOW_RESIZED,this._resize.bind(this,false));},load:function(){this._load(presence.state);this._resize(true);},_load:function(_L0){var s=0;if(_L0)s=(_L0.s?_L0.s:s);this._setPos(s);},_store:function(_L0){_L0.s=this._s;return _L0;},_calculate:function(_L0){this._setMaxWidth();if(_L0)this.maxWidth-=16;if(presence.poppedOut){this.numToShow=chatDisplay.numTabs;}else{this.numToShow=parseInt(this.maxWidth/this.handleWidth);this.numToShow=this.numToShow>0?this.numToShow:1;}if(this.shiftByNumTabs)this.numShift=this.numToShow;if(this._s!=null)this._setPos(this._s);},_setMaxWidth:function(){var w=DOMScroll.getScrollRoot().offsetWidth;if(ChatTabSlider.presenceWidthTest)var w=$('presence_ui').offsetWidth;var _L1=['buddy_list_tab','presence_notifications_tab','presence_applications_tab','icon_garden','bookmarkable_app'];for(var i=0;i<_L1.length;i++)w-=(ge(_L1[i])&&$(_L1[i]).clientWidth!=undefined)?ge(_L1[i]).clientWidth:0;this.maxWidth=(presence.poppedOut?w-254:w-138);},_setPos:function(val){if(val<0)val=0;this._s=val;this._e=this._s+this.numToShow;},_doSync:function(){var _L0=(this.org_s!=this._s);this.org_s=0;if(_L0)presence.doSync();},_build:function(){if(presence.poppedOut)return;var all=(this.numToShow>=chatDisplay.numTabs)?true:false;this.setVisibleTabs(all);if(all){this.resetCounters();}else this.updateCounters();this.updateMissedCount();},_resize:function(_L0){this.org_s=this._s;this._calculate(_L0);this._build();this._doSync();if(chatDisplay.lastFocused!=null)this.gotoTab(chatDisplay.lastFocused);},addTab:function(id){this._build();},gotoTab:function(id){if(this.tabPos[id]!=0&&!this.tabPos[id])return;var n=parseInt(this.tabPos[id]);if(!this._inRange(n)){var p=(n-this.numToShow)+1;this._setPos(p);this._build();}},close:function(id){if(this.tabPos[id]!=0&&!this.tabPos[id])return;delete this.tabPos[id];this._setPos(((this.numPrev>0||this.numNext>0)&&this._s>0)?this._s-1:0);this._calculate();this._build();},setVisibleTabs:function(all){var c=0;for(var id in chatDisplay.tabs){this.tabPos[id]=c;if(this._inRange(c,id)||all==true){chatDisplay.tabs[id].show();}else chatDisplay.tabs[id].hide();c++;}},_inRange:function(n,id){var s,e=false;if(n>=this._s){s=true;delete this.prevTabs[id];}else this.prevTabs[id]=id;if(n<this._e){e=true;delete this.nextTabs[id];}else this.nextTabs[id]=id;return (s&&e);},updateMissedCount:function(){var _L0=0;var _L1=0;for(var id in this.prevTabs)_L0+=chatDisplay.tabs[id]?chatDisplay.tabs[id].numMissed:0;this.numMissedPrevCounter.innerHTML=_L0;this.numMissedPrevCounter.style.display=_L0>0?'block':'none';for(var id in this.nextTabs)_L1+=chatDisplay.tabs[id]?chatDisplay.tabs[id].numMissed:0;this.numMissedNextCounter.innerHTML=_L1;this.numMissedNextCounter.style.display=_L1>0?'block':'none';},updateCounters:function(){this.numNext=chatDisplay.numTabs-this._e;this.numPrev=this._s;if(this.numNext<=0){this.numNext=0;CSS.addClass(this.nextTab,'disabled');}else CSS.removeClass(this.nextTab,'disabled');if(this.numPrev<=0){this.numPrev=0;CSS.addClass(this.prevTab,'disabled');}else CSS.removeClass(this.prevTab,'disabled');if(this.numPrev>0||this.numNext>0){show('chat_next_tab');show('chat_previous_tab');}else{hide('chat_next_tab');hide('chat_previous_tab');}this.nextCounter.innerHTML=this.numNext;this.prevCounter.innerHTML=this.numPrev;},resetCounters:function(){this._setPos(0);this.updateCounters();},shift:function(num){this.org_s=this._s;chatDisplay.unfocusNoSync();this._shift.bind(this,num).defer();},_shift:function(num){this._setPos(this._s<0?0:this._s+num);this._slide(num);if(this.timer||this.skipAnimation){this._slideReset();this.skipAnimation=true;var t=setTimeout(function(){this.skipAnimation=false;}.bind(this),500);}else this.timer=setTimeout(function(){this._slideReset();}.bind(this),this.animationTime);},_slide:function(num){this._slideSetup(false);this.setVisibleTabs(true);this.slideInc=(num*(this.handleWidth));this.leftPos=-(num)*(this.numNext*(this.slideInc));this.chatTabBar.style.left=this.leftPos+'px';animation(this.chatTabBar).by('left',this.slideInc).duration(this.animationTime-10).go();},_slideSetup:function(_L0){this.chat.style.position=_L0?'':'relative';this.chat.style.overflow=_L0?'visible':'hidden';if(!this.chatWidth)this.chatWidth=this.chatTabBar.clientWidth;if(_L0)this.chatWidth=null;this.chat.style.width=_L0?'':this.chatWidth+'px';this.chatTabBar.style.width=_L0?'':chatDisplay.numTabs*this.handleWidth+'px';this.chatTabBar.style.position=_L0?'':'absolute';},_slideReset:function(){clearTimeout(this.timer);this.timer=null;this._slideSetup(true);this._build();if(chatDisplay.lastFocused)if(this._inRange(this.tabPos[chatDisplay.lastFocused])){chatDisplay.refocus();}else chatDisplay.lastFocused=null;this._doSync();},next:function(){if(this.numNext<=0)return;this.shift(this.numShift);},prev:function(){if(this.numPrev<=0)return;this.shift(-this.numShift);}};
var ChannelRebuildReasons={Unknown:0,AsyncError:1,TooLong:2,Refresh:3,RefreshDelay:4,UIRestart:5,NeedSeq:6,PrevFailed:7,IFrameLoadGiveUp:8,IFrameLoadRetry:9,IFrameLoadRetryWorked:10,PageTransitionRetry:11};function fbChannelUplink(){this.startDelay=1000;this.regularDelay=100;this.checkAliveInterval=65000;this.retryInterval=1000;this.maxRetries=0;this.reconnectInterval=1000;this.maxReconnects=5;this.targetOrigin=null;this._init();}function handleChannelParentMessageEvent(_L0){_L0=_L0||window.event;var _L1=(_L0.domain||_L0.origin);if(_L1.substring(_L1.length-13)!='.facebook.com'&&_L1.substring(_L1.length-15)!='://facebook.com'&&_L1!='facebook.com')return;handleChannelParentMessage(_L0.data);}function handleChannelParentMessage(parentMsgStr){if(parentMsgStr&&parentMsgStr.charAt(0)=='{')channelUplink.handleParentMessage(eval('('+parentMsgStr+')'));}fbChannelUplink.prototype={_init:function(){this.debug('iframex: init');this.requestNum=0;this.request=null;this.reconnectNum=0;this.checkAliveTimer=null;this.isReconnecting=false;this.isIframeReconnecting=false;this.isActionRequest=false;this.parentAlive=false;this.channels={};this.managerIsReady=false;if(window.postMessage){var _L0=window.parent.location;var _L1=_L0.hostname;if(_L1=='facebook.com'||_L1.substring(_L1.length-13)=='.facebook.com')this.targetOrigin=_L0.protocol+'//'+_L0.host;if("object"==typeof window.postMessage){var _L2=window.parent;this.postMessage=function(_L3,_L4){_L2.postMessage(_L3,_L4);};}else this.postMessage=bind(window.parent,window.parent.postMessage);if(window.addEventListener){window.addEventListener('message',handleChannelParentMessageEvent,false);}else window.onmessage=handleChannelParentMessageEvent;}else if(document.postMessage){this.postMessage=bind(window.parent.document,window.parent.document.postMessage);document.addEventListener('message',handleChannelParentMessageEvent,false);}else this.postMessage=bind(window.parent,window.parent.handleChanneliFrameMessage);setTimeout(function(){this.sendParentInit();}.bind(this),100);},sendParentInit:function(){this.sendParentMessage({'type':'init'});setTimeout(this.checkParentInit.bind(this),1000);},checkParentInit:function(){if(!this.parentAlive)this.sendParentInit();},sendParentMessage:function(msg){if(this.targetOrigin){this.postMessage(JSON.encode(msg),this.targetOrigin);}else this.postMessage(JSON.encode(msg));},handleParentMessage:function(_L0){this.parentAlive=true;if(_L0.type=='isReady'){this.managerIsReady=_L0.isReady;this.isActionRequest=_L0.isActionRequest;if(this.managerIsReady)if(is_empty(_L0.channels)){this.channels={};this.warn('iframex: got no channels. not sending a request.');}else{var _L1=false;for(var c in _L0.channels)if(!this.channels[c]||_L0.channels[c].currentSeq!=this.channels[c].currentSeq){_L1=true;break;}this.channels=_L0.channels;if(!this.started){setTimeout(this.sendRequest.bind(this),this.startDelay);this.started=true;}else if(this.isReconnecting||_L1){this.debug('iframex: manager ready again. sending new request.');this.isReconnecting=false;this.sendRequest();}}}else if(_L0.type=='isActionRequest')this.isActionRequest=_L0.isActionRequest;},debug:function(msg){},warn:function(msg){if(window.console)if(window.console.error){window.console.error(msg);}else if(window.console.log)window.console.log(msg);},sendRequest:function(){var url='http://'+document.location.host+'/x/'+rand32()+'/';if(this.isActionRequest){url+='true/';this.isActionRequest=false;}else url+='false/';var _L1={};for(var c in this.channels)_L1[encodeURIComponent(c)]=this.channels[c].currentSeq;url+=URI.implodeQuery(_L1);clearTimeout(this.checkAliveTimer);this.requestNum++;this.checkAliveTimer=setTimeout(this.checkAlive.bind(this,this.requestNum),this.checkAliveInterval);var _L3=document.location.host.match('xyzzy')?{ka:'1'}:{};this.request=new AsyncRequest().setHandler(this.onRequestSuccess.bind(this,this.requestNum)).setErrorHandler(this.onRequestError.bind(this,this.requestNum,false)).setTransportErrorHandler(this.onTransportError.bind(this,this.requestNum)).setData(_L3).setMethod('GET').setReadOnly(true).setOption('retries',this.maxRetries).setOption('suppressErrorAlerts',true).setURI(url).setOption('tfbEndpoint',false).send();},_requestIsValid:function(_L0){if(this.isReconnecting||_L0<this.requestNum)return false;if(!this.managerIsReady){this.debug("iframex: channel manager isn't ready, not sending another x request");this.isReconnecting=true;return false;}return true;},checkAlive:function(_L0){this.checkAliveTimer=null;if(!this._requestIsValid(_L0))return;this.warn('iframex: request took too long');if(!this.isIframeReconnecting){this.isIframeReconnecting=true;setTimeout(this.sendRequest.bind(this),this.regularDelay);}else this.reconnect(ChannelRebuildReasons.TooLong);},reconnect:function(_L0){if(this.isReconnecting||!this.managerIsReady)return;this.isReconnecting=true;this.isIframeReconnecting=false;this.warn('iframex: forwarding a shutdown');var msg={type:'shutdown',reason:_L0};this.sendParentMessage({'type':'channelMsg','channel':'all','seq':0,'msg':msg});},onTransportError:function(_L0,_L1){this.debug('iframex: transport error');this.onRequestError(_L0,_L1,true);},onRequestError:function(_L0,_L1,_L2){if(!this._requestIsValid(_L0))return;this.warn('iframex: request error: '+_L1.getErrorDescription());this._onRequestError(ChannelRebuildReasons.AsyncError,_L2);},_onRequestError:function(_L0,_L1){if(_L1&&!this.isIframeReconnecting){this.isIframeReconnecting=true;setTimeout(this.sendRequest.bind(this),this.regularDelay);return;}this.reconnectNum++;if(this.reconnectNum>=this.maxReconnects){this.warn('iframex: too many reconnects.  bailing for good.');var msg={type:'permaShutdown'};this.sendParentMessage({'type':'channelMsg','channel':'all','seq':0,'msg':msg});}else this.reconnect(_L0);},onRequestSuccess:function(_L0,_L1){if(!this._requestIsValid(_L0))return;var _L2=_L1.getPayload();if(_L2.t=='refresh'){this.warn('iframex: got refresh from channel');this._onRequestError(ChannelRebuildReasons.Refresh);return;}else if(_L2.t=='refreshDelay'){this.warn('iframex: got refreshDelay from channel');this._onRequestError(ChannelRebuildReasons.RefreshDelay);return;}else if(_L2.t=='continue'){}else if(_L2.t=='msg'){var _L3=_L2.c;for(var i=0;i<_L2.ms.length;i++){var msg=_L2.ms[i];var seq=this.channels[_L3].currentSeq;this.sendParentMessage({'type':'channelMsg','channel':_L3,'seq':seq,'msg':msg});this.channels[_L3].currentSeq++;}}else{this.warn('iframex: got unexpected response from channel');this._onRequestError(ChannelRebuildReasons.AsyncError,true);return;}this.reconnectNum=0;this.isIframeReconnecting=false;setTimeout(this.sendRequest.bind(this),this.regularDelay);}};function channelIFrameStartFn(){if(window.location.pathname.startsWith("/iframe/")){document.domain='facebook.com';window.channelUplink=new fbChannelUplink();}}onloadRegister(channelIFrameStartFn);
function ChatNotificationList(){this.alertIds=[];this.alertsObj={};this.contentRoot=null;this.noItemsElement=null;this.ITEM_UNREAD_CLASS='notif_unread';this.ITEM_TAG='div';this.ITEM_CLASS='notification';this.NO_ITEMS_ID='presence_no_notifications';this.NO_ITEMS_CLASS='no_notifications';}ChatNotificationList.prototype={setUnreadItemClass:function(_L0){this.ITEM_UNREAD_CLASS=_L0;},setItemTag:function(_L0){this.ITEM_TAG=_L0;},setItemClass:function(_L0){this.ITEM_CLASS=_L0;},setNoItemsClass:function(_L0){this.NO_ITEMS_CLASS=_L0;},getAlertIds:function(){return this.alertIds;},fromDom:function(_L0){this.contentRoot=_L0;var _L1=this.ITEM_TAG;if(this.ITEM_CLASS)_L1+='.'+this.ITEM_CLASS;var _L2=DOM.scry(this.contentRoot,_L1);for(var i=0;i<_L2.length;i++){var _L4=_L2[i];var _L5=parseInt(_L4.getAttribute('id').replace('notification_',''),10);this.alertIds.push(_L5);this.alertsObj[_L5]=_L4;}this.alertIds.sort(function(a,b){return b-a;});},add:function(_L0,_L1,_L2){_L0=parseInt(_L0,10);if(this.alertsObj[_L0]){if(!_L2){Util.log('Inserting notification '+_L0+' when it already exists');return false;}else DOM.replace(this.alertsObj[_L0],HTML(_L1));}else{var _L3=-1,_L4=-1;for(var i=0;i<this.alertIds.length;i++)if(this.alertIds[i]<_L0){_L3=this.alertIds[i];_L4=i;break;}if(-1==_L3){DOM.appendContent(this.contentRoot,HTML(_L1));this.alertIds.push(_L0);}else{DOM.insertBefore(HTML(_L1),this.alertsObj[_L3]);this.alertIds.splice(_L4,0,_L0);}}this.alertsObj[_L0]=$('notification_'+_L0);if(1==this.size())hide(this.NO_ITEMS_ID);return true;},hideApp:function(_L0,_L1){var _L2=DOM.scry(this.content,this.ITEM_TAG+'.notif_'+_L0);for(var i=0;i<_L2.length;i++)if(_L1){animation(_L2[i]).to('opacity',0).to('height',0).blind().duration(1000).hide().go();}else hide(_L2[i]);if(this.isEmpty())this.showNoNotifications();return _L2.length;},showNoNotifications:function(){if(null==this.noItemsElement)this.noItemsElement=ge(this.NO_ITEMS_ID);if(null==this.noItemsElement){this.noItemsElement=$N(this.ITEM_TAG,{'id':this.NO_ITEMS_ID,'className':this.NO_ITEMS_CLASS},_tx("No new notifications."));DOM.appendContent(this.contentRoot,this.noItemsElement);}show(this.NO_ITEMS_ID);},remove:function(_L0){var _L1=this.alertsObj[_L0];if(!this.alertsObj[_L0]){Util.log('Removing notification '+_L0+'that doesn\'t exist');return false;}DOM.remove(_L1);delete this.alertsObj[_L0];this.alertIds.splice(this.alertIds.indexOf(_L0),1);if(this.isEmpty())this.showNoNotifications();return true;},getUnreadIds:function(_L0){var _L1=[];_L0=_L0||this.alertIds;for(var i=0;i<_L0.length;i++){var _L3=this.alertsObj[_L0[i]];if(_L3&&CSS.hasClass(_L3,this.ITEM_UNREAD_CLASS))_L1.push(_L0[i]);}return _L1;},markRead:function(_L0){for(var i=0;i<_L0.length;i++){var _L2=this.alertsObj[_L0[i]];animation(_L2).duration(1500).checkpoint().to('backgroundColor','#FFFFFF').duration(2250).ondone(CSS.removeClass.bind(null,_L2,this.ITEM_UNREAD_CLASS)).go();}return 0!=_L0.length;},addMany:function(_L0){var _L1=0;if('object'==typeof _L0&&!is_empty(_L0))for(var _L2 in _L0)if(this.add(_L2,_L0[_L2]))_L1++;if(0==_L1&&this.isEmpty()){this.showNoNotifications();}else hide(this.NO_ITEMS_ID);return _L1;},isEmpty:function(){return 0==this.size();},size:function(){return this.alertIds.length;}};function ChatNotifications(_L0,_L1,_L2,_L3,_L4,_L5){this.count=_L0;this.countNew=_L1;this.updateTime=_L2;this.user=presence.user;this.app_names=_L3;this.latest_notif_time=_L4;this.latest_read_notif_time=_L5;this.wrapperID='presence_notifications';this.contentID='presence_notifications_content';this.navInboxID='nav_inbox';this.timeElement='span.time';this.alertList=new ChatNotificationList();this._init();}ChatNotifications.UPDATER_NAME='notifications';ChatNotifications.showReportDialog=function(_L0,_L1,_L2,_L3){if(!Dialog){var _L4=this.showReportDialog.bind(this,_L0,_L1,_L2,_L3);Bootloader.loadComponent('dialog',_L4);return;}var _L5={name:'hide',label:_tx("Hide all"),handler:_L1};var _L6={name:'report',label:_tx("Report Spam"),handler:_L2};var _L7={};copy_properties(_L7,Dialog.CANCEL);_L7.handler=_L3||bagofholding;new Dialog().setTitle(_tx("Do you want to hide all notifications from {application-name}?",{'application-name':_L0})).setBody(_tx("This will hide all notifications from this application.")).setButtons([_L5,_L6,_L7]).setModal().show();};ChatNotifications.markAppNotificationSpam=function(_L0,_L1,_L2){var _L3={app_id:_L0,collapse:1,type:_L1};if(_L2)_L3.spam=1;new AsyncSignal('/ajax/notifications.php',_L3).send();};ChatNotifications.prototype={_init:function(){this.cookieName='notifications_'+this.user;this.beepsExpiredToken=null;this.appHideCache=[];this.updateCheckCount=0;this.wrapper=ge(this.wrapperID);this.content=ge(this.contentID);this.navInbox=ge(this.navInboxID);this.countSpan=ge('presence_notifications_count');this.alertList.fromDom(this.content);this._updateCount();Arbiter.subscribe(PresenceMessage.getArbiterMessageType('notification'),this._handleNotificationMsg.bind(this));Arbiter.subscribe(PresenceMessage.getArbiterMessageType('notifications_read'),this._handleNotificationsReadMsg.bind(this));presenceUpdater.register(ChatNotifications.UPDATER_NAME,this._checkUpdater.bind(this),this._onUpdaterResponse.bind(this),this._onUpdaterError.bind(this),this._onUpdaterError.bind(this));},notifyRead:function(_L0){var _L1=null;if(_L0)_L1={alert_ids:_L0};AsyncRequest.pingURI('/ajax/presence/notifications_read.php',_L1);},markRead:function(_L0,_L1,_L2){if(this.countNew==0)return;_L1=_L1||this.alertList.getUnreadIds();this.countNew=_L2?_L2:0;this._updateCount();if(!_L0)this.notifyRead(_L1);this.alertList.markRead(_L1);},requiresUpdate:function(_L0,_L1,_L2){if(!buddyList._checkUpdater(_L0,{},_L2))return false;if(_L1&&undefined!=_L1[ChatNotifications.UPDATER_NAME])return _L1[ChatNotifications.UPDATER_NAME];return _L2||((100/(this.updateCheckCount+1))<=presence.sitevars.NOTIFICATIONS_PIGGYBACK_PERCENTAGE);},_checkUpdater:function(_L0,_L1,_L2){if(!buddyList._checkUpdater(_L0,{},_L2))return false;if(this.requiresUpdate(_L0,{},_L2)){this.updateCheckCount=0;_L1['notif_latest']=this.latest_notif_time;_L1['notif_latest_read']=this.latest_read_notif_time;_L1[ChatNotifications.UPDATER_NAME]=1;return true;}else{this.updateCheckCount++;_L1[ChatNotifications.UPDATER_NAME]=0;}return false;},_updateInboxMarkup:function(_L0,_L1){if(this.navInbox&&_L0!=null)CounterDisplay.setCount('messages_unread',_L0);var _L2=ge('fb_menu_inbox_dropdown');if(_L2&&_L1)_L2.setContent(HTML(_L1));},_updateInboxUnseenCount:function(_L0){return;},_onUpdaterResponse:function(_L0,_L1){this._updateInboxMarkup(_L0.inboxCount,_L0.inboxDropdownMarkup);this._updateInboxUnseenCount(_L0.inboxUnseen);if(!_L0.no_change){if(this.count!=_L0.count){this.count=_L0.count;presence.contentChanged(this.contentID);}this.updateTime=_L1;this.latest_notif_time=_L0.latest_notif;this.latest_read_notif_time=_L0.latest_read_notif;this._addAppNames(_L0.app_names);this.countNew=_L0.countNew;this._updateDisplayDelayed();this.alertList.addMany(_L0.markup_map);Arbiter.inform(Arbiter.NEW_NOTIFICATIONS,_L0);}},_updateDisplayDelayed:function(){if(typeof Beeper!='undefined'){this.beepsExpiredToken=Arbiter.subscribe(Arbiter.BEEPS_EXPIRED,this._updateDisplay.bind(this));}else this._updateDisplay();},_updateDisplay:function(){if(!this.content)return;for(var i=0;i<this.appHideCache.length;i++)this.hideNotifications(this.appHideCache[i],true);this.appHideCache=[];this._updateCount();if(this.beepsExpiredToken)Arbiter.unsubscribe(this.beepsExpiredToken);},_onUpdaterError:function(_L0){},_updateCount:function(){if(this.countSpan)this.countSpan.innerHTML=this.countNew?'<strong>'+this.countNew+'</strong>':'';},hideNotifications:function(_L0,_L1){var _L2=this.alertList.hideApp(_L0,!_L1);this.count-=_L2;presence.contentChanged(this.contentID);_L1||this.appHideCache.push(_L0);},showHideDialog:function(_L0,_L1,_L2){var _L3=function(_L6){this.hideNotifications(_L1);var _L7=('report'==_L6);ChatNotifications.markAppNotificationSpam(_L1,_L2,_L7);(typeof(toggleType)=='function')&&(typeof(hidden)!='undefined')&&(!hidden[_L1])&&toggleType(_L1,true,null,false,true,presence.user,false,_L2);};var _L3=bind(this,_L3,'hide');var _L4=bind(this,_L3,'report');var _L5=this.app_names[_L1]||_L1;ChatNotifications.showReportDialog(_L5,_L3,_L4);return false;},loadTab:function(){if(!this.fetch())this.markRead();},fetch:function(){if(this.alertList.size()>=5){this.fetch=bagofholding;$('presence_notifications_loading').remove();return false;}new AsyncRequest().setURI('/ajax/presence/notifications_read.php').setStatusElement($('presence_notifications_loading')).setData({render:1}).setMethod('POST').setHandler(function(_L0){var _L1=_L0.getPayload();var _L2=_L1.markup_map;this.alertList.addMany(_L2);this._addAppNames(_L1.app_names);$('presence_notifications_loading').remove();this.markRead(true);this.fetch=bagofholding;}.bind(this)).send();return true;},_addAppNames:function(_L0){_L0&&copy_properties(this.app_names,_L0);},_mergeNotification:function(_L0,_L1,_L2,_L3){if(!this.alertList.add(_L0,_L1))return;this.count++;if(_L2)this.countNew++;this._updateCount();_L3&&this._addAppNames(_L3);if(presence.focusedTab=='presence_notifications_tab')this._merged_mouseover_handler=this.content.listen('mouseover',(function(){this._merged_mouseover_handler.remove();this.markRead();}).bind(this));},_handleNotificationMsg:function(_L0,_L1){var obj=_L1.obj;if(obj.markup){this._mergeNotification(obj.alert_id,obj.markup,obj.unread,obj.app_names);}else presenceUpdater.runHandler('notifications');},_handleNotificationsReadMsg:function(_L0,_L1){var obj=_L1.obj;if(typeof Beeper!='undefined')Beeper.getInstance().markRead(true,obj.alert_ids);this.markRead(true,obj.alert_ids,obj.num_unread);}};

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