if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());if(!window.FB){FB={_apiKey:null,_session:null,_userStatus:"unknown",_logging:true,_domain:{api:window.location.protocol+"//api.facebook.com/",cdn:(window.location.protocol=="https:"?"https://s-static.ak.fbcdn.net/":"http://static.ak.fbcdn.net/"),www:window.location.protocol+"//www.facebook.com/"},_locale:null,copy:function(h,a,g){if(typeof h=="string"){var j=FB,e=h.split(".");for(var f=0,c=e.length;f<c;f++){var b=e[f];if(b===""){continue}if(typeof j[b]==="undefined"){j[b]={}}j=j[b]}h=j}for(var d in a){if(a.hasOwnProperty(d)&&(g||!(d in h))){h[d]=a[d]}}return h},guid:function(){return"f"+(Math.random()*(1<<30)).toString(16).replace(".","")},log:function(a){if(FB._logging&&window.console){console.log(a)}if(FB.Event){FB.Event.fire("fb.log",a)}}}}FB.copy("",{api:function(d,b){if(FB.Auth&&d.method=="Auth.revokeAuthorization"){var c=b;b=function(e){if(e===true){FB.Auth.setSession(null,"notConnected")}c&&c(e)}}try{FB.RestServer.jsonp(d,b)}catch(a){if(FB.Flash.hasMinVersion()){FB.RestServer.flash(d,b)}else{throw new Error("Flash is required for this API call.")}}}});FB.copy("RestServer",{_callbacks:{},sign:function(a){FB.copy(a,{api_key:FB._apiKey,call_id:(new Date()).getTime(),format:"json",v:"1.0"});if(FB._session){FB.copy(a,{session_key:FB._session.session_key,ss:1})}if(FB._session){a.sig=FB.md5sum(FB.QS.encode(a,"",false)+FB._session.secret)}return a},jsonp:function(e,a){var d=FB.guid(),b=document.createElement("script"),c;e=FB.RestServer.sign(FB.copy({callback:"FB.RestServer._callbacks."+d},e));c=FB._domain.api+"restserver.php?"+FB.QS.encode(e);if(c.length>2000){throw new Error("JSONP only support a maximum of 2000 bytes of input.")}FB.RestServer._callbacks[d]=function(f){a(f);delete FB.RestServer._callbacks[d];b.parentNode.removeChild(b)};b.src=c;document.getElementsByTagName("head")[0].appendChild(b)},flash:function(b,a){if(!FB.RestServer.flash._init){window.FB_OnXdHttpResult=function(d,c){FB.RestServer._callbacks[d](FB.Flash.decode(c))};FB.RestServer.flash._init=true}FB.Flash.onReady(function(){var f,d,c,e;c=FB.QS.encode(FB.RestServer.sign(FB.copy({},b)));d=FB._domain.api+"restserver.php";if(d.length+c.length>2000){f="POST"}else{f="GET";d+="?"+c;c=""}e=document.XdComm.sendXdHttpRequest(f,d,c,null);FB.RestServer._callbacks[e]=function(g){a(JSON.parse(FB.Flash.decode(g)));delete FB.RestServer._callbacks[e]}})}});FB.copy("",{getLoginStatus:function(a,e){if(!FB._apiKey){FB.log("FB.getLoginStatus() called before calling FB.init().");return}if(a){if(!e&&FB.Auth._loadState=="loaded"){a({status:FB._userStatus,session:FB._session});return}else{FB.Auth._callbacks.push(a)}}if(!e&&FB.Auth._loadState=="loading"){return}FB.Auth._loadState="loading";var f=function(h){FB.Auth._loadState="loaded";var k=FB.Auth._callbacks;FB.Auth._callbacks=[];for(var j=0,g=k.length;j<g;j++){k[j](h)}};var c=FB.Auth.xdHandler,d=FB.guid(),b=FB._domain.www+"extern/login_status.php?"+FB.QS.encode({api_key:FB._apiKey,no_session:c(f,d,"parent",false,"notConnected"),no_user:c(f,d,"parent",false,"unknown"),ok_session:c(f,d,"parent",false,"connected"),session_version:2});FB.Frames.hidden(b,d)},getSession:function(){return FB._session},login:function(a,d){if(!FB._apiKey){FB.log("FB.login() called before calling FB.init().");return}if(FB._session&&!d){FB.log("FB.login() called when user is already connected.");a&&a({status:FB._userStatus,session:FB._session});return}var c=FB.Auth.xdHandler,h=FB.guid(),f=c(a,h,"opener",true,FB._userStatus,FB._session),e=c(a,h,"opener",false,"connected",FB._session),b=FB._domain.www+"login.php?"+FB.QS.encode({api_key:FB._apiKey,cancel_url:f,channel_url:window.location.toString(),display:"popup",fbconnect:1,next:e,req_perms:d,return_session:1,session_version:2,v:"1.0"});FB.Frames.popup(b,450,415,h)},logout:function(a){if(!FB._apiKey){FB.log("FB.logout() called before calling FB.init().");return}if(!FB._session){FB.log("FB.logout() called without a session.");return}var c=FB.guid(),b=FB._domain.www+"logout.php?"+FB.QS.encode({api_key:FB._apiKey,next:FB.Auth.xdHandler(a,c,"parent",false,"unknown"),session_key:FB._session.session_key});FB.Frames.hidden(b,c)}});FB.copy("Auth",{_callbacks:[],setSession:function(h,c){var e=!FB._session&&h,b=FB._session&&!h,g=FB._session&&h&&FB._session.uid!=h.uid,a=(FB._session&&h&&FB._session.session_key!=h.session_key),f=c!=FB._status;var d={session:h,status:c};FB._session=h;FB._userStatus=c;if(f){FB.Event.fire("auth.statusChange",d)}if(b||g){FB.Event.fire("auth.logout",d)}if(e||g){FB.Event.fire("auth.login",d)}if(e||b||a){FB.Event.fire("auth.sessionChange",d)}return d},xdHandler:function(a,f,e,c,b,d){return FB.Frames.xdHandler(function(j){var h;try{h=FB.Auth.setSession(JSON.parse(j.session),b)}catch(g){h=FB.Auth.setSession(d||null,b)}h.perms=(j.result!="xxRESULTTOKENxx"&&j.result||"");a&&a(h)},f,e,c)+"&result=xxRESULTTOKENxx"}});FB.copy("Content",{_root:null,_hiddenRoot:null,_callbacks:{},append:function(b,a){if(!a){if(!FB.Content._root){FB.Content._root=a=document.getElementById("fb-root");if(!a){FB.log('The "fb-root" div has not been created.');return}}else{a=FB.Content._root}}if(typeof b=="string"){var c=document.createElement("div");a.appendChild(c).innerHTML=b;return c}else{return a.appendChild(b)}},appendHidden:function(c){if(!FB.Content._hiddenRoot){var a=document.createElement("div"),b=a.style;b.position="absolute";b.top="-10000px";b.width=b.height=0;FB.Content._hiddenRoot=FB.Content.append(a)}return FB.Content.append(c,FB.Content._hiddenRoot)},insertIframe:function(c,a,g){var b=FB.guid(),h=FB.Content.append("",a),e=false;FB.Content._callbacks[b]=function(){if(e){g&&g(h.firstChild);delete FB.Content._callbacks[b]}};if(document.attachEvent){var d=('<iframe  src="'+c+'" onload="FB.Content._callbacks.'+b+'()"></iframe>');h.innerHTML='<iframe src="javascript:false"></iframe>';e=true;window.setTimeout(function(){h.innerHTML=d},0)}else{var f=document.createElement("iframe");f.onload=FB.Content._callbacks[b];h.appendChild(f);e=true;f.src=c}}});FB.copy("Cookie",{_domain:null,init:function(){if(!FB.Cookie._initDone){FB.Event.subscribe("auth.sessionChange",function(a){FB.Cookie.set(a.session)});FB.Cookie._initDone=true}},load:function(){var b=document.cookie.match("\\bfbs_"+FB._apiKey+"=([^;]*)\\b"),c,a;if(b){c=FB.QS.decode(b[1]);a=c.expires=parseInt(c.expires,10);FB.Cookie._domain=c.base_domain}return c},setRaw:function(c,b,a){document.cookie="fbs_"+FB._apiKey+"="+c+"; expires="+new Date(b*1000).toGMTString()+"; path=/"+(a?"; domain=."+a:"");FB.Cookie._domain=a},set:function(a){a?FB.Cookie.setRaw(FB.QS.encode(a),a.expires,a.base_domain):FB.Cookie.clear()},clear:function(){FB.Cookie.setRaw("",0,FB.Cookie._domain)}});FB.copy("",{init:function(a){if(!a||!a.apiKey){FB.log("FB.init() called without an apiKey.");return}FB.copy(a,{logging:true});FB._apiKey=a.apiKey;if(!a.logging&&window.location.toString().indexOf("fb_debug=1")<0){FB._logging=false}if(a.cookie){FB.Cookie.init()}a.session=a.session||FB.Cookie.load();FB.Auth.setSession(a.session,a.session?"connected":"unknown");if(a.status){FB.getLoginStatus()}}});FB.copy("EventProvider",{subscribers:function(){if(!this._subscribersMap){this._subscribersMap={}}return this._subscribersMap},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a]}else{c[b].push(a)}},unsubscribe:function(c,a){var e=this.subscribers();if(e[c]){for(var d=0,b=e[c].length;d<b;d++){if(e[c][d]==a){e[c][d]=null}}}},fire:function(){var c=Array.prototype.slice.call(arguments),b=c.shift(),f=this.subscribers()[b],e;if(!f){return}for(var d=0,a=f.length;d<a;d++){e=f[d];if(e){e.apply(window,c)}}}});FB.copy("Event",FB.EventProvider);FB.copy("Flash",{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:"swf/XdComm.swf",_callbacks:[],init:function(){if(FB.Flash._init){return}FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var e=0,d=FB.Flash._callbacks.length;e<d;e++){FB.Flash._callbacks[e]()}FB.Flash._callbacks=[]};var c=!!document.attachEvent,b=FB._domain.cdn+FB.Flash._swfPath,a=('<object type="application/x-shockwave-flash" id="XdComm" '+(c?'name="XdComm" ':"")+(c?"":'data="'+b+'" ')+(c?'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ':"")+'allowscriptaccess="always"><param name="movie" value="'+b+'"></param><param name="allowscriptaccess" value="always"></param></object>');FB.Content.appendHidden(a)},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==="undefined"){var q,h,f,j=[];try{q=new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(k){var b="application/x-shockwave-flash";if(navigator.mimeTypes[b].enabledPlugin){var a="Shockwave Flash";q=(navigator.plugins[a+" 2.0"]||navigator.plugins[a]).description}}if(q){var g=q.replace(/\D+/g,",").match(/^,?(.+),?$/)[1].split(",");for(h=0,f=g.length;h<f;h++){j.push(parseInt(g[h],10))}}FB.Flash._hasMinVersion=false;majorVersion:for(h=0,f=FB.Flash._minVersions.length;h<f;h++){var p=FB.Flash._minVersions[h];if(p[0]!=j[0]){continue}for(var e=1,d=p.length,c=j.length;(e<d&&e<c);e++){if(j[e]<p[e]){FB.Flash._hasMinVersion=false;continue majorVersion}else{FB.Flash._hasMinVersion=true;if(j[e]>p[e]){break majorVersion}}}}}return FB.Flash._hasMinVersion},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0)}else{FB.Flash._callbacks.push(a)}},decode:function(a){if(a&&a.length&&typeof a!="string"){a=a[0]}if(!a||typeof a!="string"){return a}a=a.replace(/\&custom_lt\;/g,"<");a=a.replace(/\&custom_gt\;/g,">");a=a.replace(/\&custom_backslash\;/g,"\\");a=a.replace(/\\0/g,"\0");return a}});FB.copy("Frames",{_monitor:null,_count:0,_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',hidden:function(a,b){FB.Content.insertIframe(a,FB.Content.appendHidden(""),function(c){FB.Frames._active[b]=c})},popup:function(a,c,k,b){var g=typeof window.screenX!="undefined"?window.screenX:window.screenLeft,e=typeof window.screenY!="undefined"?window.screenY:window.screenTop,m=typeof window.outerWidth!="undefined"?window.outerWidth:document.body.clientWidth,j=typeof window.outerHeight!="undefined"?window.outerHeight:(document.body.clientHeight-22),f=parseInt(g+((m-c)/2),10),h=parseInt(e+((j-k)/2.5),10),d=("width="+c+",height="+k+",left="+f+",top="+h);FB.Frames._active[b]=window.open(a,"_blank",d);if(b in FB.Frames._defaultCb){FB.Frames._count++;FB.Frames.popupMonitor()}},popupMonitor:function(){if(FB.Frames._count<1){window.clearInterval(FB.Frames._monitor);FB.Frames._monitor=null;return}if(!FB.Frames._monitor){FB.Frames._monitor=window.setInterval(FB.Frames.popupMonitor,100)}for(var d in FB.Frames._active){if(FB.Frames._active.hasOwnProperty(d)&&d in FB.Frames._defaultCb){var b=FB.Frames._active[d];try{if(b.tagName){continue}}catch(a){}try{if(b.closed){FB.Frames._count--;FB.Frames.xdRecv({frame:d},FB.Frames._defaultCb[d])}}catch(c){}}}},xdHandler:function(a,d,b,c){if(c){FB.Frames._defaultCb[d]=a}return FB.XD.handler(function(e){FB.Frames.xdRecv(e,a)},b)+"&frame="+d},xdRecv:function(c,b){var d=FB.Frames._active[c.frame];try{if(d.tagName){window.setTimeout(function(){d.parentNode.removeChild(d)},500)}}catch(a){}try{if(d.close){d.close()}}catch(e){}delete FB.Frames._active[c.frame];delete FB.Frames._defaultCb[c.frame];b(c)},xdResult:function(a,d,c,b){return(FB.Frames.xdHandler(function(e){a&&a(e.result&&e.result!=FB.Frames._resultToken&&JSON.parse(e.result))},d,c,b)+"&result="+encodeURIComponent(FB.Frames._resultToken))}});FB.md5sum=function(p){var A="0123456789abcdef",f="",G,e,z,w="",r="",v=-1,o,n;function u(a,c){var b=(a&65535)+(c&65535);return(((a>>16)+(c>>16)+(b>>16))<<16)|(b&65535)}function s(K,y,d,c,J,I){var H=u(u(y,K),u(c,I));return u((H<<J)|(H>>>(32-J)),d)}function t(I,H,M,L,y,K,J){return s((H&M)|((~H)&L),I,H,y,K,J)}function C(I,H,M,L,y,K,J){return s((H&L)|(M&(~L)),I,H,y,K,J)}function h(I,H,M,L,y,K,J){return s(H^M^L,I,H,y,K,J)}function q(I,H,M,L,y,K,J){return s(M^(H|(~L)),I,H,y,K,J)}while(++v<p.length){o=p.charCodeAt(v);n=v+1<p.length?p.charCodeAt(v+1):0;if(55296<=o&&o<=56319&&56320<=n&&n<=57343){o=65536+((o&1023)<<10)+(n&1023);v++}if(o<=127){f+=String.fromCharCode(o)}else{if(o<=2047){f+=String.fromCharCode(192|((o>>>6)&31),128|(o&63))}else{if(o<=65535){f+=String.fromCharCode(224|((o>>>12)&15),128|((o>>>6)&63),128|(o&63))}else{if(o<=2097151){f+=String.fromCharCode(240|((o>>>18)&7),128|((o>>>12)&63),128|((o>>>6)&63),128|(o&63))}}}}}G=f.length*8;e=Array(f.length>>2);for(v=0;v<e.length;v++){e[v]=0}for(v=0;v<G;v+=8){e[v>>5]|=(f.charCodeAt(v/8)&255)<<(v%32)}e[G>>5]|=128<<((G)%32);e[(((G+64)>>>9)<<4)+14]=G;var F=1732584193,E=-271733879,D=-1732584194,B=271733878;for(v=0;v<e.length;v+=16){var m=F,k=E,j=D,g=B;F=t(F,E,D,B,e[v+0],7,-680876936);B=t(B,F,E,D,e[v+1],12,-389564586);D=t(D,B,F,E,e[v+2],17,606105819);E=t(E,D,B,F,e[v+3],22,-1044525330);F=t(F,E,D,B,e[v+4],7,-176418897);B=t(B,F,E,D,e[v+5],12,1200080426);D=t(D,B,F,E,e[v+6],17,-1473231341);E=t(E,D,B,F,e[v+7],22,-45705983);F=t(F,E,D,B,e[v+8],7,1770035416);B=t(B,F,E,D,e[v+9],12,-1958414417);D=t(D,B,F,E,e[v+10],17,-42063);E=t(E,D,B,F,e[v+11],22,-1990404162);F=t(F,E,D,B,e[v+12],7,1804603682);B=t(B,F,E,D,e[v+13],12,-40341101);D=t(D,B,F,E,e[v+14],17,-1502002290);E=t(E,D,B,F,e[v+15],22,1236535329);F=C(F,E,D,B,e[v+1],5,-165796510);B=C(B,F,E,D,e[v+6],9,-1069501632);D=C(D,B,F,E,e[v+11],14,643717713);E=C(E,D,B,F,e[v+0],20,-373897302);F=C(F,E,D,B,e[v+5],5,-701558691);B=C(B,F,E,D,e[v+10],9,38016083);D=C(D,B,F,E,e[v+15],14,-660478335);E=C(E,D,B,F,e[v+4],20,-405537848);F=C(F,E,D,B,e[v+9],5,568446438);B=C(B,F,E,D,e[v+14],9,-1019803690);D=C(D,B,F,E,e[v+3],14,-187363961);E=C(E,D,B,F,e[v+8],20,1163531501);F=C(F,E,D,B,e[v+13],5,-1444681467);B=C(B,F,E,D,e[v+2],9,-51403784);D=C(D,B,F,E,e[v+7],14,1735328473);E=C(E,D,B,F,e[v+12],20,-1926607734);F=h(F,E,D,B,e[v+5],4,-378558);B=h(B,F,E,D,e[v+8],11,-2022574463);D=h(D,B,F,E,e[v+11],16,1839030562);E=h(E,D,B,F,e[v+14],23,-35309556);F=h(F,E,D,B,e[v+1],4,-1530992060);B=h(B,F,E,D,e[v+4],11,1272893353);D=h(D,B,F,E,e[v+7],16,-155497632);E=h(E,D,B,F,e[v+10],23,-1094730640);F=h(F,E,D,B,e[v+13],4,681279174);B=h(B,F,E,D,e[v+0],11,-358537222);D=h(D,B,F,E,e[v+3],16,-722521979);E=h(E,D,B,F,e[v+6],23,76029189);F=h(F,E,D,B,e[v+9],4,-640364487);B=h(B,F,E,D,e[v+12],11,-421815835);D=h(D,B,F,E,e[v+15],16,530742520);E=h(E,D,B,F,e[v+2],23,-995338651);F=q(F,E,D,B,e[v+0],6,-198630844);B=q(B,F,E,D,e[v+7],10,1126891415);D=q(D,B,F,E,e[v+14],15,-1416354905);E=q(E,D,B,F,e[v+5],21,-57434055);F=q(F,E,D,B,e[v+12],6,1700485571);B=q(B,F,E,D,e[v+3],10,-1894986606);D=q(D,B,F,E,e[v+10],15,-1051523);E=q(E,D,B,F,e[v+1],21,-2054922799);F=q(F,E,D,B,e[v+8],6,1873313359);B=q(B,F,E,D,e[v+15],10,-30611744);D=q(D,B,F,E,e[v+6],15,-1560198380);E=q(E,D,B,F,e[v+13],21,1309151649);F=q(F,E,D,B,e[v+4],6,-145523070);B=q(B,F,E,D,e[v+11],10,-1120210379);D=q(D,B,F,E,e[v+2],15,718787259);E=q(E,D,B,F,e[v+9],21,-343485551);F=u(F,m);E=u(E,k);D=u(D,j);B=u(B,g)}z=[F,E,D,B];for(v=0;v<z.length*32;v+=8){w+=String.fromCharCode((z[v>>5]>>>(v%32))&255)}for(v=0;v<w.length;v++){o=w.charCodeAt(v);r+=A.charAt((o>>>4)&15)+A.charAt(o&15)}return r};FB.copy("QS",{encode:function(e,b,c){b=b===undefined?"&":b;c=c===false?function(f){return f}:encodeURIComponent;var d=[],a;for(a in e){if(e.hasOwnProperty(a)&&e[a]!==null&&typeof e[a]!="undefined"){d.push(c(a)+"="+c(e[a]))}}d.sort();return d.join(b)},decode:function(f){var c=decodeURIComponent,e={},b=f.split("&"),a,d;for(a=0;a<b.length;a++){d=b[a].split("=",2);e[c(d[0])]=c(d[1])}return e}});FB.copy("",{share:function(b,c){var a=FB._domain.www+"sharer.php?"+FB.QS.encode({title:c,u:b||window.location.toString()});FB.Frames.popup(a,575,380)},publish:function(d,a){if(a){var b=a;a=function(f){if(f){if(f.postId){f={message:f.data.user_message,post_id:f.postId}}else{f=null}}b(f)}}d=d||{};var e=FB._apiKey&&FB.guid(),c=FB._domain.www+"connect/prompt_feed.php?"+FB.QS.encode({action_links:JSON.stringify(d.action_links||{}),actor_id:d.actor_id,api_key:FB._apiKey,attachment:JSON.stringify(d.attachment||{}),callback:e&&FB.Frames.xdResult(a,e,"opener",true),message:d.message,preview:1,session_key:FB._session&&FB._session.session_key,target_id:d.target_id,user_message_prompt:d.user_message_prompt});FB.Frames.popup(c,550,242,e)},addFriend:function(d,a){var c=FB.guid(),b=FB._domain.www+"addfriend.php?"+FB.QS.encode({api_key:FB._apiKey,display:"dialog",id:d,next:FB.Frames.xdResult(a,c,"opener",true),session_key:FB._session.session_key});FB.Frames.popup(b,565,240,c)}});FB.copy("XD",{_origin:null,_transport:null,_callbacks:{},init:function(){if(FB.XD._origin){return}FB.XD._origin=(window.location.protocol+"//"+window.location.host+"/"+FB.guid());if(window.addEventListener&&window.postMessage){FB.XD.PostMessage.init();FB.XD._transport="postmessage"}else{if(FB.Flash.hasMinVersion()){FB.XD.Flash.init();FB.XD._transport="flash"}else{FB.XD._transport="fragment"}}},handler:function(a,b){FB.XD.init();var d=FB._domain.cdn+"connect/xd_proxy.php#?=&",e=FB.guid();if(FB.XD._transport=="fragment"){d=window.location.toString();var c=d.indexOf("#");if(c>0){d=d.substr(0,c)}d+="?&fb_xd_bust#?=&"+FB.XD.Fragment._magic}FB.XD._callbacks[e]=a;return d+FB.QS.encode({cb:e,origin:FB.XD._origin,relation:b||"opener",transport:FB.XD._transport})},recv:function(b){if(typeof b=="string"){b=FB.QS.decode(b)}var a=FB.XD._callbacks[b.cb];delete FB.XD._callbacks[b.cb];a&&a(b)},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener("message",a,false):window.attachEvent("onmessage",a)},onMessage:function(a){FB.XD.recv(a.data)}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init("FB.XD.Flash.onMessage",FB.XD._origin)})},onMessage:function(a){FB.XD.recv(decodeURIComponent(a))}},Fragment:{_magic:"fb_xd_fragment;",checkAndDispatch:function(){var d=window.location.toString(),a=d.substr(d.indexOf("#")+1),b=a.indexOf(FB.XD.Fragment._magic);if(b>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.body.style.display="none";a=a.substr(b+FB.XD.Fragment._magic.length);var c=FB.QS.decode(a);window[c.relation].FB.XD.recv(a)}}}});FB.XD.Fragment.checkAndDispatch();var Delegator={subscribers:{},listen:function(a,e,d){if(document.attachEvent){if(e=="focus"){e="focusin"}else{if(e=="blur"){e="focusout"}}}if(!(e in Delegator.subscribers)){document.addEventListener?document.addEventListener(e,Delegator.handler(e),true):document.attachEvent("on"+e,Delegator.handler(e));Delegator.subscribers[e]=[]}var f=a.split(/\s*,\s*/);for(var c=0,b=f.length;c<b;c++){Delegator.subscribers[e].push({rule:f[c],handler:d})}},handler:function(a){return function(b){Delegator.dispatch(a,b||window.event)}},dispatch:function(n,d){var f=d.target||d.srcElement,b=Delegator.subscribers[n],j=b.length,g=[];while(f){try{var k={id:f.id,className:f.className,tagName:f.tagName}}catch(m){return}for(var h=0;h<j;h++){var a=b[h];if(!a.compiled){a.compiled=Delegator.compile(a.rule)}var c=typeof g[h]==="undefined"?g[h]={index:(a.compiled.length-1)}:g[h];if(c.index<0){continue}var o=a.compiled[c.index];if((!o.id||o.id==k.id)&&(!o.tagName||o.tagName==k.tagName)&&(o.className.length===0||Delegator.matchClasses(k.className,o.className))){--c.index;if(!c.node){c.node=f}if(c.index==-1){a.handler.call(c.node,d)}}}f=f.parentNode}},regexpCache:{},matchClasses:function(d,c){for(var b=0,a=c.length;b<a;b++){var e="(?:^|\\s+)"+c[b]+"(?:\\s+|$)";if(!Delegator.regexpCache[e]){Delegator.regexpCache[e]=new RegExp(e)}if(!Delegator.regexpCache[e].test(d)){return false}}return true},compile:function(d){var f=Delegator.split(d),g=[],e;for(var c=0,a=f.length;c<a;c++){var b=f[c];if(!e){e={tagName:null,id:null,className:[]}}switch(b){case"":break;case"#":e.id=f[++c];break;case".":e.className.push(f[++c]);break;case" ":g.push(e);e=null;break;default:e.tagName=b.toUpperCase()}}if(e){g.push(e)}return g},_compliantCG:/()??/.exec("")[1]===undefined,split:function(b){var f=/(#|\.| )/g,a=/^(#|\.| )$(?!\s)/g,d=[],g=0,e,h,c;while((e=f.exec(b))){h=e.index+e[0].length;if(h>g){d.push(b.slice(g,e.index));if(!Delegator._compliantCG&&e.length>1){e[0].replace(a,function(){for(var j=1;j<arguments.length-2;j++){if(arguments[j]===undefined){e[j]=undefined}}})}if(e.length>1&&e.index<b.length){Array.prototype.push.apply(d,e.slice(1))}c=e[0].length;g=h}if(f.lastIndex===e.index){f.lastIndex++}}if(g===b.length){if(!f.test("")||c){d.push("")}}else{d.push(b.slice(g))}return d}};var Herstory={current:undefined,callback:undefined,iframe:undefined,safari:/webkit/.test(navigator.userAgent.toLowerCase()),msie:(/msie/.test(navigator.userAgent.toLowerCase())&&!/opera/.test(navigator.userAgent.toLowerCase())),init:function(e,c,b){Herstory.current=location.hash.replace(/\?.*$/,"");Herstory.callback=e;if(Herstory.msie){if(Herstory.current===""){Herstory.current="#"}var d=document.body.appendChild(document.createElement("div"));d.innerHTML=('<iframe style="display: none;"'+(c?' src="'+c+'"':"")+"></iframe>");Herstory.iframe=d.firstChild;var a=Herstory.iframe.contentWindow.document;a.open();a.close();a.location.hash=Herstory.current;if(typeof b=="undefined"||b){document.attachEvent("onclick",function(g){var f=(g&&g.srcElement&&g.srcElement.href)||"";if(Herstory.handleHrefFragment(f)){g.returnValue=false;window.scrollTo(0,0)}})}}else{if(Herstory.safari){Herstory.rwStack=[];Herstory.rwStack.length=history.length;Herstory.ffStack=[];Herstory.lastLength=history.length;Herstory.isFirst=true}}Herstory.callback(Herstory.current.replace(/^#/,""));setInterval(Herstory.check,100)},handleHrefFragment:function(b){var a=b.indexOf("#");if(a<0){return false}else{if(a!==0){if(b.charAt(0)=="/"&&b.substr(0,a)!=window.location.path){return false}else{var d=window.location.href.indexOf("#"),c=window.location.href.substr(0,(d<0?undefined:d));if(b.substr(0,a)!=c){return false}}}}Herstory.load(b.substr(a+1));return true},add:function(a){Herstory.rwStack.push(a);Herstory.ffStack.length=0;Herstory.isFirst=true},check:function(){if(Herstory.msie){var a=Herstory.iframe,e=a.contentDocument||a.contentWindow.document,g=e.location.hash.replace(/\?.*$/,"");if(g!=Herstory.current){location.hash=g;Herstory.current=g;Herstory.callback(g.replace(/^#/,""))}}else{if(Herstory.safari){if(Herstory.lastLength==history.length&&Herstory.rwStack.length>Herstory.lastLength){Herstory.rwStack.shift()}if(!Herstory.dontCheck){var c=history.length-Herstory.rwStack.length;Herstory.lastLength=history.length;if(c){Herstory.isFirst=false;if(c<0){for(var d=0;d<Math.abs(c);d++){Herstory.ffStack.unshift(Herstory.rwStack.pop())}}else{for(var b=0;b<c;b++){Herstory.rwStack.push(Herstory.ffStack.shift())}}var f=Herstory.rwStack[Herstory.rwStack.length-1];if(f!==undefined){Herstory.current=location.hash.replace(/\?.*$/,"");Herstory.callback(f)}}else{if(Herstory.rwStack[Herstory.rwStack.length-1]===undefined&&!Herstory.isFirst){if(location.hash){var g=location.hash;Herstory.callback(location.hash.replace(/^#/,""))}else{var g="";Herstory.callback("")}Herstory.isFirst=true}}}}else{var g=location.hash.replace(/\?.*$/,"");if(g!=Herstory.current){Herstory.current=g;Herstory.callback(g.replace(/^#/,""))}}}},load:function(b){var c;b=decodeURIComponent(b.replace(/\?.*$/,""));if(Herstory.safari){c=b}else{c="#"+b;location.hash=c}Herstory.current=c;if(Herstory.msie){var a=Herstory.iframe.contentWindow.document;a.open();a.close();a.location.hash=c;Herstory.lastLength=history.length;Herstory.callback(b)}else{if(Herstory.safari){Herstory.dontCheck=true;Herstory.add(b);window.setTimeout(function(){Herstory.dontCheck=false},200);Herstory.callback(b);location.hash=c}else{Herstory.callback(b)}}}};var FlashReplace={elmToReplace:null,flashIsInstalled:null,defaultFlashVersion:7,replace:function(d,a,b,c,q,o,g){this.elmToReplace=d.tagName?d:document.getElementById(d);this.flashIsInstalled=this.checkForFlash(o||this.defaultFlashVersion);if(this.elmToReplace&&this.flashIsInstalled){var j="<object"+((window.ActiveXObject)?' id="'+b+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="'+a+'"':"");j+=' width="'+c+'"';j+=' height="'+q+'"';j+=">";var f="<param";f+=' name="movie"';f+=' value="'+a+'"';f+=">";f+="";var p="";var n="";for(var h in g){p+='<param name="'+h+'" value="'+g[h]+'">';n+=" "+h+'="'+g[h]+'"'}var m='<embed id="'+b+'" src="'+a+'" type="application/x-shockwave-flash" width="'+c+'" height="'+q+'"';var k=n+"></embed>";var e="</object>";this.elmToReplace.innerHTML=j+f+p+m+k+e}},checkForFlash:function(a){this.flashIsInstalled=false;var c;if(window.ActiveXObject){try{c=new ActiveXObject(("ShockwaveFlash.ShockwaveFlash."+a));this.flashIsInstalled=true}catch(d){}}else{if(navigator.plugins&&navigator.mimeTypes.length>0){c=navigator.plugins["Shockwave Flash"];if(c){var b=navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1");if(b>=a){this.flashIsInstalled=true}}}}return this.flashIsInstalled}};var StreamDiff={init:function(){if(navigator.userAgent.toLowerCase().indexOf("iphone")>-1){StreamDiff.DOM.addClass(document.getElementsByTagName("html")[0],"iphone")}window.setTimeout(function(){StreamDiff._init()},0)},_init:function(){FB.init({apiKey:"2522fa99e515c8a86ec5bbb879732d85",cookie:true});Delegator.listen("#doc .logout","click",function(){FB.logout(function(){Intro.view()})});Delegator.listen(".share-streamdiff","click",StreamDiff.shareSite);if(FB.getSession()){StreamDiff.statusReady()}else{FB.getLoginStatus(function(a){StreamDiff.statusReady()})}},shareSite:function(){var a={message:"Checkout StreamDiff!",attachment:{name:"StreamDiff",caption:"Just see what's new!",description:("StreamDiff provides an alternate view of your News Feed. It provides a Mark as read feature to bury the old stuff. New Posts, Comments and Like's will show up at the top for immediate consumption!"),href:"http://streamdiff.com/",media:[{type:"image",src:"http://streamdiff.com/logo.png",href:"http://streamdiff.com/"}]},action_links:[{text:"StreamDiff",href:"http://streamdiff.com/"}]};FB.publish(a)},statusReady:function(){Herstory.init(StreamDiff.hashChange,"far/xd.html")},hashChange:function(c){if(c=="/"){Stream.view({})}else{if(c.indexOf("/profile/")===0){var b=c.substr(9).split("/",2),f=b[0],e=b[1]||0;Stream.view({source_id:f,offset:parseInt(e,10)})}else{if(c.indexOf("/filter/")===0){var b=c.substr(8).split("/",2),d=b[0],e=b[1]||0;Stream.view({filter_key:d,offset:parseInt(e,10)})}else{if(c.indexOf("/details/")===0){var b=c.substr(9).split("/",2),a=b[0],e=b[1]||0;Detail.view(a,e)}else{Herstory.load("/")}}}}},setMainView:function(a){document.getElementById("bd-container").innerHTML=a;Spinner.hide()},prettyDate:function(c){var b=new Date(c*1000),d=(((new Date()).getTime()-b.getTime())/1000),a=Math.floor(d/86400);if(isNaN(a)||a<0){return}return a===0&&(d<60&&"just now"||d<120&&"1 minute ago"||d<3600&&Math.floor(d/60)+" minutes ago"||d<7200&&"1 hour ago"||d<86400&&Math.floor(d/3600)+" hours ago")||a==1&&"Yesterday"||a<7&&a+" days ago"||a<31&&Math.ceil(a/7)+" weeks ago"||Math.floor(a/30)+" months ago"},linkyText:function(b){var a=/(\b(https?|ftp|file):\/\/[\-A-Z0-9+&@#\/%?=~_|!:,.;]*[\-A-Z0-9+&@#\/%=~_|])/i;return b.replace(a,'<a href="$1">$1</a>')},prettyNumber:function(b){b=b.toString();var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b},fql:function(b,a){var e=typeof b!="string";function d(f){if(f.error_code){Intro.view();return}if(e){var h={};for(var g=0,c=f.length;g<c;g++){h[f[g].name]=f[g].fql_result_set}f=h}a(f)}if(e){FB.api({method:"Fql.multiquery",queries:JSON.stringify(b)},d)}else{FB.api({method:"Fql.query",query:b},d)}},copy:function(d,c,a){for(var b in c){if(a||!(b in d)){d[b]=c[b]}}return d}};var Cache={put:function(b,c,a){b=FB.getSession().uid+b;c=JSON.stringify({value:c,expires:a?new Date().getTime()+(a*1000):null});if(window.localStorage){localStorage[b]=c}else{if(window.globalStorage){globalStorage[window.location.host][b]=c}}},get:function(a){a=FB.getSession().uid+a;var b;if(window.localStorage){b=window.localStorage[a]}else{if(window.globalStorage){b=window.globalStorage[window.location.host][a]}}if(b){try{b=JSON.parse(b.toString())}catch(c){Cache.remove(a);return null}if(b.expires&&new Date(b.expires)<new Date()){Cache.remove(a);return null}else{return b.value}}return null},remove:function(a){a=FB.getSession().uid+a;if(window.localStorage){window.localStorage[a]=""}else{if(window.globalStorage){window.globalStorage[window.location.host][a]=""}}},clear:function(){if(window.localStorage){window.localStorage.clear()}else{if(window.globalStorage){window.globalStorage.clear()}}}};StreamDiff.DOM={regexpCache:{},regexp:function(a){if(!StreamDiff.DOM.regexpCache[a]){StreamDiff.DOM.regexpCache[a]=new RegExp(a)}return StreamDiff.DOM.regexpCache[a]},_classRegexp:function(a){return StreamDiff.DOM.regexp("(?:^|\\s+)"+a+"(?:\\s+|$)")},hasClass:function(b,a){return StreamDiff.DOM._classRegexp(a).test(b.className)},removeClass:function(b,a){if(StreamDiff.DOM.hasClass(b,a)){b.className=b.className.replace(StreamDiff.DOM._classRegexp(a),"");StreamDiff.DOM.removeClass(b,a)}},addClass:function(b,a){if(!StreamDiff.DOM.hasClass(b,a)){b.className=b.className+" "+a}},getElementsByClassName:function(b,e){if(b.getElementsByClassName){return b.getElementsByClassName(e)}var g=b.all?b.all:b.getElementsByTagName("*"),f=[],c;for(var d=0,a=g.length;d<a;d++){c=g[d];if(StreamDiff.DOM.hasClass(c,e)){f.push(c)}}return f}};var Spinner={show:function(){document.getElementById("spinner").style.display="block"},hide:function(){document.getElementById("spinner").style.display="none"}};var Intro={view:function(){if(FB.getSession()){StreamDiff.fql({user:("SELECT name,pic_square,profile_url FROM user WHERE uid="+FB.getSession().uid),perms:("SELECT read_stream,publish_stream FROM permissions WHERE uid="+FB.getSession().uid)},Intro.render)}else{Intro.render()}},render:function(b){if(b){var a=b.user[0];UserInfo.render(a);if(b.perms[0].publish_stream&&b.perms[0].read_stream){Stream.view();return}}StreamDiff.setMainView('<div id="intro" class="bd"><div class="what"><p>StreamDiff provides an alternate view of your Facebook News Feed. It provides a <strong>Mark as read</strong> feature to allow focusing on just the new stuff. Comments and Like\'s will make a post fresh again, so you\'ll get all new content as  soon as its created!</p><p>In order to use StreamDiff, you must sign in with your Facebook account and allow access to your stream.</p></div><div class="buttons"><button class="connect" onclick="Intro.connect()">Connect with Facebook</button></div></div>')},connect:function(){FB.login(function(a){Stream.view()},"read_stream,publish_stream")}};var UserInfo={render:function(a){var b;if(!FB.getSession()){b=""}else{if(a){b=('<a class="pic" href="#/profile/'+a.id+'"><img src="'+a.pic_square+'"></a><a href="#/profile/'+a.id+'">'+a.name+'</a><br><a class="logout">Logout</a>');Cache.put("userInfo",b)}else{b=Cache.get("userInfo");if(!b){return}}}document.getElementById("user-info").innerHTML=b}};var Stream={_options:null,defaultOptions:{filter_key:"nf",source_id:null,offset:0,limit:30},_prefs:null,defaultPrefs:{show_read:true},_profiles:{},_posts:{},_read:{},init:function(){if(this._initListeners){return}this._initListeners=true;this._read=Cache.get("markAsRead")||{};this._prefs=Cache.get("prefs")||{};StreamDiff.copy(this._prefs,Stream.defaultPrefs);this.registerUnload();Delegator.listen("#stream .post .action-comment","click",function(){Comments.show(this)});Delegator.listen("#stream .post .action-like","click",function(){Stream.like(this)});Delegator.listen("#stream .post .video a","click",function(a){Stream.playVideo(this,a)});Delegator.listen("#stream .post .music a","click",function(a){Stream.playMusic(this,a)});Delegator.listen("#stream .mark-as-read","click",function(a){Stream.markAsRead()});Delegator.listen("#stream .show-read","click",function(a){Stream.showRead()});Delegator.listen("#stream .hide-read","click",function(a){Stream.hideRead()});Delegator.listen("#stream .show-older","click",function(a){Stream.showOlder()});Comments.init()},registerUnload:function(){var a=window.unload;window.onunload=function(){if(a){a()}Cache.put("markAsRead",Stream._read);Cache.put("prefs",Stream._prefs)}},view:function(c){c=c||Stream._options;StreamDiff.copy(c,Stream.defaultOptions);Stream._options=c;if(!FB.getSession()){Intro.view();return}UserInfo.render();var e=("SELECT post_id,created_time,updated_time,actor_id,target_id,message,attachment,comments,likes FROM stream WHERE ");if(c.source_id){e+='source_id="'+c.source_id+'"'}else{e+='filter_key="'+c.filter_key+'"'}e+=(" ORDER BY updated_time DESC LIMIT "+c.limit+" OFFSET "+c.offset);var d=Cache.get(Stream.cacheKey());if(d){StreamDiff.setMainView(d)}else{Spinner.show()}var a=("SELECT id,type,name,pic,pic_square,url FROM profile WHERE id IN (SELECT actor_id FROM #stream) OR id IN (SELECT target_id FROM #stream) OR id IN (SELECT comments.comment_list.fromid FROM #stream) OR id IN (SELECT likes.friends FROM #stream) OR id IN (SELECT likes.sample FROM #stream) OR id="+FB.getSession().uid);var b={stream:e,profiles:a};StreamDiff.fql(b,function(f){Stream.render(f,c)})},updateProfiles:function(b){var a=Stream._profiles;for(i=0,l=b.length;i<l;i++){var c=b[i];if(!c.pic_square){c.pic_square="http://static.ak.fbcdn.net/pics/q_silhouette.gif"}a[c.id+""]=c}return a},render:function(a,c){Stream.init();var e=a.stream,k=Stream.updateProfiles(a.profiles),r=Stream._read,j={},t,q;UserInfo.render(k[FB.getSession().uid]);var d=[];for(t=0,q=e.length;t<q;t++){var s=e[t];if(!Stream._prefs.show_read&&s.post_id in r&&r[s.post_id]==s.updated_time){continue}j[s.post_id]=s;d.push(Stream.renderPost(s,c))}var p=k[c.source_id],o="",m="What's on your mind?",g;if(p){o=('<div class="source-info"><a target="_blank" href="http://www.facebook.com/profile.php?id='+p.id+'"><img src="'+p.pic+'">'+p.name+"</a></div>");m="Write something…";g="StreamDiff — "+p.name}else{g="StreamDiff"}document.title=g;var f;if(d.length===0){f=Stream.renderCraving(j,c)}else{var b=Stream._prefs.show_read?'<button class="hide-read">Hide read posts</button>':'<button class="show-read">View read posts</button>';f=('<ul id="posts">'+d.join("")+'</ul><div class="craving-content"><button class="mark-as-read">Mark as Read</button> '+b+' <button class="show-older">Dig into the archives</button></div>')}var n=('<div id="stream" class="bd">'+o+Publisher.render(m)+Stream.renderFromTo(e,c)+f+"</div>");var h=Stream.cacheKey(c);if(d.length>0){Cache.put(h,n,3600)}else{Cache.remove(h)}if(JSON.stringify(Stream._options)==JSON.stringify(c)){Stream._posts=j;StreamDiff.setMainView(n)}},renderPost:function(c,a){var b=Stream,d=b._profiles[c.actor_id];return('<li class="post" id="post-'+c.post_id+'" data-post-id="'+c.post_id+'"><a class="actor-pic" href="#/profile/'+d.id+'"><img src="'+d.pic_square+'"></a><div class="bd">'+b.renderMessage(c,a)+b.renderAttachment(c,a)+b.renderMeta(c,a)+b.renderLikes(c,a)+b.renderComments(c,a)+'</div><div style="clear: left;"></div></li>')},renderMessage:function(c,b){var a=Stream._profiles,d=a[c.actor_id],e="";if(c.target_id&&b.source_id!=c.target_id){e=(' &#8227; <a class="actor" href="#/profile/'+c.target_id+'">'+a[c.target_id].name+"</a>")}return('<div class="message"><a class="actor" href="#/profile/'+d.id+'">'+d.name+"</a>"+e+" "+StreamDiff.linkyText(c.message||"")+"</div>")},renderAttachment:function(j,k){var f=j.attachment;if(!f){return""}var d=f.media&&f.media.length>0,g='<div class="attachment">';if(d){var h=f.media[0].type||"";g+='<div class="media '+h+'">';for(var e=0,c=f.media.length;e<c;e++){var b=f.media[e],a=b.src||(b.video&&b.video.preview_img);g+=('<a href="'+b.href+'"><img src="'+a+'">'+(b.type=="video"?'<span class="play"></span>':"")+"</a>")}g+="</div>"}if(f.name){g+=('<a class="name"'+(f.href?' href="'+f.href+'"':"")+">"+f.name+"</a>")}if(f.caption){g+='<div class="caption">'+f.caption+"</div>"}if(f.description){g+='<div class="description">'+f.description+"</div>"}if(d){g+='<div style="clear: left;"></div>'}g+="</div>";return g},renderMeta:function(c,a){var d="",b="";if(c.attachment&&c.attachment.icon){d='<img class="icon" src="'+c.attachment.icon+'">'}if(c.comments&&c.comments.can_post){b+=' &middot; <a class="action-comment">Comment</a>'}if(c.likes&&c.likes.can_like&&!c.likes.user_likes){b+=' &middot; <a class="action-like">Like</a>'}return('<div class="meta">'+d+'<span class="time">'+StreamDiff.prettyDate(c.created_time)+"</span>"+b+"</div>")},renderLikes:function(h,k){if(!h.likes.count){return""}var j=Stream._profiles,b=[],a=h.likes,e=h.likes.count,d,g;if(a.user_likes){b.push('<a href="#/profile/'+FB.getSession().uid+'">You</a>');e--}function f(p){if(p&&p.length>0){for(var n=0,m=p.length;n<m;n++){var o=p[n];b.push('<a href="#/profile/'+o+'">'+(j[o].name||"Facebook User")+"</a>")}e-=m}}f(a.friends);if(a&&a.sample&&((b.length>0&&Math.abs(e-a.sample.length)!=1)||a.count==a.sample.length)){f(a.sample)}if(e>0){var c='<a href="'+a.href+'">'+StreamDiff.prettyNumber(e);if(e==a.count){if(e==1){b.push(c+" person</a>")}else{b.push(c+" people</a>")}}else{b.push(c+" others</a>")}}if(b.length>1){g=b.pop()}d=b.join(", ");if(g){d+=" and "+g}if(a.count==1&&!a.user_likes){d+=" likes this."}else{d+=" like this."}return'<div class="sub">'+d+"</div>"},renderComments:function(f,c){var b=Stream._profiles,e="",d,a;if(f.comments.count>0){if(f.comments.count!=f.comments.comment_list.length){e+=('<div class="sub"><a href="#/details/'+f.post_id+'">View all '+StreamDiff.prettyNumber(f.comments.count)+" comments.</a></div>")}for(d=0,a=f.comments.comment_list.length;d<a;d++){var h=f.comments.comment_list[d];e+=('<div class="sub comment"><a class="from-pic" href="#/profile/'+h.fromid+'"><img src="'+(b[h.fromid]||{}).pic_square+'"></a><div class="bd"><div class="hd"><a href="#/profile/'+h.fromid+'">'+((b[h.fromid]||{}).name||"Facebook User")+"</a>"+StreamDiff.prettyDate(h.time)+"</div>"+StreamDiff.linkyText(h.text)+'</div><div style="clear: left;"></div></div>')}}if(f.comments&&f.comments.can_post){var g=e===""?' style="display: none;"':"";e+=('<form onsubmit="return Comments.submit(this)" class="sub post-comment"'+g+'><img src="'+b[FB.getSession().uid].pic_square+'"><textarea name="text">Write a comment…</textarea><div class="buttons"><input type="submit" class="button" value="Comment"></div></form>')}return e},renderCraving:function(b,a){var c;if(a.source_id){if(Stream._profiles[a.source_id]){c=Stream._profiles[a.source_id].name+"'s"}else{c="Facebook User's"}}else{c="Your"}return('<div class="no-content"><h2>'+c+' stream has no unread posts</h2><button class="show-read">View read posts</button> <button class="show-older">Dig into the archives</button></div>')},renderFromTo:function(c,a){var b="Viewing ";if(a.source_id){if(a.source_id==FB.getSession().uid){b+="your "}else{if(Stream._profiles[a.source_id]){b+=Stream._profiles[a.source_id].name+"'s "}}}if(a.offset){b+=(a.offset+"-"+(a.offset+a.limit)+" ")}b+="most recent ";if(!Stream._prefs.show_read){b+="unread "}b+="posts ";if(c.length>0){b+=("(from "+StreamDiff.prettyDate(c[0].updated_time)+" to "+StreamDiff.prettyDate(c[c.length-1].updated_time)+")")}return('<div class="from-to">'+b+"</div>")},cacheKey:function(a){a=a||Stream._options;return"stream"+JSON.stringify(a)},like:function(c){var b=Stream.findPostId(c);function a(){Cache.remove(Stream.cacheKey());var d=Stream._posts[b];d.likes.user_likes=true;if(d.likes.count){d.likes.count++}else{d.likes.count=1}Stream.refreshPost(b)}FB.api({method:"Stream.addLike",post_id:b},a)},playVideo:function(c,a){a.returnValue=false;if(a.preventDefault){a.preventDefault()}var j=Stream.findPost(c),e=j.getAttribute("data-post-id"),f=Stream._posts[e],d=f.attachment.media[0].video.source_url,g=StreamDiff.DOM.getElementsByClassName(j,"media")[0],k={allowfullscreen:"true",quality:"high",wmode:"transparent"};if(/video.ak.facebook.com/.test(d)){var h=f.attachment.media[0].video.display_url,b=/video.php\?v=(.*)/.exec(h)[1];k.allowscriptaccess="always";d="http://www.facebook.com/v/"+b}FlashReplace.replace(g,d,Math.random(),450,300,null,k)},playMusic:function(c,a){a.returnValue=false;if(a.preventDefault){a.preventDefault()}var j=Stream.findPost(c),e=j.getAttribute("data-post-id"),f=Stream._posts[e],d=f.attachment.media[0].video.source_url,g=StreamDiff.DOM.getElementsByClassName(j,"media")[0],k={allowfullscreen:"true",quality:"high",wmode:"transparent"};if(/video.ak.facebook.com/.test(d)){var h=f.attachment.media[0].video.display_url,b=/video.php\?v=(.*)/.exec(h)[1];k.allowscriptaccess="always";d="http://www.facebook.com/v/"+b}FlashReplace.replace(g,d,Math.random(),450,300,null,k)},markAsRead:function(){var b=Stream._posts,c=Stream._read,a;for(a in b){if(b.hasOwnProperty(a)){c[a]=b[a].updated_time}}Stream._prefs.show_read=false;Stream.refresh()},showRead:function(){Stream._prefs.show_read=true;Stream.refresh()},hideRead:function(){Stream._prefs.show_read=false;Stream.refresh()},refresh:function(){Stream.view();Spinner.show();window.scrollTo(0,0)},go:function(b){var a="";if(b.source_id){a+="/profile/"+b.source_id}else{a+="/filter/"+b.filter_key}if(b.offset>0){a+="/"+b.offset}Herstory.load(a);window.scrollTo(0,0)},showOlder:function(){var a=Stream._options;Stream.go(StreamDiff.copy({offset:a.offset+a.limit},a))},findPost:function(a){while(a&&a.getAttribute){var b=a.getAttribute("data-post-id");if(b){return a}a=a.parentNode}},findPostId:function(b){var a=Stream.findPost(b);if(a){return a.getAttribute("data-post-id")}},refreshPost:function(d){var c=Stream.renderPost(Stream._posts[d],Stream._options);var a=document.getElementById("post-"+d),b=document.createElement("ul");b.innerHTML=c;a.parentNode.replaceChild(b.firstChild,a)}};var Comments={init:function(){Delegator.listen(".post-comment textarea","focus",function(){Comments.focus(this)});Delegator.listen(".post-comment textarea","blur",function(){Comments.blur(this)})},show:function(b){var a=Stream.findPost(b),c=StreamDiff.DOM.getElementsByClassName(a,"post-comment")[0];c.style.display="block";c.text.focus()},submit:function(c){var b=Stream.findPostId(c),d=c.text.value;function a(f){Cache.remove(Stream.cacheKey());var e=Stream._posts[b];if(e.comments.count){e.comments.count++}else{e.comments.count=1}if(!e.comments.comment_list||!e.comments.comment_list.length){e.comments.comment_list=[]}e.comments.comment_list.push({fromid:FB.getSession().uid,time:(new Date().getTime()/1000),text:d});Stream.refreshPost(b)}FB.api({method:"Stream.addComment",post_id:b,comment:d},a);return false},focus:function(a){StreamDiff.DOM.addClass(a.form,"focused");if(a.value=="Write a comment…"){a.value=""}},blur:function(a){if(a.value===""){window.setTimeout(function(){StreamDiff.DOM.removeClass(a.form,"focused");a.value="Write a comment…"},400)}}};var Publisher={_blurTimer:null,_message:null,init:function(){if(Publisher._initListeners){return}Publisher._initListeners=true;Delegator.listen(".publisher #message","focus",function(){Publisher.focus(this)});Delegator.listen(".publisher #message","blur",function(){Publisher.blur(this)});Delegator.listen(".publisher #message","keyup",function(){Publisher.autoSize(this)});Delegator.listen(".publisher #message","mouseup",function(){Publisher.autoSize(this)})},render:function(a){Publisher.init();Publisher._message=a;return('<form class="publisher" onsubmit="return Publisher.submit()"><textarea id="message">'+a+'</textarea><div class="buttons"><input type="submit" class="button" value="share"></div></form>')},focus:function(a){if(Publisher._blurTimer){window.clearTimeout(Publisher._blurTimer)}if(a.value==Publisher._message){a.value=""}StreamDiff.DOM.addClass(a.form,"focused")},blur:function(a){if(!a.value){Publisher._blurTimer=window.setTimeout(function(){StreamDiff.DOM.removeClass(a.form,"focused");a.value=Publisher._message},400)}},autoSize:function(a){},submit:function(){var b=Stream._options.source_id||undefined,c=document.getElementById("message").value;function a(d){Cache.remove(Stream.cacheKey());var f=Stream._posts[d]={post_id:d,actor_id:FB.getSession().uid,target_id:b,message:c,created_time:(new Date().getTime()/1000),comments:{can_post:true,count:0},likes:{can_like:true,sample:[],friends:[],count:0},attachment:{icon:document.getElementById("favicon").href}};var g=document.getElementById("posts"),e=document.createElement("ul");e.innerHTML=Stream.renderPost(f,Stream._options);g.insertBefore(e.firstChild,g.firstChild);document.getElementById("message").value=""}FB.api({method:"Stream.publish",target_id:b,message:c},a);return false}};Detail={LIMIT:20,view:function(e,b){b=b||0;var c=('SELECT post_id,created_time,updated_time,actor_id,target_id,message,attachment,comments,likes FROM stream WHERE post_id="'+e+'"');var d=('SELECT fromid,time,text FROM comment WHERE post_id="'+e+'" LIMIT '+Detail.LIMIT+" OFFSET "+b);var a=("SELECT id,type,name,pic,pic_square,url FROM profile WHERE id IN (SELECT actor_id FROM #details) OR id IN (SELECT target_id FROM #details) OR id IN (SELECT fromid FROM #comments) OR id IN (SELECT likes.friends FROM #details) OR id IN (SELECT likes.sample FROM #details) OR id="+FB.getSession().uid);StreamDiff.fql({details:c,comments:d,profiles:a},Detail.render)},render:function(a){Stream.init();Stream.updateProfiles(a.profiles);var b=a.details[0];b.comments.comment_list=a.comments;StreamDiff.setMainView('<div id="stream" class="bd"><ul id="posts">'+Stream.renderPost(b,{})+"</ul></div>")}};