/* Copyright 2009 FriendFeed */

(function(A){A.fn.bgIframe=A.fn.bgiframe=function(C){if(A.browser.msie&&/6.0/.test(navigator.userAgent)){C=A.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:true,src:"javascript:false;"},C||{});var D=function(E){return E&&E.constructor==Number?E+"px":E},B='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+C.src+'"style="display:block;position:absolute;z-index:-1;'+(C.opacity!==false?"filter:Alpha(Opacity='0');":"")+"top:"+(C.top=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":D(C.top))+";left:"+(C.left=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":D(C.left))+";width:"+(C.width=="auto"?"expression(this.parentNode.offsetWidth+'px')":D(C.width))+";height:"+(C.height=="auto"?"expression(this.parentNode.offsetHeight+'px')":D(C.height))+';"/>';return this.each(function(){if(A("> iframe.bgiframe",this).length==0){this.insertBefore(document.createElement(B),this.firstChild)}})}return this}})(jQuery);(function(B){B.dimensions={version:"@VERSION"};B.each(["Height","Width"],function(D,C){B.fn["inner"+C]=function(){if(!this[0]){return }var F=C=="Height"?"Top":"Left",E=C=="Height"?"Bottom":"Right";return this[C.toLowerCase()]()+A(this,"padding"+F)+A(this,"padding"+E)};B.fn["outer"+C]=function(F){if(!this[0]){return }var G=C=="Height"?"Top":"Left",E=C=="Height"?"Bottom":"Right";F=B.extend({margin:false},F||{});return this[C.toLowerCase()]()+A(this,"border"+G+"Width")+A(this,"border"+E+"Width")+A(this,"padding"+G)+A(this,"padding"+E)+(F.margin?(A(this,"margin"+G)+A(this,"margin"+E)):0)}});B.each(["Left","Top"],function(D,C){B.fn["scroll"+C]=function(E){if(!this[0]){return }return E!=undefined?this.each(function(){this==window||this==document?window.scrollTo(C=="Left"?E:B(window)["scrollLeft"](),C=="Top"?E:B(window)["scrollTop"]()):this["scroll"+C]=E}):this[0]==window||this[0]==document?self[(C=="Left"?"pageXOffset":"pageYOffset")]||B.boxModel&&document.documentElement["scroll"+C]||document.body["scroll"+C]:this[0]["scroll"+C]}});B.fn.extend({position:function(){var H=0,G=0,F=this[0],I,C,E,D;if(F){E=this.offsetParent();I=this.offset();C=E.offset();I.top-=A(F,"marginTop");I.left-=A(F,"marginLeft");C.top+=A(E,"borderTopWidth");C.left+=A(E,"borderLeftWidth");D={top:I.top-C.top,left:I.left-C.left}}return D},offsetParent:function(){var C=this[0].offsetParent;while(C&&(!/^body|html$/i.test(C.tagName)&&B.css(C,"position")=="static")){C=C.offsetParent}return B(C)}});var A=function(C,D){return parseInt(B.css(C.jquery?C[0]:C,D))||0}})(jQuery);(function(A){A.fn.extend({autocomplete:function(B,C){var D=typeof B=="string";C=A.extend({},A.Autocompleter.defaults,{url:D?B:null,data:D?null:B,delay:D?A.Autocompleter.defaults.delay:10,max:C&&!C.scroll?10:150},C);C.highlight=C.highlight||function(E){return E};return this.each(function(){new A.Autocompleter(this,C)})},result:function(B){return this.bind("result",B)},deletelast:function(B){return this.bind("deletelast",B)},search:function(B){return this.trigger("search",[B])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(B){return this.trigger("setOptions",[B])},unautocomplete:function(){return this.trigger("unautocomplete")}});A.Autocompleter=function(L,G){var C={UP:38,DOWN:40,DEL:46,BACKSPACE:8,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34};var B=A(L).attr("autocomplete","off").addClass(G.inputClass);var J;var P="";var M=A.Autocompleter.Cache(G);var E=0;var U;var W={mouseDownOnSelect:false};var R=A.Autocompleter.Select(G,L,D,W);B.keydown(function(X){E=1;U=X.keyCode;switch(X.keyCode){case C.UP:X.preventDefault();if(R.visible()){R.prev()}else{T(0,true)}break;case C.DOWN:X.preventDefault();if(R.visible()){R.next()}else{T(0,true)}break;case C.PAGEUP:X.preventDefault();if(R.visible()){R.pageUp()}else{T(0,true)}break;case C.PAGEDOWN:X.preventDefault();if(R.visible()){R.pageDown()}else{T(0,true)}break;case (G.multiple||G.fbMode)&&A.trim(G.multipleSeparator)==","&&C.COMMA:case C.TAB:if(G.requireExplicit){X.preventDefault();R.next();break}case C.RETURN:if(D()){if(!G.multiple){B.blur()}X.preventDefault()}if(!G.requireExplicit){B.val("")}break;case C.ESC:R.hide();break;case C.BACKSPACE:if(G.fbMode&&!B.val()){B.trigger("deletelast");break}default:clearTimeout(J);J=setTimeout(T,G.delay);break}}).keypress(function(){clearTimeout(J);J=setTimeout(T,G.delay)}).focus(function(){E++}).blur(function(){if(!G.requireExplicit){setTimeout(function(){if(B.val()){B.val("")}},10)}E=0;if(!W.mouseDownOnSelect){S()}}).click(function(){if(E++>1&&!R.visible()){T(0,true)}}).bind("search",function(){var X=(arguments.length>1)?arguments[1]:null;function Y(c,b){var Z;if(b&&b.length){for(var a=0;a<b.length;a++){if(b[a].result.toLowerCase()==c.toLowerCase()){Z=b[a];break}}}if(typeof X=="function"){X(Z)}else{B.trigger("result",Z&&[Z.data,Z.value])}}A.each(H(B.val()),function(Z,a){F(a,Y,Y)})}).bind("flushCache",function(){M.flush()}).bind("setOptions",function(){A.extend(G,arguments[1]);if("data" in arguments[1]){M.populate()}}).bind("unautocomplete",function(){R.unbind();B.unbind()});function D(){var Y=R.selected();var X;if(!Y){if(!G.fbMode){return false}var a=A.trim(B.val());if(a.indexOf("@")>0){Y={value:a,data:[a,null,true],result:a}}else{return false}}X=Y.result;P=X;if(G.multiple){var Z=H(B.val());if(Z.length>1){X=Z.slice(0,Z.length-1).join(G.multipleSeparator)+G.multipleSeparator+X}X+=G.multipleSeparator}if(!G.requireExplicit){}V();B.trigger("result",[Y.data,Y.value]);return true}function T(Z,Y){if(U==C.DEL){R.hide();return }var X=B.val();if(!Y&&X==P){return }P=X;X=I(X);if(X.length>=G.minChars){B.addClass(G.loadingClass);if(!G.matchCase){X=X.toLowerCase()}F(X,K,V)}else{N();R.hide()}}function H(Y){if(!Y){return[""]}var Z=Y.split(A.trim(G.multipleSeparator));var X=[];A.each(Z,function(a,b){if(A.trim(b)){X[a]=A.trim(b)}});return X}function I(X){if(!G.multiple){return X}var Y=H(X);return Y[Y.length-1]}function Q(X,Y){if(G.autoFill&&(I(B.val()).toLowerCase()==X.toLowerCase())&&U!=8){B.val(B.val()+Y.substring(I(P).length));A.Autocompleter.Selection(L,P.length,P.length+Y.length)}}function S(){clearTimeout(J);J=setTimeout(V,200)}function V(){R.hide();clearTimeout(J);N();if(G.mustMatch){B.search(function(X){if(!X){B.val("")}})}}function K(Y,X){if(X&&X.length&&E){N();R.display(X,Y);Q(Y,X[0].value);R.show()}else{V()}}function F(Y,a,X){if(!G.matchCase){Y=Y.toLowerCase()}var Z=M.load(Y);if(Z&&Z.length){a(Y,Z)}else{if((typeof G.url=="string")&&(G.url.length>0)){var b={};A.each(G.extraParams,function(c,d){b[c]=typeof d=="function"?d():d});A.ajax({mode:"abort",port:"autocomplete"+L.name,dataType:G.dataType,url:G.url,data:A.extend({q:I(Y),limit:G.max},b),success:function(d){var c=G.parse&&G.parse(d)||O(d);M.add(Y,c);a(Y,c)}})}else{X(Y)}}}function O(a){var X=[];var Z=a.split("\n");for(var Y=0;Y<Z.length;Y++){var b=A.trim(Z[Y]);if(b){b=b.split("|");X[X.length]={data:b,value:b[0],result:G.formatResult&&G.formatResult(b,b[0])||b[0]}}}return X}function N(){B.removeClass(G.loadingClass)}};A.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(B){return B[0]},autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(C,B){return htmlEscape(C).replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+B.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:true,scrollHeight:180,attachTo:"body",requireExplicit:false,permaResults:function(B){return[]}};A.Autocompleter.Cache=function(C){var F={};var D=0;function H(K,J){if(!C.matchCase){K=K.toLowerCase()}var I=K.indexOf(J);if(I==-1){return false}return I==0||(C.matchContains&&(K[I-1]==" "||K[I-1]=="("))}function G(J,I){if(D>C.cacheLength){B()}if(!F[J]){D++}F[J]=I}function E(){if(!C.data){return false}var J={},I=0;if(!C.url){C.cacheLength=1}J[""]=[];for(var L=0,K=C.data.length;L<K;L++){var O=C.data[L];O=(typeof O=="string")?[O]:O;var N=C.formatItem(O,L+1,C.data.length);if(N===false){continue}var M=N.charAt(0).toLowerCase();if(!J[M]){J[M]=[]}var P={value:N,data:O,result:C.formatResult&&C.formatResult(O)||N};J[M].push(P);J[""].push(P)}A.each(J,function(Q,R){C.cacheLength++;G(Q,R)})}setTimeout(E,25);function B(){F={};D=0}return{flush:B,add:G,populate:E,load:function(M){if(!C.cacheLength||!D){return null}var K=[];var I=C.permaResults(M);for(var J=0;J<I.length;J++){var L=I[J];K.push({data:[L],value:""})}if(!C.url&&C.matchContains){var N=F[""];A.each(N,function(P,O){if(H(O.value,M)){K.push(O)}});return K}else{if(F[M]){return F[M]}else{if(C.matchSubset){for(var J=M.length-1;J>=C.minChars;J--){var N=F[M.substr(0,J)];if(N){var K=[];A.each(N,function(P,O){if(H(O.value,M)){K[K.length]=O}});return K}}}}}return null}}};A.Autocompleter.Select=function(E,J,L,P){var I={ACTIVE:"ac_over"};var K,F=-1,R,M="",S=true,C,O;function N(){if(!S){return }C=A("<div/>").hide().addClass(E.resultsClass).css("position","absolute").appendTo(E.attachTo);O=A("<ul>").appendTo(C).mouseover(function(T){if(Q(T).nodeName&&Q(T).nodeName.toUpperCase()=="LI"){F=A("li",O).removeClass(I.ACTIVE).index(Q(T));A(Q(T)).addClass(I.ACTIVE)}}).click(function(T){A(Q(T)).addClass(I.ACTIVE);L();J.focus();return false}).mousedown(function(){P.mouseDownOnSelect=true}).mouseup(function(){P.mouseDownOnSelect=false});if(E.width>0){C.css("width",E.width)}S=false}function Q(U){var T=U.target;while(T&&T.tagName!="LI"){T=T.parentNode}if(!T){return[]}return T}function H(T){K.slice(F,F+1).removeClass();G(T);var V=K.slice(F,F+1).addClass(I.ACTIVE);if(E.scroll){var U=0;K.slice(0,F).each(function(){U+=this.offsetHeight});if((U+V[0].offsetHeight-O.scrollTop())>O[0].clientHeight){O.scrollTop(U+V[0].offsetHeight-O.innerHeight())}else{if(U<O.scrollTop()){O.scrollTop(U)}}}}function G(T){F+=T;if(F<0){F=K.size()-1}else{if(F>=K.size()){F=0}}}function B(T){return E.max&&E.max<T?E.max:T}function D(){O.empty();var U=B(R.length);for(var V=0;V<U;V++){if(!R[V]){continue}var W=E.formatItem(R[V].data,V+1,U,R[V].value,M);if(W===false){continue}var T=A("<li>").html(E.highlight(W,M,R[V].data)).addClass(V%2==0?"ac_event":"ac_odd").appendTo(O)[0];A.data(T,"ac_data",R[V])}K=O.find("li");if(E.selectFirst){K.slice(0,1).addClass(I.ACTIVE);F=0}O.bgiframe()}return{display:function(U,T){N();R=U;M=T;D()},next:function(){H(1)},prev:function(){H(-1)},pageUp:function(){if(F!=0&&F-8<0){H(-F)}else{H(-8)}},pageDown:function(){if(F!=K.size()-1&&F+8>K.size()){H(K.size()-1-F)}else{H(8)}},hide:function(){C&&C.hide();F=-1},visible:function(){return C&&C.is(":visible")},current:function(){return this.visible()&&(K.filter("."+I.ACTIVE)[0]||E.selectFirst&&K[0])},show:function(){var V=A(J).offset();C.css({width:typeof E.width=="string"||E.width>0?E.width:A(J).width(),top:V.top+J.offsetHeight,left:V.left}).show();if(E.scroll){O.scrollTop(0);O.css({maxHeight:E.scrollHeight,overflow:"auto"});if(A.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var T=0;K.each(function(){T+=this.offsetHeight});var U=T>E.scrollHeight;O.css("height",U?E.scrollHeight:T);if(!U){K.width(O.width()-parseInt(K.css("padding-left"))-parseInt(K.css("padding-right")))}}}},selected:function(){var T=K&&K.filter("."+I.ACTIVE).removeClass(I.ACTIVE);return T&&T.length&&T.is(":visible")&&A.data(T[0],"ac_data")},unbind:function(){C&&C.remove()}}};A.Autocompleter.Selection=function(D,E,C){if(D.createTextRange){var B=D.createTextRange();B.collapse(true);B.moveStart("character",E);B.moveEnd("character",C);B.select()}else{if(D.setSelectionRange){D.setSelectionRange(E,C)}else{if(D.selectionStart){D.selectionStart=E;D.selectionEnd=C}}}D.focus()}})(jQuery);var clickHandlers={};var mouseoverHandlers={};var mouseoutHandlers={};var kSlideTime=200;var kEntrySlideTime=400;var kCommentSlideTime=400;var kEntryReorderTime=500;$(function(){if(window.recordTime){recordTime("start core init")}bindEvents("click");if(!window.gIphoneMode){bindEvents("mouseover");bindEvents("mouseout")}$.event.remove(window,"unload");if(!window.gIphoneMode){setupKBShortcuts();$("body").mousedown(function(D){for(var C=D.target;C;C=C.parentNode){if(C.tagName=="A"){if((document.location.href.split("#")[0]+"#")==C.href){return }savePageHtml();realtime.poll(2500);if(C.className.match(/l_/)){return }if(window.gNewWin){var E=C.href.indexOf("//"+document.location.host+"/");if(E==-1||E>6){C.target="_blank"}}return }}})}delayHideAlert();if(window.fileUploader&&!window.gIphoneMode){setTimeout(function(){fileUploader.load()},200)}var B=(new Date()).getTimezoneOffset();try{document.cookie="T="+B+"; expires=Tue, 31 Dec 2030 20:47:11 UTC; path=/"}catch(A){}if(window.gFacebookParams){window.gFacebookParams+="&tz="+B;$("body").submit(function(D){var C=D.target;if(isFriendFeed(C.action)){C.action=addFBParams(C.action);C.target="_self"}})}gKillClick=false;if(window.recordTime){recordTime("about to httpCheck")}httpCheck()});var delayTimeout=null;function delayHideAlert(){var B=$("#alertmessage");if(B.length>0){if(delayTimeout){clearTimeout(delayTimeout)}var A=B.find("a").length>0?8000:5000;delayTimeout=setTimeout(function(){delayTimeout=null;B.slideUp(undefined,function(){B.remove()})},A)}}function showErrorMessage(A){$("#alertmessage").remove();var B=$('<div id="alertmessage"><div id="errormessage">'+htmlEscape(A)+'</div><div style="height:23px"></div>');B.hide();$("#body .box-body").prepend(B);B.slideDown(function(){delayHideAlert()})}function bindEvents(A){var B=window[A+"Handlers"];$("body")[A](function(F){if(A=="click"&&handleFBClick(F)){return false}for(var E=F.target;E;E=E.parentNode){if(!E.className){continue}var C=E.className.match(/\bl_([\w]+)\b/);if(!C){continue}var D=B[C[1]];if(!D){continue}if(A=="click"){$(E).blur();return D($(E),F)?undefined:false}else{D($(E),F);return }}if(!window.gIphoneMode&&A=="click"){popup.hide();$.closePopupMenu()}})}function httpCheck(){if(!location.hostname.endsWith("friendfeed.com")){return }var A=window.name&&window.name.startsWith("friendfeedhttps");if(location.pathname.startsWith("/account/")){if(A||location.protocol=="http:"){return }$("a").each(function(){var B=$(this);var C=B.attr("href");if(!C||C[0]!="/"||C.startsWith("/account/")){return }B.attr("href","http://"+location.host+C)})}else{if(location.protocol=="https:"){if(A||location.pathname.startsWith("/settings/")||location.pathname.startsWith("/share/")){return }if(document.referrer&&document.referrer.match(/^https:\/\/friendfeed.com\/(account|settings)\//)){document.location="http"+location.href.substring(5)}else{window.name="friendfeedhttps"+Math.random()}}else{if(A){window.name="not"+window.name}}}}function isFriendFeed(A){return A.charAt(0)=="/"||A.match(new RegExp("^https?://"+document.location.host+"/"))}function addFBParams(A){if(!window.gFacebookParams||!isFriendFeed(A)){return A}return A+(A.indexOf("?")!=-1?"&":"?")+gFacebookParams}function handleFBClick(C){if(!window.gFacebookParams){return }var B=C.target;for(;;B=B.parentNode){if(!B){return }if(B.tagName=="A"){break}}var A=B.href;if($(B).hasClass("noframe")){B.target="_blank"}if(!A||A.indexOf("#")!=-1||!isFriendFeed(A)){return }if(B.onclick||$(B).hasClass("noframe")){return }document.location.href=addFBParams(A);return true}function pageLoadId(){return(new Date(document.lastModified)).getTime()}function maybeRestoreHtml(){var A=$("input.savedhtml").val();var C=$("input.savedhash").val();var B=$("input.savedloadid").val();if(A&&C&&(!pageLoadId()||B==pageLoadId())){dprint("Restoring saved HTML");$("#feed").html(A);window.gFeedSpec.hash=C;realtime.token=$("input.savedtoken").val()}}function savePageHtml(){if(window.gFeedSpec){$("input.savedhtml").val($("#feed").html());$("input.savedhash").val(window.gFeedSpec.hash);$("input.savedloadid").val(pageLoadId());$("input.savedtoken").val(realtime.token)}}function submitForm(D,B){var C=$('<form method="post"></form>');C.attr("action",addFBParams(D));C.target="_self";if(!B.next){B.next=location.href}B.at=getCookie("AT");B._nano=1;for(var A in B){C.append($('<input type="hidden" name="'+A+'"/>').val(B[A]))}$("body").append(C);C.submit()}function setLocale(A){submitForm("/a/setlocale",{locale:A})}function getCookie(A){var B=document.cookie.match("\\b"+A+"=([^;]*)\\b");return B?B[1]:undefined}if(!String.prototype.startsWith){String.prototype.startsWith=function(A){return this.lastIndexOf(A,0)!=-1}}if(!String.prototype.endsWith){String.prototype.endsWith=function(A){return this.indexOf(A,this.length-A.length)!=-1}}function showSpinner(B,A){if(B&&B.length>0){hideSpinner();var E=B.offset();var C=B.width();var D=A?E.left-21:E.left+C+5;loader=$('<div id="loadingspinner" style="width: 16px; height: 16px; position: absolute; top: '+E.top+"px; left: "+D+'px; z-index:200000"><img src="/static/images/loading.gif?v=2767" width="16" height="16" alt="'+'Loading...'+'"/></div>');$(document.body).append(loader)}}function checkRequired(D,B){var E=true;for(var C=0;C<B.length;C++){var A=D[B[C]];if(!A){continue}if(!A.value||A.className.indexOf("blur")!=-1){$(A).addClass("required");if(E){A.select()}E=false}else{$(A).removeClass("required")}}return E}function hideSpinner(){$("#loadingspinner").remove()}function errorSpinner(B,A){hideSpinner();if(B&&B.length>0){hideSpinner();var F=B.offset();var C=B.width();var D=A?F.left-21:F.left+C+5;var E='Oops, there was a problem! \u003ca href=\u0027%(url)s\u0027\u003eLearn more...\u003c/a\u003e';E=E.replace("%(url)s","/about/help#exclamation");loader=$('<div id="loadingspinner" style="height: 16px; position: absolute; top: '+F.top+"px; left: "+D+'px; z-index:200000; background-color: white;"><img src="/static/images/error.png?v=e4dd" width="16" height="16" style="vertical-align: bottom;" alt="'+'Error'+'" + title="'+E+'"/><span style="padding: 5px; height: 16px;">'+E+"</span></div>");$(document.body).append(loader)}}function shareSubmit(B){var D=[];B.find(".l_tocard").each(function(E,F){var G=$(F).attr("sid");if(G){D.push(G)}});if(D.length==0){B.find(".l_toinput").select().focus();return false}B.find("input[name=streams]").val(D.join(","));fileUploader.addFormInputs(B);var A=B.formToDict();if(!A.title||A.title==B.find("textarea.title").attr("title")){B.find("textarea.title").select().focus();return false}var C=B.find(":submit");if(C.attr("disabled")){return false}C.disable();if(B.find("div.photo").length>0){showSpinner(B.find("div.title"));B.submit();return false}delete A.next;if(B.find("td.cc").is(":hidden")){delete A.sharetwitter}$.postJSON("/a/share",A,function(E){if(E.error){showErrorMessage(E.error);C.enable();return }B.find("textarea").val("").blur().animate({height:"22pt"});B.find("input[type='hidden']").each(function(G,F){if(isMultiFileField(F)){$(F).remove()}});B.find(".thumbnails").slideUp(function(){B.find(".thumbnails").remove()});B.find(".files").slideUp(function(){B.find(".files").empty().show()});B.find(".widgets").slideUp(function(){B.find(".widgets").remove()});B.find(".progress table tr").remove();C.enable();if(B.find("input[name=reshare]").length>0){$.closeDialog();$("body").append('<div class="infomessage sharedmsg">'+'Shared'+"</div>");setTimeout(function(){$(".sharedmsg").remove()},2000)}else{if(E.html){showEntry(E.id,E.html)}shareCollapse()}},B.find("div.title"));return false}function shareFocus(B){var A=$(B.target).parents(".sharebox");A.find("div.to,div.ccbody").slideDown(kSlideTime);A.find(".ccbody").fadeIn();shareSetupToBox(A)}function shareSetupToBox(A){if(A.hasClass("sharesetup")){return }A.addClass("sharesetup");$.postJSON("/a/tocontacts",{},function(B){A.find(".l_tolist").autoCompleteToBox(B.contacts)})}function setupSearchBox(){if(window.gSetupSearch){return }window.gSetupSearch=true;$("#searchbox").unbind("focus keydown",setupSearchBox);$.postJSON("/a/searchcontacts",{},function(A){$("#searchbox").autoCompleteSearchBox(A.contacts)})}function shareCollapse(){var A=$(".sharebox");A.find("div.to,div.ccbody").slideUp(kEntrySlideTime);A.find(".ccbody").fadeOut()}function bind(A,B){if(typeof (B)=="string"){B=A[B]}return function(){return B.apply(A,arguments)}}function dprint(A){if(window.console&&window.console.log){window.console.log(A)}}function dtimer(){return function(){}}function _(A){return A}function now(){return(new Date()).getTime()}function getEntry(A){return $("#e-"+A)}jQuery.postJSON=function(url,data,opt_callback,opt_loadingElement,opt_loadingLeft){if(opt_loadingElement){showSpinner(opt_loadingElement,opt_loadingLeft)}data.at=getCookie("AT");var body=$.param(data);if(window.gFacebookParams&&url.charAt(0)=="/"){body+="&"+window.gFacebookParams}if(window.gIphoneMode){body+="&_iphone=1"}body+="&_nano=1";dprint(url);$.ajax({url:url,data:body,dataType:"text",type:"POST",success:function(response){if(opt_loadingElement){hideSpinner()}if(opt_callback){opt_callback(eval("("+response+")"))}},error:function(response){if(opt_loadingElement){errorSpinner(opt_loadingElement,opt_loadingLeft)}}})};jQuery.fn.formToDict=function(){var A=this.serializeArray();var C={};for(var B=0;B<A.length;B++){C[A[B].name]=A[B].value}return C};jQuery.fn.disable=function(){this.enable(false);return this};jQuery.fn.enable=function(A){if(arguments.length&&!A){this.attr("disabled","disabled")}else{this.removeAttr("disabled")}return this};jQuery.fn.center=function(H,A,E){var B=windowSize();var F=E?{x:0,y:0}:scrollPos();for(var D=0;D<this.length;D++){var G=Math.max(0,B.width-this[D].offsetWidth);var C=Math.max(0,B.height-this[D].offsetHeight);$(this[D]).css({top:F.y+C*(A!==undefined?A:0.5),left:F.x+G*(H!==undefined?H:0.5)})}return this};jQuery.fn.makeExpandable=function(A,E,D){var C=D||"5em";var B=this[0];function F(){setTimeout(function(){if(B.value.indexOf("\n")!=-1||B.scrollTop>0||B.scrollLeft>0||B.scrollHeight>B.offsetHeight){B.style.height=C;if(window.updateFrameSize){window.updateFrameSize()}}},10)}this.keypress(function(G){if(G.keyCode==13&&E){E(this);return false}if(this.value.length>=A&&G.charCode>8&&G.charCode<63200){return false}if(this.style.height!=C){F()}});if(B.value){F()}return this};jQuery.fn.dialog=function(A,E){$.closeDialog();$("object,embed").each(function(){$(this).attr("oldh",$(this).css("height")).css("height","0px")});A=A||0.6;E=E||100000;var C="position:fixed;";if($.browser.msie&&$.browser.version<7){C="position:absolute;"}var B=$('<div class="dialogdiv" style="z-index:'+E+"; width:100%; height:100%; top:0; left:0; "+C+' background-color:black"></div>');B.css("opacity",A);var D=$('<div class="dialogdiv" style="z-index:'+E+"; "+C+'"></div>');D.append(this);B.click($.closeDialog);$([B,D]).appendTo(document.body);D.center(0.5,0.5,true);return this};jQuery.closeDialog=function(){$(".dialogdiv").remove();$("object,embed").each(function(){$(this).css("height",$(this).attr("oldh"))})};clickHandlers.closedialog=jQuery.closeDialog;jQuery.fn.hint=function(){return this.each(function(){var A=$(this);var B=A.attr("title");if(!B){return }A.blur(function(){if(!A.val()||A.val()==B){A.addClass("blur");A.val(B)}});A.focus(function(){if(A.val()==B){A.val("")}A.removeClass("blur")});A.parents("form:first").submit(function(){if(A.val()==B){A.val("");A.removeClass("blur")}});A.blur()})};jQuery.fn.popupMenu=function(B){if($(".popupmenu:visible").attr("menuLink")==B[0]){$.closePopupMenu();return }$.closePopupMenu();var C=B.offset();var A=B.height();this.css({position:"absolute",left:(C.left-4)+"px",top:(C.top+A+3)+"px"});this.appendTo(document.body);this.show();var D=$('<div class="popupshadow"></div>').css({position:"absolute",left:(C.left-3)+"px",top:(C.top+A+4)+"px",width:this.width()+8,height:this.height()+8,backgroundColor:"black",opacity:0.4,zIndex:9999}).appendTo(document.body);this.find("a").not(".menuified").addClass("menuified").click(function(){setTimeout($.closePopupMenu,100)});this.attr("menuLink",B[0])};jQuery.closePopupMenu=function(){$(".popupmenu,.popupshadow").remove()};clickHandlers.expandcomments=function(A){var B=A.parents(".entry");$.postJSON("/a/comments",{entry:B.attr("eid"),boldphrases:window.gBoldPhrases||""},function(D){var F=B.find(".commentform");var C=$("<div/>").html(D.html);var E=C.find(".comments");if(F.length>0){E.append(F)}B.find(".comments").replaceWith(C);C.replaceWith(C.find(".comments"));if(F.length==0&&!B.find(".bottomcomment").length>0){B.addClass("keepbottomcommentlink");B.find(".comments").after(makeBottomCommentLink())}B.addClass("expandedcomments")},A)};clickHandlers.expandlikes=function(A){var B=A.parents(".entry");$.postJSON("/a/likes",{entry:B.attr("eid")},function(C){B.find(".likes").replaceWith(C.html)},A.parents(".lbody"))};clickHandlers.editcomment=function(B){var A=B.parents(".entry");var C=B.parents(".comment:first");$.postJSON("/a/getcomment",{entry:A.attr("eid"),comment:C.attr("cid"),boldphrases:window.gBoldPhrases||""},function(D){var E=$("<span/>");C.addClass("hiddencomment").hide().after(E);makeCommentForm(E,commentEditSubmit,D.raw_html)},B)};clickHandlers.morecomment=function(B){var A=B.parents(".entry");var C=B.parents(".comment:first");$.postJSON("/a/getcomment",{entry:A.attr("eid"),comment:C.attr("cid"),fullhtml:"1"},function(D){B.parents(".cbody").html(D.full_html)},B)};clickHandlers.deletecomment=function(B){var A=B.parents(".entry").attr("eid");var C=B.parents(".comment");$.postJSON("/a/deletecomment",{entry:A,comment:C.attr("cid"),"delete":"1"},function(D){if(B.parents(".pendingcomment").remove().length==0){C.replaceWith(D.html)}},B)};clickHandlers.undeletecomment=function(A){$.postJSON("/a/deletecomment",{entry:A.attr("eid"),comment:A.attr("cid"),"delete":"0"},function(B){comment=$(B.html);comment.not(".owner").addClass("moderated").find(".content").append('(<a href="#" class="l_deletecomment">'+'delete'+"</a>)");A.parents(".deleted").replaceWith(comment)},A)};function requireLogin(C){if(window.gCurrentUserId){return false}var B=C.parents(".entry");var A=B.find(".info a.date").attr("href")||document.location;top.location=(document.cookie.indexOf("HASFF=1")==-1?"/account/create":"/account/login")+"?next="+encodeURIComponent(A);return true}clickHandlers.comment=function(D){if(requireLogin(D)){return }var C=D.parents(".entry");var B=C.find(".commentform");if(B.length>0){B.find("textarea").focus();return }var A=C.find(".comments");if(!A.length){var E=$('<div class="comments"></div>');C.find(".body").append(E);A=E}makeCommentForm(A,commentSubmit,"");if(D.hasClass("remove")){D.parents(".comment").remove()}};clickHandlers.subscribe=function(A){if(window.gIphoneMode){return clickHandlers.simplesubscribe(A)}$.postJSON("/a/friendlistdialog",{stream:A.attr("sid"),code:A.attr("scode")||""},function(B){var C=$(B.html).dialog();C.find("input[type=text]").hint();C.find("input[type=submit]").focus()},A)};clickHandlers.feedremove=function(A){submitForm("/a/feedremove",{stream:A.attr("sid"),user:A.attr("uid")})};clickHandlers.feedadmin=function(A){submitForm("/a/feedmakeadmin",{stream:A.attr("sid"),user:A.attr("uid"),admin:"1"})};clickHandlers.feedunadmin=function(A){submitForm("/a/feedmakeadmin",{stream:A.attr("sid"),user:A.attr("uid")})};clickHandlers.userblock=function(A){$.postJSON("/a/blockuserdialog",{user:A.attr("uid"),next:location.href},function(B){$(B.html).dialog()},A)};clickHandlers.userunblock=function(A){submitForm("/a/setblock",{user:A.attr("uid")})};clickHandlers.directmessage=function(B){if(location.pathname!="/"&&location.pathname!="/filter/direct"){return true}var A=$(".sharebox");A.find(".l_tocard").remove();A.find(".l_tolist .addedit").before('<li class="l_tocard" sid="'+B.attr("nickname")+'"><span>'+htmlEscape(B.attr("name"))+'</span> <img class="l_toremove" src="/static/images/to-delete.png?v=f1c8" title="'+'Delete'+'"/></li>');setCCTwitterHtml();popup.hide();A.find("div.to,.ccbody").show();setScrollTop(0);A.find("textarea").select().focus()};clickHandlers.directdisabled=function(){$('<div id="dialog" style="width:425px"><div>'+'You currently cannot direct message %(name)s. You can only direct message people who are subscribed to you.'.replace("%(name)s",$("h1").text())+'</div><div class="buttons"><button class="l_closedialog">'+'Close'+"</button></div></div>").dialog()};clickHandlers.simplesubscribe=function(A){submitForm("/a/subscribe",{stream:A.attr("sid"),create:A.attr("create")||""})};clickHandlers.unsubscribe=function(A){submitForm("/a/unsubscribe",{stream:A.attr("sid"),code:A.attr("scode")||""})};clickHandlers.share=function(A){if(requireLogin(A)){return }var B=A.parents(".entry");$.postJSON("/a/shareentry",{entry:B.attr("eid")},function(C){$('<div id="dialog"/">').html(C.html).dialog();$("#dialog .sharebox textarea.title").makeExpandable(350,function(D){shareSubmit($(D).parents("form"))}).focus(shareFocus);$("#dialog .sharebox .l_toinput").focus(shareToFocus).blur(shareToBlur);$("#dialog .sharebox textarea.title").focus();setCCTwitterHtml()},A)};clickHandlers.sharelink=function(A){if(requireLogin(A)){return }$.postJSON("/a/sharelink",{link:A.attr("link"),title:A.attr("share")},function(B){$('<div id="dialog"/">').html(B.html).dialog();$("#dialog .sharebox textarea.title").makeExpandable(350,function(C){shareSubmit($(C).parents("form"))}).focus(shareFocus);$("#dialog .sharebox .l_toinput").focus(shareToFocus).blur(shareToBlur);$("#dialog .sharebox textarea.title").focus();setCCTwitterHtml()},A)};function makeBottomCommentLink(){return'<div class="comment bottomcomment"><div class="quote"></div><div class="content"><a href="#" class="l_comment remove">'+'Add comment'+"</a></div>"}function makeCommentForm(E,B,A,H){var G=$('<div class="commentform'+(A?" editform":"")+'"><form method="post"><div class="text"><textarea name="body"></textarea></div><div class="buttons"><span class="ccount"></span><input type="submit" value="'+(H?'Comment':'Post')+'"/>'+(H?"":'<a href="#" class="l_cancelcomment">'+'Cancel'+"</a>")+"</div></form></div>");G.find("form").submit(function(){return B(G.find("form"))});G.find("textarea").val(A);E.append(G);if(E.parents(".entry").find("a.service[href^=http://twitter.com]").length){G.find("form").append('<div class="twitbox"></div>');setTweetBackHtml()}var F=G.parents(".entry");var C=(F.hasClass("author")&&F.find(".comment:first").not(".hiddencomment").length==0)?1000:512;var D=G.find("textarea").makeExpandable(20000,function(){if(!G.find("input[type='submit']").attr("disabled")){G.find("textarea").blur();B(G.find("form"))}});D.keyup(function(){var I=D.val().length;var J="";if(I>C){J="%(len)s characters";J=J.replace("%(len)s",""+I);J="<span>"+J+"</span> "+'(part of your comment may be hidden behind a link)'}G.find(".ccount").html(J)});if(!H){D.focus().keypress();if($.browser.msie){D.select()}}}function setTweetBackHtml(B){var D='<input type="checkbox" id="twitback"/><label for="twitback">';if(gTwitLogin){var C='Also send this comment as an @reply twitter from %(username)s';C=C.replace("%(username)s",gTwitLogin);D+=C+'</label> - <a href="#" class="l_twitlogout">'+'sign out'+"</a>"}else{var C='Also send this comment as an @reply twitter';D+=C+"</label>"}D+='<br/><span class="charcount"></span>';var A=$(".twitbox").html(D).find("input[type=checkbox]");A.click(twitCheckbox);if(B){if(gTwitLogin){A.attr("checked","true");A.each(twitCheckbox)}else{A.removeAttr("checked")}}}function doTwitLogin(){if(gTwitLogin){$.postJSON("/a/twitterdialog",{curpath:location.pathname},function(B){$('<div id="dialog"/>').html(B.html).dialog()},$(".ccbox"))}else{if(location.hostname.endsWith("friendfeed.com")){var A="/account/twitter/redirect";window.open(A,"twitteroauth","width=800,height=400,left=150,top=100,scrollbar=no,resize=no")}else{var A=gHttpsPrefix+"/account/twitterlogin";if(document.location.protocol=="https:"){A+="?https=1"}$('<div id="dialog" class="twitterlogin" style="width:425px"><iframe style="width:425px;height:140px;border-width:0px" frameborder="0" scrolling="no" src="'+A+'"></iframe></div>').dialog()}}}clickHandlers.twitlogin=doTwitLogin;clickHandlers.twitlogout=function(A){$.postJSON("/a/twitterforget",{},function(B){setTwitLogin("")},$(A))};function setTwitLogin(A,B){gTwitLogin=A;setTweetBackHtml(true);setCCTwitterHtml(true);$(".comment textarea").select();if(B){$('<div id="dialog">'+htmlEscape(B)+"</div>").dialog()}}function updateCounter(A,E,B,D){var C=140-A[0].value.length;if(B){C-=2+B.length}if(!D){D='%(count)s remaining'}D=D.replace("%(count)s",""+C);E.html(D);if(C<0){E.addClass("errortext")}else{E.removeClass("errortext")}}function updateLengthCounter(A,C){var B=A[0].value.length;if(B<=0){C.html("")}else{C.html(""+B)}}function twitCheckbox(){if(gTwitLogin){var A=$(this);var C=A.siblings(".charcount");var B=A.parents(".commentform").find("textarea");if(A.attr("checked")){var E=A.parents(".entry").find("a.service[href^='http://twitter.com/']").attr("href").match(/twitter.com\/(.+)$/)[1];updateCounter(B,C,E);var D=setInterval(function(){if(A.attr("checked")){updateCounter(B,C,E)}else{B.unbind("keypress.charcount");clearInterval(D)}},150)}else{C.empty()}}else{doTwitLogin();return false}}function setCCTwitterHtml(A){$(".sharebox").each(function(){var G=$(this);var F=$(".l_tocard.public",G).length>0||$(".l_tocard[sid$=+friends]",G).length>0;$("td.cc",G).toggle(F);$("td.cc input[name=maybetweet]",G).val(F?"1":"0");var H="";if(gTwitLogin){H+='<span class="l_sharetwitter">Twitter</span> (<a href="#" class="l_twitlogin">'+'settings'+"</a>)"}else{H+='<a href="#" class="l_sharetwitter">Twitter</a>'}$(".cclabel",G).html(H);var B=$("input.l_sharetwitter",G);if(A){if(gTwitLogin){B.attr("checked","true")}else{B.removeAttr("checked")}}var D=$(".ccbody",G).find(".ccremaining");if(D.length>0&&B.attr("checked")){var C=G.find("textarea");updateLengthCounter(C,D);var E=setInterval(function(){if(B.attr("checked")){updateLengthCounter(C,D)}else{clearInterval(E)}},150)}else{D.empty()}})}clickHandlers.sharetwitter=function(C){var B=C[0].tagName=="INPUT";if(gTwitLogin){var A=C.parents(".ccbody").find(".l_sharetwitter:checkbox");if(!B){A.each(function(){this.checked=!this.checked})}setCCTwitterHtml();if(B){return true}}else{doTwitLogin()}};clickHandlers.cancelcomment=function(B){var A=B.parents(".entry");B.parents(".commentform").parent().siblings(".hiddencomment").removeClass("hiddencomment").show();B.parents(".commentform").remove();if(A.hasClass("keepbottomcommentlink")&&!A.find(".bottomcomment").length>0){A.find(".comments").after(makeBottomCommentLink())}};clickHandlers.like=function(A){if(requireLogin(A)){return }like(A.parents(".entry"),false,A.parents("div:first").find("a:last"))};clickHandlers.unlike=function(A){like(A.parents(".entry"),true,A.parents("span"))};clickHandlers.editprofile=function(C){var A=C.attr("uid");var B=C.attr("rid");$.postJSON("/a/profiledialog",{stream:A||B,next:location.href},function(D){var E=$("<div/>").html(D.html).dialog();E.find("input[type=text]:first").focus();E.find("textarea[name=description]").makeExpandable(A?161:1000,function(){E.find("form").submit()})},C)};clickHandlers.changepassword=function(A){$.postJSON("/a/changepassworddialog",{next:location.href},function(B){$('<div id="dialog"/>').html(B.html).dialog().find("input[name=oldpassword]").select()},A)};clickHandlers.editpicture=function(A){$.postJSON("/a/picturedialog",{stream:A.attr("sid"),next:location.href},function(B){$(B.html).dialog().find("#pictureupload").focus()},A,true)};clickHandlers.attachphotos=function(B){var E=B.parents(".sharebox");var D=E.find("div.photo").length;var A;if(D>0){A=E.find("div.photo:last")}else{A=E.find("div.title")}E.find("div.photo .l_attachphotos").remove();var C=$('<div class="photo field"><input type="file" name="photo'+D+'" class="photo" size="35"/><span class="add"><a href="#" class="l_attachphotos">'+'add another'+"</a></span></div>");C.insertAfter(A)};function commentSubmit(E){var G=!!E.find(".twitbox input[type=checkbox]").attr("checked");var B=E.parents(".entry").attr("eid");var A=$.extend({entry:B,tweet:G},E.formToDict());if(!A.body){E.find("textarea").select();return false}var D=E.find(".l_cancelcomment");var F=E.find("input[type='submit']");var C=D;if(D.length>0){D.text("")}else{C=F}F.disable();$.postJSON("/a/comment",A,function(H){showComment(B,H.id,H.html,true);if(E.parents(".entry").hasClass("keepbottomcommentlink")&&!E.parents(".entry").find(".bottomcomment").length>0){E.parents(".entry").find(".comments").after(makeBottomCommentLink())}if(!E.parents(".entry").is(".large")){E.parents(".commentform").remove()}else{E.find("textarea").val("").select();E.find(".ccount").html("");F.enable()}},C);return false}function commentEditSubmit(C){var A=C.parents(".commentform").parent().prev(".hiddencomment");var B=$.extend({entry:C.parents(".entry").attr("eid"),comment:A.attr("cid")},C.formToDict());if(!B.body){C.find("textarea").select();return false}C.find(".l_cancelcomment").text("");C.find("input[type='submit']").disable();$.postJSON("/a/editcomment",B,function(D){A.remove();C.parents(".commentform").replaceWith(D.html);C.parents(".commentform").css("background-color","yellow")},C.find(".l_cancelcomment"));return false}function like(B,A,C){$.postJSON("/a/like",{entry:B.attr("eid"),"delete":A||""},function(D){var E=B.find(".likes");if(E.length>0){E.replaceWith(D.html)}else{$(D.html).insertAfter(B.find(".info"))}if(!A){B.find(".like").hide()}else{B.find(".like").show()}},C)}function createFlashObj(E,B,C,D,A){D=D||"1px";A=A||"1px";if(!C){C=document.createElement("div");C.style.width=D;C.style.height=A;document.getElementsByTagName("body")[0].appendChild(C)}if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){C.innerHTML='<embed type="application/x-shockwave-flash" src="'+B+'" width="'+D+'" height="'+A+'" id="'+E+'" name="'+E+'" wmode="transparent" quality="high" menu="false"/>'}else{C.innerHTML='<object id="'+E+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+D+'" height="'+A+'"><param name="movie" value="'+B+'"><param name="wmode" value="transparent"/><param name="quality" value="high"/><param name="menu" value="false"/></object>'}}function scrollPos(){if(self.pageYOffset!==undefined){return{x:self.pageXOffset,y:self.pageYOffset}}var A=document.documentElement;return{x:A.scrollLeft,y:A.scrollTop}}function setScrollTop(A){document.body.scrollTop=A;document.documentElement.scrollTop=A}function windowSize(){var C=document.documentElement;var A=(window.innerWidth||self.innerWidth||(C&&C.clientWidth)||document.body.clientWidth);var B=(window.innerHeight||self.innerHeight||(C&&C.clientHeight)||document.body.clientHeight);return{width:A,height:B}}function saveFriendListChanges(F){var E=F.find("input[name=lists]:checked");var D=[];for(var B=0;B<E.length;B++){D.push(E.get(B).value)}F.find("input[type=submit]").disable();showSpinner(F.find(".l_closedialog"));var C="";var A=$("#newlistname");if($("#fl-new").attr("checked")&&A.val()&&A.val()!=A.attr("title")){C=A.val()}submitForm("/a/updatefriendlists",{lists:D.join(","),stream:F.attr("sid"),code:F.attr("scode"),newlist:C});return false}var fileUploader={id_:"fileuploader",loaded_:false,callbackCounter_:0,startLoaded_:false,uploaded_:{},load:function(){if(navigator.userAgent.indexOf("X11;")!=-1){return }if(!navigator.mimeTypes||!navigator.mimeTypes["application/x-shockwave-flash"]){try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(C){dprint("Flash not supported");return }}var B=$(".sharebox #attachlinks");if(B.length==0){return }if($(".sharebox .l_platformcreate").length>0){return }if(fileUploader.startLoaded_){return }fileUploader.startLoaded_=true;var A=window.gRTL?"right":"left";fileUploader.div=$('<div style="line-height:0;position:absolute;top:0;'+A+':0"/>');B.append(fileUploader.div);createFlashObj(fileUploader.id_,"/static/flash/UploaderLink.swf?v=1297b465",fileUploader.div.get(0),B.get(0).offsetWidth+"px",B.get(0).offsetHeight+"px")},onLoaded:function(){var url="/a/upload?c="+escape(getCookie("U"))+"&fescape=1";var shareBox=$(".sharebox");fileUploader.configure(url,{start:function(file){var progress=$('<tr id="progress'+file.id+'"><td class="name"></td><td><div class="pbar"><div class="percentage" style="width:1%"></div></div></td><td class="loading"><img src="/static/images/share-loading-w.gif?v=65a7" width="16" height="16"/></td><td class="message"></td></tr>');progress.find(".name").text(file.name);shareBox.find("div.progress table").append(progress);shareBox.find("input[type='submit']").disable()},progress:function(file,bytes,total){var progress=$("#progress"+file.id);var percentage=Math.round(100*bytes/total);progress.find(".pbar .percentage").css("width",percentage+"%");if(percentage==100){progress.find(".message").text('processing...')}},complete:function(file,data){$("#progress"+file.id).remove();var response=eval("("+data+")");var linkid=""+file.id;while(linkid.length<3){linkid="0"+linkid}if(response.thumbnail){var thumbnails=shareBox.find(".thumbnails");if(thumbnails.length==0){thumbnails=$('<div class="thumbnails"><table><tr><td></td></tr></table></div>');thumbnails.insertAfter(shareBox.find(".progress"))}linkid="imgup_"+linkid;var thumb=$('<a href="#" id="'+linkid+'" title="'+'Click to remove image'+'"><img src="'+response.thumbnail.url+'" width="'+response.thumbnail.width+'" height="'+response.thumbnail.height+'"/></a>');var others=thumbnails.find("td a");for(var i=0;i<others.length;++i){if(others[i].id>linkid){$(others[i]).before(thumb);break}}if(i==others.length){thumbnails.find("td").append(thumb)}fileUploader.uploaded_[linkid]={url:response.image.url,type:response.image.type,title:response.image.name,thumb:response.thumbnail.url,thumbwidth:response.thumbnail.width,thumbheight:response.thumbnail.height};thumb.click(function(){delete fileUploader.uploaded_[linkid];thumb.remove();return false})}else{linkid="fileup_"+linkid;shareBox.find(".files").append($('<div class="file"><a href="'+response.file.cdnUrl+'" id="'+linkid+'" target="_blank" style="'+response.file.style+'">'+htmlEscape(response.file.name)+'</a> <span class="filesize">'+response.file.sizeText+' - <a href="#" class="l_removefile">'+'Remove'+"</a></span></div>"));fileUploader.uploaded_[linkid]={url:response.file.url,type:response.file.type,name:response.file.name,size:response.file.size}}if(fileUploader.numActiveUploads()==0){shareBox.find("input[type='submit']").enable()}},error:function(file,data){var message='could not upload';if(data){var response=eval("("+data+")");if(response.error){message=response.error}}var progress=$("#progress"+file.id);progress.find(".loading,.pbar").css("display","none");progress.find(".message").html(message);progress.addClass("error");if(fileUploader.numActiveUploads()==0){shareBox.find("input[type='submit']").enable()}}},[{extensions:window.gFileExt||"*.jpg;*.gif;*.png;*.jpeg",description:window.gFileExtDesc||"Images (*.jpg, *.gif, *.png, *.jpeg)"}]);$(".sharebox").append(fileUploader.flash_)},addFormInputs:function(F){var A=F.find(".thumbnails td a");for(var D=0;D<A.length;++D){var B=fileUploader.uploaded_[A[D].id];for(var C in B){$('<input type="hidden" name="image'+D+"_"+C+'"/>').val(B[C]).appendTo(F)}}var E=F.find(".file a");for(var D=0;D<E.length;++D){var B=fileUploader.uploaded_[E[D].id];for(var C in B){$('<input type="hidden" name="file'+D+"_"+C+'"/>').val(B[C]).appendTo(F)}}},available:function(){return(fileUploader.loaded_&&fileUploader.flash_().showFileDialog)},configure:function(C,E,F){var A={};for(var D in E||{}){var B="_fileUploaderCallback"+fileUploader.callbackCounter_++;window[B]=E[D];A[D]=B}fileUploader.flash_().configure(C,A,F)},numActiveUploads:function(){return fileUploader.flash_().numActiveUploads()},flash_:function(){return document.getElementById(fileUploader.id_)}};function isMultiFileField(A){return(A.name.substr(0,5)=="image"||A.name.substr(0,4)=="file")}clickHandlers.play=function(C){var A=C.parent(".container");var D=A.find("div.l_play img");A.parents(".entry").find(".player").remove();if(A.attr("playing")){D.attr("src","/static/images/playbutton.png?v=e094");A.removeAttr("playing")}else{D.attr("src","/static/images/stopbutton.png?v=a009");A.attr("playing",true);var B=A.find("a").attr("play");A.parents(".media").after('<div class="player">'+B+"</div>")}};clickHandlers.audio=function(C){var A=C.parent(".container");A.css("display","none");A.attr("playing",true);var B=A.find("a").attr("play");A.parent().append('<div class="player">'+B+"</div>");return false};clickHandlers.expandmedia=function(A){var B=A.parents(".entry");$.postJSON("/a/expandmedia",{entry:B.attr("eid"),media:1},function(C){A.parents(".entry").find(".media.images").replaceWith(C.html)},A)};clickHandlers.deliveryoptions=function(B){var A=$("#page .subbar");if(A.is(":visible")&&A.find(".deliveryoptions").length>0){A.slideUp(kSlideTime);return }$.postJSON("/a/deliveryoptionsbar",{category:B.attr("category")||"",feed:B.attr("feedid"),next:location.href},function(C){A.html(C.html);A.slideDown(kSlideTime)},B,true)};clickHandlers.subbarclose=function(){$("#page .subbar").slideUp(kSlideTime)};clickHandlers.togglehide=function(A){var B=$("#feed");if(B.find(".hiddenentries:visible").length>0){A.css("backgroundImage","url('/static/images/arrow-collapsed.png?v=3328')");B.find(".hiddenentries").hide()}else{A.css("backgroundImage","url('/static/images/arrow-expanded.png?v=f6a0')");B.find(".hiddenentries").show()}};clickHandlers.hideone=function(B){var A=B.parents(".entry");$.postJSON("/a/hideone",{entry:A.attr("eid"),foaf:A.find(".foaf").attr("uid")||"",hide:"1"},function(C){A.replaceWith(C.html)},B)};clickHandlers.unhideone=function(B){var A=B.attr("eid")||B.parents(".entry").attr("eid");$.postJSON("/a/hideone",{entry:A,hide:"0"},function(C){B.parents(".hidemore").replaceWith(C.html)},B.parents(".graybox"))};clickHandlers.unhide=function(A){submitForm("/a/hiderule",{rules:A.parents(".entry").attr("unhide")})};clickHandlers.hideclose=function(A){A.parents(".hidemore").find(".hideopen").toggle();A.parents(".hidemore").find(".hideclosed").toggle()};clickHandlers.hideexplain=function(A){$('<div style="max-width:30em" id="dialog"><div>'+_('Hidden stuff will no longer appear in your main views. However, you can still find them (and un-hide them) by clicking on the "View hidden entries" link at the bottom of the page.')+'</div><div class="buttons"><button class="l_closedialog">'+'Close'+"</button></div></div>").dialog()};clickHandlers.submithide=function(B){var A=B.parents(".hidemore");var C=A.find("input:checkbox:checked:enabled").attr("rule")||A.find("input:radio:checked").attr("rule");showSpinner(B.parents(".graybox"));submitForm("/a/hiderule",{rules:C})};clickHandlers.hiderule=function(A){showSpinner(A);submitForm("/a/hiderule",{rules:A.attr("hiderules")})};clickHandlers.radiohide=function(C){var A=C.parents(".hidemore");A.find("label.l_checkboxhide").addClass("disabled");A.find("input:checkbox").disable();var B=A.find("input:radio:checked").parent().next().next();if(B.hasClass("l_checkboxhide")){B.removeClass("disabled");B.find("input:checkbox").enable()}return true};clickHandlers.editentry=function(C){var B=C.parents(".entry");var A=B.attr("eid");var D='<div class="popupmenu" eid="'+A+'">';if(B.hasClass("author")){D+='<div class="item"><a href="#" class="l_edittitle" eid="'+A+'">'+'Edit this entry'+"</a></div>"}if(B.find(".comment").not(".deleted").not(".owner").length){D+='<div class="item"><a href="#" class="l_moderate" eid="'+A+'">'+'Moderate comments'+"</a></div>"}D+='<div class="item"><a href="#" class="l_disablecomments" eid="'+A+'">'+(B.hasClass("muted")?'Enable comments':'Disable comments')+"</a></div>";D+='<div class="item"><a href="#" class="l_deleteentry" eid="'+A+'">'+'Delete this entry'+"</a></div>";D+="</div>";$(D).popupMenu(C)};clickHandlers.moderate=function(C){var A=C.attr("eid");var B=getEntry(A);B.find(".comments .comment").not(".moderated,.owner").addClass("moderated").find(".content").append('(<a href="#" class="l_deletecomment">'+'delete'+"</a>)")};clickHandlers.deleteentry=function(B){var A=B.attr("eid");$.postJSON("/a/deleteentry",{entry:A,"delete":"1"},function(C){getEntry(A).replaceWith(C.html)},getEntry(A).find(".l_editentry"))};clickHandlers.disablecomments=function(B){var A=B.attr("eid");$.postJSON("/a/disablecomments",{entry:A,disable:getEntry(A).hasClass("muted")?0:1},function(C){getEntry(A).replaceWith(C.html)},getEntry(A).find(".l_editentry"))};clickHandlers.undeleteentry=function(A){$.postJSON("/a/deleteentry",{entry:A.attr("eid"),stream_ids:A.attr("sids"),userview:$(".entry.nopicture").length>0?"1":"","delete":"0"},function(B){A.parents(".deleted").replaceWith(B.html)},A)};clickHandlers.canceledittitle=function(B){var A=B.parents(".title .text");A.html(A.attr("oldhtml"))};clickHandlers.edittitle=function(B){var A=B.attr("eid");$.postJSON("/a/editentry",{entry:A},function(D){var E=getEntry(A);var C=E.find(".title .text");C.attr("oldhtml",C.html());C.html(D.html);C.find("textarea").makeExpandable(350,function(F){submitEditEntry($(F).parents("form.editentryform")[0])}).focus()},getEntry(A).find(".l_editentry"))};function submitEditEntry(C){if(!checkRequired(C,["title"])){return false}C=$(C);var A=C.parents(".entry").attr("eid");var B=C.formToDict();B.entry=A;B.save="1";$.postJSON("/a/editentry",B,function(D){getEntry(A).find(".title .text").html(D.html)},C.find(".l_canceledittitle"));return false}clickHandlers.emailaddresses=function(A){$.postJSON("/a/emailaddresses",{next:location.href},function(B){$('<div id="dialog"/>').html(B.html).dialog().find("input[type=text]").select()},A)};clickHandlers.imenable=function(A){$.postJSON("/a/imdialog",{},function(B){$('<div id="dialog"/>').html(B.html).dialog().find("input[type=text]").select()},A)};clickHandlers.airenable=function(A){$('<div id="dialog"><div style="margin-bottom:15px; width:400px">'+'To enable desktop notifications, you need to install the FriendFeed Notifier desktop client.'+'</div><div style="font-weight:bold"><a href="/settings/notifier">'+'Install desktop notifier'+"</a></div>").dialog()};clickHandlers.resetnotifierpos=function(A){submitForm("/a/resetairpos",{})};clickHandlers.setprimaryemail=function(A){submitForm("/a/setprimaryemail",{email:A.parents("tr:first").attr("email")})};clickHandlers.deleteemail=function(A){submitForm("/a/deleteemail",{email:A.parents("tr:first").attr("email")})};clickHandlers.sendverification=function(A){submitForm("/a/emailverify",{email:A.parents("tr:first").attr("email")})};clickHandlers.sendverifications=function(A){submitForm("/a/emailverify",{})};clickHandlers.choosefavorites=function(A){$.postJSON("/a/favoritesdialog",{},function(B){$('<div id="dialog"/>').html(B.html).dialog()},A)};function updateFavorites(A){submitForm("/a/updatefavorites",{streams:A.join(",")})}clickHandlers.editfriendlist=function(A){$.postJSON("/a/editfriendlist",{list:A.attr("lid")},function(B){$('<div id="dialog"/>').html(B.html).dialog()},A)};function updateFriendList(A){submitForm("/a/updatefriendlist",{streams:A.join(","),list:$(".l_editfriendlist").attr("lid")})}function bulkSubscribe(C,A,D){var B=$.extend(D,{streams:C.join(","),list:A||"00000000000000000000000000000000"});submitForm("/a/bulkfriendlist",B)}jQuery.fn.autoCompleteContacts=function(){if(!window.gContacts){var A=this;$.postJSON("/a/contacts",{},function(B){window.gContacts=B.contacts;if(window.gContacts){A.autoCompleteContacts()}});return this}this.autoCompleteToBox(window.gContacts);return this};jQuery.fn.makeFriendNavigator=function(B){if(!window.gContacts){var A=this;$.postJSON("/a/contacts",{},function(C){window.gContacts=C.contacts;if(window.gContacts){A.makeFriendNavigator(B)}});return this}this.autoCompleteFriendNav(window.gContacts,B);return this};clickHandlers.createfeed=function(A){var B={};var C=A.attr("next");if(C){B={next:C}}$.postJSON("/a/createfeeddialog",B,function(E){var D=$('<div id="dialog"/>').html(E.html).dialog();setUpCreateForm(D);return },A)};clickHandlers.feedinvite=function(A){$.postJSON("/a/feedinvitedialog",{stream:A.attr("sid")},function(B){$('<div id="dialog"/>').html(B.html).dialog().find(".l_tolist").autoCompleteContacts().find(".l_toinput").select()},A,true)};clickHandlers.sharefocus=function(){$(".sharebox textarea[name=title]").select()};function feedInviteSubmit(A){var C=[];A.find(".l_tocard").each(function(D,E){var F=$(E).attr("sid");if(F){C.push(F)}});var B=$.trim(A.find("textarea[name=emails]").val());if(C.length==0&&B.length==0){A.find(".l_toinput").select();return false}A.find("input[type=submit]").disable();submitForm("/a/feedinvite",$.extend(A.formToDict(),{streams:C.join(",")}));return false}function checkCreateFeedNickname(B,A){nicknameFormUpdate($(".createform input[name=nickname]"),$(".createform .usernameurl"),$(".createform .usernameerror"),A)}function checkCreateFeed(B){if(!checkRequired(B.get(0),["name","nickname"])){return false}var A=B.find("input[name=nickname]");if(B.find(".error").is(":visible")||A.val().length<3){A.select();return false}return true}function setUpCreateForm(E){var C=E.find("input[name=name]");var A=E.find("input[name=nickname]");var D=true;var B="";A.keyup(function(F){if(A.val()!=B){if(A.val().length==0){D=true}else{D=false}}B=A.val()});C.select().keyup(function(K){if(!D){return }var J=C.val().split(/[^A-Za-z0-9]/);var H=[];for(var G=0;G<J.length;G++){if(J[G]){H.push(J[G].toLowerCase())}}if(H){var I=$("#feedoptiongroup").length>0;var F=H.join(I?"-":"").substr(0,35);if(A.val()!=F&&F!=B){A.val(F);B=A.val();checkCreateFeedNickname(null,C.val())}}});A.keyup(checkCreateFeedNickname).focus(checkCreateFeedNickname)}var gNicknameTimeout=null;function nicknameFormUpdate(C,B,D,A){var E=C.val().toLowerCase();if(B.text()==E){return }if(E.length>=3){B.text(E).css({color:"green"});D.hide();if(gNicknameTimeout){clearTimeout(gNicknameTimeout)}gNicknameTimeout=setTimeout(function(){checkNickname(C,B,D,A)},200)}else{B.text('USERNAME').css({color:"green"});D.hide()}}function checkNickname(C,B,E,A){var F=C.val().toLowerCase();var D={nickname:F,room:$("#feedoptiongroup").length>0?1:""};if(A){D.name=A}$.postJSON("/a/checknickname",D,function(G){if(C.val().toLowerCase()==F&&G){if(G.suggestion){C.val(G.suggestion);B.text(G.suggestion)}else{if(G.error_html){B.css({color:"#cc0000"});E.text(G.error_html).show()}}}})}jQuery.fn.autoCompleteToBox=function(B){var A=this;$(".l_toinput",A).autocomplete(B||[],{fbMode:true,matchContains:true,width:220,scrollHeight:100,formatItem:function(C){return C[1]?C[1]+" ("+C[0]+")":C[0]}}).result(function(G,I,F){if($(".l_tocard[sid="+I[0]+"]",A).length==0){var C=I.length>2&&I[2]?" public":"";var E=I.length>1&&I[1]?I[1]:I[0];var D='<li class="l_tocard'+C+'" sid="'+I[0]+'"><span>'+htmlEscape(E)+'</span> <img class="l_toremove" src="/static/images/to-delete.png?v=f1c8" title="'+'Delete'+'"/></li>';var H=$(".addedit",A);if(H.length>0){H.before(D).val("");setCCTwitterHtml()}else{$(".l_toinput",A).before(D)}}window.setTimeout(function(){$(".l_toinput",A).focus()})}).deletelast(function(){$(".l_tocard:last",A).remove();setCCTwitterHtml();$(".l_toinput",A).focus()})};clickHandlers.toremove=function(A){var B=A.parents(".l_tolist");A.parents(".l_tocard").remove();setCCTwitterHtml();B.find(".l_toinput").focus()};clickHandlers.tolist=function(A){A.find(".l_toinput").focus()};function shareToFocus(A){window.clearTimeout(window.gToTimeout);window.gToTimeout=null;shareSetupToBox($(A.target).parents(".sharebox"));$(A.target).parents(".l_tolist").addClass("active")}function shareToBlur(A){if($(".sharebox").is(".expanded")){return }window.clearTimeout(window.gToTimeout);window.gToTimeout=window.setTimeout(function(){$(A.target).parents(".l_tolist").removeClass("active")},0)}clickHandlers.streamchoice=function(A){A.toggleClass("selected");streamChooserUpdateNum()};clickHandlers.streamshowall=function(A){A.addClass("selected");$(".l_streamshowselected").removeClass("selected");streamChooserUpdate()};clickHandlers.streamshowselected=function(A){A.addClass("selected");$(".l_streamshowall").removeClass("selected");streamChooserUpdate()};clickHandlers.expandcluster=function(A){var B=A.parents(".entry");$.postJSON("/a/expandcluster",{entry_ids:A.attr("eids")},function(C){A.remove();B.after(C.html)},A)};function streamChooserUpdate(){var C=$(".streamchooser select");var B=null;if(C.length>0){B=C.get(0).value}var E=$(".l_streamshowselected").is(".selected");var D=$("#streamselectfilter").val();if(!D){var F=E?".selected":"";F+=B?".sel-l-"+B:"";if(F){$(".l_streamchoice").hide();$(".l_streamchoice"+F).show()}else{$(".l_streamchoice").show()}}else{var A=D.toLowerCase().split(" ");$(".l_streamchoice").hide();$(".l_streamchoice").each(function(I,L){var L=$(L);if(E&&!L.is(".selected")){return }if(B&&!L.is(".sel-l-"+B)){return }var K=L.find(".name").text().toLowerCase().split(" ");var G=true;for(var I=0;I<A.length;I++){if(!A[I]){continue}var J=false;for(var H=0;H<K.length;H++){if(!K[H]){continue}if(K[H].startsWith(A[I])){J=true;break}}if(!J){G=false;break}}if(G){L.show()}})}}function streamChooserUpdateNum(){$(".l_streamshowselected").text('Selected (%(num)d)'.replace("%(num)d",$(".l_streamchoice.selected").length))}function streamChooserSubmit(B){if(!B){$.closeDialog()}var A=[];$(".l_streamchoice.selected").each(function(C,D){A.push($(D).attr("sid"))});B(A,$("form#hidden").formToDict())}jQuery.fn.autoCompleteSearchBox=function(A){this.autocomplete(A||[],{requireExplicit:true,selectFirst:true,matchContains:true,width:231,delay:50,permaResults:function(B){if(B.match(searchScope)){return[0]}else{return searchOrder}},highlight:function(D,C,E){if(typeof (E[0])=="number"){return D}var B=E[2];if(B==null){B="/static/images/nomugshot-small.png?v=ed40"}return'<img class="ac_picture picture small" src="'+B+'"/>'+$.Autocompleter.defaults.highlight(D,C)},formatItem:function(F,D,B,E,C){if(typeof (F[0])=="number"){return searchOptions[F[0]][0].replace("%(term)s","<strong>"+htmlEscape(C)+"</strong>")}return(F[1]?F[1]+" ("+F[0]+")":F[0])}}).result(function(C,E,D){if(E.length==1){for(var B in searchOptions[E][1]){$("#searchform").append('<input type="hidden" name="'+B+'" value="'+searchOptions[E][1][B]+'"/>')}$("#searchform").submit()}else{$("#searchbox").val("");document.location.href="/"+E[0]}})};jQuery.fn.autoCompleteFriendNav=function(B,C){var A=this;this.autocomplete(B||[],{requireExplicit:true,selectFirst:true,matchContains:true,width:231,delay:50,highlight:function(F,E,G){var D="/"+G[0]+"/picture?size=small";return'<img class="ac_picture picture small" src="'+D+'"/>'+$.Autocompleter.defaults.highlight(F,E)},formatItem:function(H,F,D,G,E){return(H[1]?H[1]+" ("+H[0]+")":H[0])}}).result(function(D,F,E){if(C){C(F[0])}else{document.location.href="/"+F[0]}})};function recommendFriends(B,C,A){if(!B){return }if(!A&&C){A=C.find("input[type=submit]")}if(C){C.find("input[type=submit]").disable()}$.postJSON("/a/recommendfriends",{user:B},function(D){if(C){C.find("input[type=text]").val("");C.find("input[type=submit]").enable()}if(D.error){$('<div id="dialog"><div>'+D.error+'</div><div style="margin-top:1em"><a href="#" class="l_closedialog">'+'Close'+"</a></div></div>").dialog();return }else{if(D.html){$('<div id="dialog">'+D.html+"</div>").dialog()}}},A)}function recommendFriendsCallback(A){return function(B){if(!B){$.closeDialog();return }submitForm("/friends/recommend",{user:A,streams:B})}}var htmlCharMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function htmlCharEsc(A){return htmlCharMap[A]}function htmlEscape(A){return String(A).replace(/[&<>\"]/g,htmlCharEsc)}var jsonEscapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var jsonSubstitutions={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function jsonQuote(A){return jsonEscapable.test(A)?'"'+A.replace(jsonEscapable,function(B){var C=jsonSubstitutions[B];return typeof C==="string"?C:"\\u"+("0000"+B.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+A+'"'}function jsonString(C){switch(typeof C){case"string":return jsonQuote(C);case"object":if(!C){return"null"}else{if(Object.prototype.toString.apply(C)==="[object Array]"){var D=[];for(var B=0;B<C.length;B++){D.push(jsonString(C[B]))}return"["+D.join(",")+"]"}else{var D=[];for(var A in C){D.push(jsonQuote(A)+":"+jsonString(C[A]))}return"{"+D.join(",")+"}"}}}return String(C)}function unlinkify(B){var A="";$.each(B,function(){$.each(this.childNodes,function(){if(this.nodeType!=8){if(this.nodeType!=1){A+=this.nodeValue}else{if(this.tagName=="A"&&this.innerHTML.startsWith("http")){A+=$(this).attr("href")}else{A+=$(this).text()}}}})});return A}var popup={cache:{},counter:0,id:null,mouseover:function(A){var B=$(A).attr("sid");if(!B){return }if(B==this.id){this.counter++}else{this.hide();this.timeout=setTimeout(function(){popup.timeout=null;popup.counter++;popup.show(A)},100)}},mouseout:function(){var B=$("#popup");if(B.css("visibility")!="visible"){this.hide()}else{var A=this.counter;setTimeout(function(){if(popup.counter==A){popup.hide(true)}},150)}},show:function(A){var E=$(A);var D=E.attr("sid");var C=E.offset();var B=$('<div id="popup" class="l_profile" sid="'+D+'"><div class="profilepopup">'+'Loading...'+"</div></div>").css({left:0,top:C.top+E.height()});$("body").append(B);this.id=D;setTimeout(function(){if(D==popup.id){var F=windowSize();var I=$("#popup");if(I.length>0){var G=I.get(0).offsetWidth;var H=C.left-10;if(H+G>F.width-25){I.css("left",F.width-G-25)}else{I.css("left",H)}popup.shadow();$("#popupshadow,#popup").css("visibility","visible")}}},1000);this.loadPopup(this.id)},shadow:function(){var B=$("#popup");if(B.length==0){return }if($("#popupshadow").length==0){$("body").append($('<div id="popupshadow"/>'))}var A=B.get(0);$("#popupshadow").css({left:A.offsetLeft,top:A.offsetTop+6,width:A.offsetWidth,height:A.offsetHeight-4})},hide:function(A){this.counter++;this.id=null;if(this.timeout){clearTimeout(this.timeout);this.timeout=null}if(A&&!$.browser.msie){$("#popup,#popupshadow").fadeOut(kSlideTime,function(){$("#popup,#popupshadow").remove()})}else{$("#popup,#popupshadow").remove()}},loadPopup:function(A){if(this.cache[A]){$("#popup").html(this.cache[A]);popup.shadow();return }$.postJSON("/a/profilepopup",{stream:A},function(B){popup.cache[A]=B.html;var C=$("#popup");if(C.length>0&&popup.id==A){C.html(popup.cache[A]);popup.shadow()}})}};mouseoverHandlers.profile=bind(popup,"mouseover");mouseoutHandlers.profile=bind(popup,"mouseout");function getActiveEntryIds(){var A={num:0};var B=$(".player").find("object,embed").add(".commentform");B.each(function(){A[$(this).parents(".entry").attr("eid")]=1;A.num++});return A}function showLike(D,B){var G=$("#e-"+D);if(G.length>0){var F=G.find(".likes");if(F.length>0){F.replaceWith(B)}else{var C=getAnchorInfo(G);if(C){var E=$($.trim(B));E.insertAfter(G.find(".info"));reAnchorPage(C)}else{var A=$("<div/>").html(B);A.hide();A.insertAfter(G.find(".info"));A.slideDown(kCommentSlideTime,function(){A.replaceWith(A.find(".likes"))})}}}}function showComment(F,I,G,D,K){var M=$("#e-"+F);if(M.length==0){return }var C=$("#c-"+I);if(C.length>0){return }var H=$($.trim(G));H.addClass("new");var L=getAnchorInfo(M);var B=M.find(".commentform");if(B.length>0&&!B.is(".editform")){if(L||D){H.insertBefore(B);collapseComments(M,true);if(!D){reAnchorPage(L)}}else{var A=$("<div/>").append(H);A.hide();A.insertBefore(B);slideAndReplaceComment(A);collapseComments(M)}}else{var N=M.find(".comments");if(!N.length){N=$('<div class="comments"/>');M.find(".body").append(N)}if(K){var J=$("#feed").get(0).offsetTop+M.get(0).offsetTop;var E=windowSize().height;K=B.length==0&&scrollPos().y==0&&J>E&&M.prev(".entry").length>0}if(D||K||L){N.append(H);collapseComments(M,true);if(L){reAnchorPage(L)}else{if(K){bubbleEntry(M)}}}else{var A=$("<div/>").append(H);A.hide();N.append(A);slideAndReplaceComment(A);collapseComments(M)}}window.setTimeout(function(){H.removeClass("new")},2000)}function collapseComments(F,C){if(F.hasClass("expandedcomments")){return }var G=F.find(".comment");var B=G.length;var A=F.find(".l_expandcomments");if((B+A.length)>4){for(var E=1;E<B-2;E++){if(C){var H=$(G.get(E)).remove()}else{var D=$("<div/>");var H=$(G.get(E)).replaceWith(D);D.append(H);D.slideUp(kCommentSlideTime,function(){D.remove()})}}if(A.length>0){A.text(A.text().replace(/(\d+)/,function(I){return parseInt(I)+1}))}else{$(G.get(0)).after('<div class="expandcomment"><a href="#" class="l_expandcomments">'+'%(num)d more comments'.replace("%(num)d",B-3)+"</a></div>")}}}function slideAndReplaceComment(A){A.slideDown(kCommentSlideTime,function(){A.replaceWith(A.find(".comment"))})}function showEntry(D,B){$("#feedpromo").slideUp(kEntrySlideTime);$(".sharebox").css({borderBottom:"1px solid #eee"});if($("#e-"+D).length>0){return }var C=getAnchorInfo();if(!C){var A=$("<div/>").html(B);A.hide();$("#feed").prepend(A);A.slideDown(kEntrySlideTime,function(){A.replaceWith(A.find(".entry"))})}else{var E=$($.trim(B));$("#feed").prepend(E);reAnchorPage(C)}if($("#feed .entry").length>realtime.maxEntries){$("#feed .entry:last").remove()}}function updateEntryBody(entryId,html,platform_updates){var entry=$("#e-"+entryId);entry.find(".ebody").replaceWith(html);if(platform_updates){for(var wid in platform_updates){p=platform_updates[wid];if(p.widget_class&&p.json_html&&platform[p.widget_class]&&platform[p.widget_class].handleUpdate){platform[p.widget_class].handleUpdate(wid,eval("("+p.json_html+")"))}else{entry.find("#wid-"+wid).replaceWith(p.html)}}}}function updateCommentBody(B,A){$("#c-"+B).replaceWith(A)}function getAnchorInfo(C){var D=$("#feed").get(0).offsetTop;var B=scrollPos().y;if(B<D){return null}if(C){var I=C.get(0);var A=C.find(".commentform");var G=I.offsetTop+I.offsetHeight;if((C.hasClass("entryview")||(A.length>0&&!A.is(".editform")))&&G+D>B&&G+D<B+windowSize().height){return{entry:C.get(0),bottomOffset:G}}}var F=$(".entry");for(var E=0;E<F.length;E++){var H=F.get(E);if(H.offsetTop+H.offsetHeight+D>=B){if(!C||C.get(0).offsetTop<H.offsetTop){return{entry:H,offset:H.offsetTop}}else{return null}}}return null}function reAnchorPage(A){if(!A){return }var B=0;if(A.offset!==undefined){B=A.entry.offsetTop-A.offset}else{if(A.bottomOffset){B=A.entry.offsetTop+A.entry.offsetHeight-A.bottomOffset}}if(B>0){setScrollTop(scrollPos().y+B)}}function bubbleEntry(H){var F=H.next(".entry");var I;if(F.length>0){I=F.get(0).offsetTop-H.get(0).offsetTop}else{I=H.height()}var E=H.get(0).offsetLeft;var G=H.get(0).offsetTop;var B=H.get(0).offsetWidth;var D=$("<div/>");D.css({height:I});var C=$("<div/>");C.css({height:I});H.replaceWith(D);C.hide();var A=$("<div/>");A.css({position:"absolute",left:E,top:G,width:B});A.append(H);$("#feed").append(A);$("#feed").prepend(C);C.slideDown(kEntryReorderTime);D.slideUp(kEntryReorderTime,function(){D.remove()});A.animate({top:$("#feed").get(0).offsetTop},kEntryReorderTime,undefined,function(){C.replaceWith(H);A.remove()})}function setupKBShortcuts(){var C={INPUT:1,TEXTAREA:1,SELECT:1,BUTTON:1};var D=false;var B=[38,38,40,40,37,39,37,39,66,65,9,13];var A=0;$(document).keydown(function(G){var F=D;D=false;if(G.altKey||G.metaKey||G.ctrlKey){return }var E=C[G.target.tagName];if(E){if(G.keyCode==27){$(G.target).blur();$("body").focus();return false}return }if(G.keyCode==B[A]){if(G.keyCode==13){setScrollTop(0);$("#page .box-body").prepend('<div id="alertmessage"><div style="color:white;background:black;padding:10px;font-style:italic;margin-bottom:23px;">REMAIN<br/>&nbsp;&nbsp;P &nbsp;30</div></div>');rotateColors();A=0}else{A+=1}if(G.keyCode<20){return false}}else{if(G.keyCode!=16){A=0}}switch(G.keyCode){case 80:$(".sharebox textarea.title").focus();if(G.shiftKey){$(".sharebox .l_toinput").focus()}return false}if(G.shiftKey){return }if(F){savePageHtml();switch(G.keyCode){case 72:document.location="/";return false;case 68:document.location="/filter/direct";return false;case 77:document.location="/filter/discussions";return false;case 66:document.location="/summary/1";return false}}switch(G.keyCode){case 191:$("#searchbox").focus();return false;case 71:D=true;return false;case 81:if(!realtime.stopped){realtime.pause()}return false}})}function rotateColors(){var B=[37,67,53];var C=0;function A(){C+=3;var F=0,D=[];for(var E in B){D.push(2+Math.sin(C/B[E]));F+=D[E]}for(var E in D){D[E]=Math.min(255,Math.floor(200*D[E]/F))}$("body").css("background","rgb("+D.join(",")+")")}setInterval(A,20)}clickHandlers.setdebuglocale=function(A){submitForm("/a/setdebuglocale",{locale:A.attr("lc")||""})};clickHandlers.hidepromo=function(A){$.postJSON("/a/hidepromo",{position:A.attr("pos")},function(B){A.parents(".entry").replaceWith(B.html)},A)};clickHandlers.unhidepromo=function(A){$.postJSON("/a/hidepromo",{unhide:1,position:A.attr("pos")},function(B){A.parents(".entry").replaceWith(B.html)},A)};clickHandlers.twitterimport=function(A){$.postJSON("/a/twitterimport",{},function(B){$('<div id="dialog"/>').html(B.html).dialog().find("input[type=text]").select()},A)};clickHandlers.serviceorder=function(A){$.postJSON("/a/serviceorderdialog",{stream:A.parents("#serviceseditor").attr("streamid")},function(B){$(B.html).dialog()},A)};clickHandlers.removefile=function(A){A.parents("div.file").remove()};clickHandlers.recommendfriends=function(A){recommendFriends(A.attr("sid"),null,A)};$(window).load(function(){window.gPageLoaded=true});var realtime={pollTime:1000,errorTime:20000,slowPollTime:40000,slowPoll:false,maxEntries:50,maxQueue:125,autoPauseTime:2000,pollHost:"",args:{},lastPoll:0,lastSuccess:0,entryQueue:[],commentQueue:[],likeQueue:[],entryEditQueue:[],commentEditQueue:[],paused:false,autoPaused:false,polling:null,prevRes:"x",delayUntil:0,stopped:false,start:function(){if(!realtime.token){return }if(!window.gPageLoaded){if(!realtime.firstStartTime){realtime.firstStartTime=now()}if(now()-realtime.firstStartTime<8000){setTimeout(realtime.start,200);return }}if(navigator.userAgent.indexOf("iPhone")==-1){$("#feed").mousemove(realtime.autoPause);$(window).scroll(realtime.autoPause)}realtime.iePoll=$.browser.msie;setInterval(function(){realtime.updateStatus();if(realtime.lastPoll&&now()-realtime.lastPoll>3*60000){dprint("reviving");$.get("/static/html/ping.txt",{action:"revive-ajax",token:realtime.token,prev:realtime.prevRes,active:$.active,lpi:Math.round((now()-realtime.lastPoll)/1000)});realtime.poll()}},10000);realtime.poll(400)},doIEPoll:function(D){function G(){realtime.slowPoll=true;realtime.iePoll=false;realtime.poll()}try{if(!realtime.htmlfile){realtime.htmlfile=(window.ActiveXObject&&new ActiveXObject("htmlfile"))}if(!realtime.htmlfile){G();return }var E=location.hostname;if(E.endsWith("friendfeed.com")){E="friendfeed.com"}D+="&ie=1&domain="+E;realtime.htmlfile.open();realtime.htmlfile.write("<html><head><title>f</title></head><body><script>document.domain='"+E+"';<\/script></body></html>");realtime.htmlfile.close();var C=false;realtime.htmlfile.parentWindow.passData=function(H){C=true;realtime.successCallback(H,true)};var B=false;realtime.htmlfile.parentWindow.passStatus=function(H){switch(H){case"loading":B=true;break;case"onload":if(!C){dprint("onload before data");realtime.htmlfile=null;realtime.errorCallback()}break;default:dprint("other: "+H)}};setTimeout(function(){if(!B){dprint("not isLoading");realtime.htmlfile=null;CollectGarbage();realtime.errorCallback()}},10000);var A=realtime.htmlfile.createElement("div");realtime.htmlfile.appendChild(A);A.innerHTML="<iframe src='"+D+"'></iframe>";A=null}catch(F){dprint("ie error");G()}},updateStatus:function(){function A(B){return Math.round((now()-B)/1000)}$("#rtstatus").text("Prev res: "+realtime.prevRes+" Last poll: "+A(realtime.lastPoll)+" Last success: "+A(realtime.lastSuccess)+" Host: "+realtime.hostNum+" (as of "+new Date()+")")},poll:function(A){if(!realtime.token){return }if(realtime.activeXHR){dprint("aborting active");realtime.activeXHR.abort()}clearTimeout(realtime.polling);if(!A){A=10}else{if(realtime.slowPoll){A=Math.max(A,realtime.slowPollTime)}}if(A>300){A+=Math.round(200*Math.random())-100}realtime.polling=setTimeout(realtime.refresh,A);realtime.updateStatus()},successCallback:function(data,skipEval){realtime.activeXHR=null;if(skipEval){r=data}else{try{var r=eval("("+data+")")}catch(e){realtime.errorCallback();return }}r.commentEdits=r.commentEdits||[];realtime.token=r.token;realtime.lastSuccess=now();realtime.prevRes="S-"+(r.entries.length+r.comments.length+r.likes.length+r.entryEdits.length+r.commentEdits.length);var oldLength=realtime.commentQueue.length+realtime.entryQueue.length+realtime.likeQueue.length+realtime.entryEditQueue.length+realtime.commentEditQueue.length;for(var i=0;i<r.likes.length;i++){if($("#e-"+r.likes[i].entry_id).length>0){realtime.likeQueue.push(r.likes[i])}}for(var i=0;i<r.entries.length;i++){if(realtime.entryQueue.length<realtime.maxQueue){if($("#e-"+r.entries[i].id).length==0){realtime.entryQueue.push(r.entries[i])}}}for(var i=0;i<r.comments.length;i++){if(realtime.commentQueue.length<realtime.maxQueue){if($("#c-"+r.comments[i].id).length==0){realtime.commentQueue.push(r.comments[i])}}}for(var i=0;i<r.entryEdits.length;i++){if(realtime.entryEditQueue.length<realtime.maxQueue){if($("#e-"+r.entryEdits[i].id).length>0){realtime.entryEditQueue.push(r.entryEdits[i])}}}for(var i=0;i<r.commentEdits.length;i++){if(realtime.commentEditQueue.length<realtime.maxQueue){if($("#c-"+r.commentEdits[i].id).length>0){realtime.commentEditQueue.push(r.commentEdits[i])}}}if(realtime.commentQueue.length+realtime.entryQueue.length+realtime.likeQueue.length+realtime.entryEditQueue.length+realtime.commentEditQueue.length>oldLength){realtime.queueUpdated()}realtime.poll(r.delay||realtime.pollTime)},errorCallback:function(){realtime.activeXHR=null;if(now()-realtime.lastPoll>realtime.errorTime){realtime.poll(realtime.pollTime)}else{realtime.poll(realtime.errorTime)}},refresh:function(){var D=[];$("#feed .entry").each(function(F,G){var E=$(G).attr("eid");if(E){D.push(E)}});for(var C=0;C<realtime.entryQueue.length;C++){D.push(realtime.entryQueue[C].id)}for(var C=0;C<D.length;C++){D[C]=D[C].substring(0,8)}if(realtime.iePoll){D=D.slice(0,100)}var A=$.param($.extend(realtime.args,{token:realtime.token,prev:realtime.prevRes,entries:D.join("-")}));if(realtime.slowPoll){A+="&timeout=0"}if(realtime.lastPoll){A+="&lpi="+Math.round((now()-realtime.lastPoll)/1000)}realtime.lastPoll=now();var B="/a/updates/nano?"+A;if(realtime.iePoll){if(realtime.pollHost){realtime.hostNum=Math.round(Math.random()*10000);B=location.protocol+"//beta-h"+realtime.hostNum+"."+realtime.pollHost+B+"&host="+realtime.hostNum}realtime.doIEPoll(B)}else{realtime.activeXHR=$.ajax({url:B,data:"",dataType:"text",type:"GET",success:function(E){realtime.successCallback(E,false)},error:realtime.errorCallback})}realtime.updateStatus()},queueUpdated:function(){if(realtime.updateTimeout){window.clearTimeout(realtime.updateTimeout)}realtime.updateTimeout=window.setTimeout(realtime.update,100)},update:function(){realtime.updateTimeout=null;if(realtime.entryQueue.length+realtime.commentQueue.length+realtime.likeQueue.length+realtime.entryEditQueue.length+realtime.commentEditQueue.length==0){return }var C=realtime.entryQueue.length+realtime.commentQueue.length>15?400:1000;realtime.updateTimeout=window.setTimeout(realtime.update,C);if(!realtime.paused&&!realtime.autoPaused){var J=getActiveEntryIds();if(J.num>0){if(realtime.commentQueue.length>0||realtime.likeQueue.length>0||realtime.entryEditQueue.length>0||realtime.commentEditQueue.length>0){if(realtime.commentQueue.length>0){var G=null;for(var E=0;E<realtime.commentQueue.length;E++){var F=realtime.commentQueue[E];if(J[F.entry_id]){G=F;realtime.commentQueue.splice(E,1);break}}if(G){showComment(G.entry_id,G.id,G.html)}}for(var E=0;E<realtime.likeQueue.length;E++){var A=realtime.likeQueue[E];if(J[A.entry_id]||$("#e-"+A.entry_id).find(".likes").length>0){realtime.likeQueue.splice(E,1);showLike(A.entry_id,A.html)}}for(var E=0;E<realtime.entryEditQueue.length;E++){var I=realtime.entryEditQueue[E];if(J[I.id]){realtime.entryEditQueue.splice(E,1);updateEntryBody(I.id,I.html,I.platform)}}for(var E=0;E<realtime.commentEditQueue.length;E++){var I=realtime.commentEditQueue[E];if(J[I.entry_id]){realtime.entryEditQueue.splice(E,1);updateCommentBody(I.id,I.html)}}}realtime.updatePauseStatus()}else{$("#realtimestatus").text("");while(realtime.likeQueue.length>0){var H=realtime.likeQueue.shift();showLike(H.entry_id,H.html)}while(realtime.entryEditQueue.length>0){var D=realtime.entryEditQueue.shift();updateEntryBody(D.id,D.html,D.platform)}while(realtime.commentEditQueue.length>0){var D=realtime.commentEditQueue.shift();updateCommentBody(D.id,D.html)}if(realtime.entryQueue.length>0){var B=realtime.entryQueue.shift();showEntry(B.id,B.html)}else{if(realtime.commentQueue.length>0){var G=realtime.commentQueue.shift();showComment(G.entry_id,G.id,G.html,false,G.bubble)}}}}else{realtime.updatePauseStatus()}},stickypause:function(){if(!gFeedSpec.pauseid){realtime.pause();return }if(realtime.stopped){submitForm("/a/feedpause",{feed:gFeedSpec.pauseid})}else{if(realtime.paused){realtime.pause();return }submitForm("/a/feedpause",{feed:gFeedSpec.pauseid,pause:1})}},pause:function(){if(realtime.paused){realtime.paused=false;$("#realtimestatus").text("");realtime.queueUpdated();$("#realtimectl .l_realtimepause").removeClass("paused")}else{realtime.paused=true;realtime.autoPaused=false;realtime.updatePauseStatus();$("#realtimectl .l_realtimepause").addClass("paused")}},autoPause:function(){realtime.autoPaused=true;if(realtime.autoPauseTimeout){window.clearTimeout(realtime.autoPauseTimeout)}realtime.autoPauseTimeout=window.setTimeout(realtime.unAutoPauseCallback,realtime.autoPauseTime)},unAutoPauseCallback:function(){realtime.autoPauseTimeout=null;realtime.autoPaused=false;if(realtime.updateTimeout){window.clearTimeout(realtime.updateTimeout)}realtime.update()},delay:function(A){var B=now()+A;if(B>realtime.delayUntil){realtime.delayUntil=B}},clearDelay:function(){realtime.delayUntil=0},updatePauseStatus:function(){var A=$("#realtimestatus");var B=realtime.entryQueue.length+realtime.commentQueue.length;if(B==0){A.text("");return }if(B==1){A.text('(1 queued item)')}else{A.text('(%(num)s queued items)'.replace("%(num)s",B))}}};clickHandlers.realtimepause=realtime.stickypause;

