var ACTIVITY=function(){function y(b){h("initialising");void 0!=b&&(e=b,g=myPanels.getPanel(e));q=YAHOO.util.Dom.get("divSAContainer"+e);YAHOO.util.Dom.get("divSAFooter"+e);z=YAHOO.util.Dom.get("divSAEmails"+e);YAHOO.util.Dom.get("divCurrentActivityMainBox")&&(l=!0,r=14);!g&&!l?YAHOO.util.Dom.setStyle("divSAFooter","display","none"):YAHOO.util.Dom.setStyle("divSAHeader","display","none");m=YAHOO.util.Dom.getFirstChild(q);YAHOO.util.Dom.setStyle(m,"display","none");n()}function s(){var b,a,d=(new Date).getTime(); if(0==f.length)n();else if(a=f[0].displayAt-d,0<a)h("next display in "+(a+10)),t=setTimeout(s,a+10);else{a=f.shift();if(a.act<A.length){var c,o,e=YAHOO.util.Dom.addClass;b=document.createElement("div");e(b,"divSALine");c=document.createElement("div");e(c,"divSAActivity");o=document.createElement("div");e(o,"divSATime");b.appendChild(c);b.appendChild(o);j=l?"#edf2f8"==j?"#ffffff":"#edf2f8":"#ffffcc"==j?"#ffffff":"#ffffcc";YAHOO.util.Dom.setStyle(b,"background-color",j);b={line:b,activity:c,time:o}; c=a.nck;b.activity.innerHTML='<span class="activitynick"><a href="#" onclick="SEXYADS.popWindow(\''+("/profiles/"+c+"?pop")+"'); return false\">"+c+"</a></span> "+A[a.act];a.isf&&YAHOO.util.Dom.setStyle(b.line,"background-color","#ffffcc"==j?"#ffccff":"#ffcccc");if((l||g)&&void 0!=a.ems)z.innerHTML=a.ems+" emails sent so far";YAHOO.util.Dom.insertBefore(b.line,m);m=b.line;a.newDiv=b;k.unshift(a);for(i=0;i<k.length;i++)a=k[i],c=Math.floor((d-a.displayAt)/1E3),60>c?b=c+"s":(b=Math.floor(c/60).toString(), c%=60,10>c&&(c="0"+c),b=b+":"+c),a.newDiv.time.innerHTML=b;k.length>r?(q.removeChild(k.pop().newDiv.line),d=500):(d=0,g&&g.center())}else d=0;t=setTimeout(s,d)}}function n(){var b={success:D},a;if(YAHOO.util.Connect.isCallInProgress(B))h("Request already in progress!");else{var d=(new Date).getTime();a=p+E;a>d?(u=setTimeout(n,a-d),h("Request too soon. Rescheduled in "+(a-d))):(a=0==v?"d="+w+"&n="+r:"s="+v,p=d,h("Requesting data at "+p),B=YAHOO.util.Connect.asyncRequest("POST","/activity/getActivity.php", b,a))}}function D(b){var a,d,c,e=(new Date).getTime(),g=e-p;try{if(void 0!==b.responseText&&""!==b.responseText&&YAHOO.lang.JSON.isValid(b.responseText))a=YAHOO.lang.JSON.parse(b.responseText),nNewActivities=f.length}catch(j){return}c=0==f.length?!0:!1;b=a.length;for(d=0;d<b;d++)a[d].displayAt=e+1E3*(w-a[d].age),f.push(a[d]);a=0;b=f.length;if(0<b)a=f[b-1].displayAt,h("last activity: "+a+" now: "+e+" diff: "+(a-e)),a=a-e-F,0>a&&(a=0),v=f[b-1].seq;c&&s();h("Got data. length="+f.length+" latency: "+ g+" Next request in "+a);C++;x+=g;h("ave latency "+Math.floor(x/C+0.5));u=setTimeout(n,a)}function h(b){if(G)try{console.log(b)}catch(a){}}var w=60,r=30,E=1E3*(w>>2),F=5E3,C=0,x=0,f=[],k=[],B={},p=0,v=0,u=0,t=0,j="#ffffcc",G=!1,A=[,"logs in","checks email","reads an email","posts in the forum","posts a photo comment","posts a profile comment","posts a blog comment","posts a blog entry","uploads a photo","uploads a video","reads a forum topic","browse erotic stories","enters chat"],q,z,m=null,l=!1, e="",g=!1;YAHOO.util.Event.onContentReady("divSAFooter",y);return{close:function(){clearTimeout(u);clearTimeout(t);g&&closePanel({panel:e})},initialise:y}}();
