function showActorChart(I,H,P,G,L,K){if($("#"+I).text()==""){var B=new Date("2009/01/01 00:00:00").getTime()-length/2;var R=[[0,0]];var Q=[[0,0]];var N=[[0,0]];var O=0;var M=0;var E=60;for(i=0;i<G.length;i++){R[R.length]=[G[i][0]+1,G[i][1]/chartstep];Q[Q.length]=[G[i][0]+1,G[i][2]/chartstep];N[N.length]=[G[i][0]+1,G[i][5]/chartstep]}R[R.length]=[R[R.length-1][0]+1,0];Q[Q.length]=[R[Q.length-1][0]+1,0];N[N.length]=[R[N.length-1][0]+1,0];var F=10;R=parspl(R,R.length-1,F);Q=parspl(Q,Q.length-1,F);N=parspl(N,N.length-1,F);for(i=0;i<R.length;i++){var D=B+Math.floor(R[i][0]*length);R[i]=[D,Math.floor(R[i][1])]}for(i=0;i<Q.length;i++){var D=B+Math.floor(Q[i][0]*length);Q[i]=[D,Math.floor(Q[i][1])]}for(i=0;i<N.length;i++){var D=B+Math.floor(N[i][0]*length);N[i]=[D,Math.floor(N[i][1])]}var C=getMarkings(L,B,K);var A=[{label:combatLocale("page.damageout"),data:R},{label:combatLocale("page.healingout"),data:Q},{label:threatLocale("page.threat"),data:N}];$.plot($("#"+I),A,{lines:{show:true,lineWidth:2},selection:{mode:"x"},legend:{show:true,container:$("#"+I+"-legend")},shadowSize:1,xaxis:{mode:"time",min:(new Date(H)).getTime(),max:(new Date(P)).getTime(),timeformat:"%M:%S"},grid:{backgroundColor:"#000000",color:"#ffffff",clickable:true,tickColor:"#101010",hoverable:true,autoHighlight:true,borderWidth:0.1,mouseActiveRadius:16,markings:C}});$("#"+I).bind("plotclick",function(T,U,S){if(S){clickableBrowseEvent(S.datapoint[0],S.seriesIndex,K)}else{}});var J;$("#"+I).bind("plothover",function(U,V,T){var S=getNearbyEvent(0,U,V,T,K,L);if(S){if(J!=V){J=V;$("#tooltip").remove();showTooltip(V.pageX,V.pageY,S)}}else{$("#tooltip").remove();J=null}})}}function clickableBrowseEvent(A,B,C){var D=new Date("2009/01/01 00:00:00").getTime()-length/2;openurl(bfid,C,getEventType(B,C),Math.floor((evbegintime+(A-D))/1000))}function getNearbyEvent(C,E,F,D,B,A){if(D){return getSeriesName(C,D.seriesIndex,D.series.label)+" : "+getPlotTime(D.datapoint[0])+" , "+D.datapoint[1]}else{return getMajorEvent(F.x,B,A)}return null}function getPlotTime(A){return new Date(A).format("MM:ss")}function getMajorEvent(N,G,C){if(C==null||C.length==0){return null}var L="";var K=new Date("2009/01/01 00:00:00").getTime()-length/2;for(i=0;i<C.length;i++){var I=C[i];var O=I[0];var D=I[2];var M=I[4];if(G=="ni"||O==2||D==G||M==G){var A=K+I[1];var Q=I[8];var E=A+getEventTimeGap(Q);var P=length/2;if(A-P<N&&E+P>N){var H=I[3];var B=I[5];var J=I[6];var F=I[7];L+=(L==""?"":"<br>")+getMajorEventContet(O,D,H,M,B,J,F)}}}return L==""?null:L}function getMajorEventContet(H,B,E,I,A,F,D){var C="page.event.type.dea";if(H!=1){if(I=="nil"||A=="nil"){C="page.event.type.put.notarget"}else{C="page.event.type.put"}}var G=eventLocale(C);if(H==1){G=G.replace("{target}",getMobName(B,E))}else{G=G.replace("{actor}",getMobName(B,E));G=G.replace("{target}",getMobName(I,A));G=G.replace("{spell}",D)}return G}function getSeriesName(C,A,B){if(C==0){switch(A){case 0:return"DPS";case 1:return"HPS";case 2:return"TPS"}}switch(C){case 2:return B+"(DPS)";case 3:return B+"(HPS)";case 4:return B+"(TPS)"}return""}function showTooltip(A,C,B){$('<div id="tooltip">'+B+"</div>").css({position:"absolute",display:"none",top:C+15,left:A+25,border:"1px solid #444444",padding:"2px","background-color":"#252525"}).appendTo("body").fadeIn(20)}function getMarkings(B,G,D){var F=[];if(B==null||B.length==0){return F}for(i=0;i<B.length;i++){var E=B[i];var I=E[0];var A=E[1];var C=E[2];var H=E[4];if(D=="ni"||I==2||C==D||H==D){var J=E[8];F[F.length]={xaxis:{from:G+A,to:G+A+getEventTimeGap(J)},color:getEventColor(I,J)}}}return F}function getEventColor(A,B){if(A==2){if(B>0){return"#001000"}return"#ffff80"}if(A==3||A==4){return"#084070"}return"red"}function getEventTimeGap(A){if(A>0){return A*1000}return length/10}function getEventType(A,B){if(B!="nil"){switch(A){case 0:return 1;case 1:return 2;case 2:return 1}}return 1}function parspl(A,B,C){var E,D;var H,G,F,P,N,L,J,I,M,K;P=0.5/C;var O=[];O[O.length]=[A[0][0],A[0][1]];for(E=0;E<B-1;E++){for(D=1;D<C;D++){H=D*P;G=H*H;F=G*H;N=4*G-H-4*F;L=1-10*G+12*F;J=H+8*G-12*F;I=4*F-2*G;M=N*A[E][0];if(A.length>E+1){M+=L*A[E+1][0]}else{M+=L*A[E][0]}if(A.length>E+2){M+=J*A[E+2][0]}else{M+=J*A[E][0]}if(A.length>E+3){M+=I*A[E+3][0]}else{M+=I*A[E][0]}K=N*A[E][1];if(A.length>E+1){K+=L*A[E+1][1]}if(A.length>E+2){K+=J*A[E+2][1]}if(A.length>E+3){K+=I*A[E+3][1]}if(Math.abs(M)<O[O.length-1][0]){M=O[O.length-1][0]}O[O.length]=[Math.abs(M),Math.abs(K)]}}return O}function getActors(C){var B=[];for(var A=0;A<C.length;A++){if(C[A].checked){B[B.length]=C[A].value}}return B}function showrealtimechart(B){if((B!="damageout"&&B!="healingout"&&B!="damagetaken")||realtimes.realtime.length==0||mevs.majorevent.length==0){$("#charttable").hide();return}$("#charttable").show();clearTbody("rtchart");clearTbody("rtchart-legend");var A=getActors($("input:checkbox"));if(A.length==0){$("#charttable").hide();return}renderrealtimechart("rtchart",(B=="damageout"?2:(B=="healingout"?3:4)),realtimes.realtime,chartbegintime,chartendtime,bfid,A,mevs.majorevent);this.location.hash="#realtime"}function getActorName(B){for(var A=0;A<actors.actor.length;A++){if(actors.actor[A].guid==B){return actors.actor[A].actorname}}return"Unknown"}function renderrealtimechart(L,D,J,K,S,N,A,O){if(A.length==0){return}var C=new Date("2009/01/01 00:00:00").getTime()-length/2;var P=[];var R=0;var Q=0;var H=60;for(i=0;i<A.length;i++){P[i]=[];P[i][0]=[0,0];var F=0;for(j=0;j<J.length;j++){if(A[i]==J[j][0]){P[i][P[i].length]=[J[j][1]+1,J[j][D]/chartstep]}}P[i][P[i].length]=[P[i][P[i].length-1][0]+1,0]}var I=10;for(i=0;i<P.length;i++){P[i]=parspl(P[i],P[i].length-1,I)}var B=[];for(i=0;i<P.length;i++){for(j=0;j<P[i].length;j++){var G=C+Math.floor(P[i][j][0]*length);P[i][j]=[G,Math.floor(P[i][j][1])]}B[B.length]={label:getActorName(A[i]),data:P[i]}}var E=getMarkings(O,C,"nil");$.plot($("#"+L),B,{lines:{show:true,lineWidth:2},selection:{mode:"x"},legend:{show:true,container:$("#"+L+"-legend")},shadowSize:1,xaxis:{mode:"time",min:(new Date(K)).getTime(),max:(new Date(S)).getTime(),timeformat:"%M:%S"},grid:{backgroundColor:"#000000",color:"#ffffff",clickable:true,tickColor:"#101010",hoverable:true,autoHighlight:true,borderWidth:0.1,mouseActiveRadius:16,markings:E}});$("#"+L).bind("plotclick",function(U,V,T){if(T){clickableBrowseEvent(T.datapoint[0],T.seriesIndex,"nil")}else{}});var M;$("#"+L).bind("plothover",function(V,W,U){var T=getNearbyEvent(D,V,W,U,"nil",O);if(T){if(M!=W){M=W;$("#tooltip").remove();showTooltip(W.pageX,W.pageY,T)}}else{$("#tooltip").remove();M=null}})}function renderreportdata(D,C,F,E){var B=[];for(var A=0;A<D.length;A++){if(D[A].rankable==F&&(E==""||D[A].suborg==E)){B[B.length]=[(new Date(D[A].shortdate)).getTime(),getdatabytype(D[A],C)]}}return B}function getkillcount(C,E,D){var B=0;for(var A=0;A<C.length;A++){if((E==0||C[A].rankable==E)&&(D==""||C[A].suborg==D)){B++}}return B}function displayKillcount(A,C,B){document.write(getkillcount(A,C,B))}function getdatabytype(B,A){if(A=="dps"){return B.dps}if(A=="dtps"){return B.dtps}if(A=="hps"){return B.hps}if(A=="tobossdps"){return B.tobossdps}if(A=="tps"){return B.tps}if(A=="ehps"){return B.ehps}if(A=="dtb"){return B.dtb}if(A=="fighttime"){return Math.floor(B.fighttime/1000)}return 0}function displayReport(C,G,B,F,D){var E=renderreportdata(C,B,F,D);if(E.length<2){return}E.sort(dynSortFnUp);$.plot($("#"+G),[E],{lines:{show:true,lineWidth:2},shadowSize:1,xaxis:{ticks:[],mode:"time",timeformat:"%m-%d"},yaxis:{tickFormatter:function(H){return B!="fighttime"?Math.floor(H/100)/10+"k":Math.floor(H)}},grid:{color:"#ffffff",tickColor:"#101010",hoverable:true,autoHighlight:true,borderWidth:0.1,mouseActiveRadius:16}});var A;$("#"+G).bind("plothover",function(J,K,I){var H=getReportTips(B,J,K,I);if(H){if(A!=K){A=K;$("#tooltip").remove();showTooltip(K.pageX,K.pageY,H)}}else{$("#tooltip").remove();A=null}})}function getReportTips(A,C,D,B){if(B){return getPlotDate(B.datapoint[0])+" , "+B.datapoint[1]}return null}function getPlotDate(A){return new Date(A).format("mm-dd")}function displayBossfightList(B,D,C){for(var A=0;A<B.length;A++){if(B[A].rankable==D&&(C==""||B[A].suborg==C)){document.write('<a href="'+webroot+"combat/"+B[A].id+'">'+B[A].time+"</a><br>")}}};