/**
 * @author mad@Max
 * Advanced Statistics by ChangUonDyU (rewrote by mad@Max)
 * Version 6.0.0.2.0
 */
function ChangStat(c,b,d,a){this.title=new Array();this.type=new Array();this.menu=null;this.fids=null;this.timer=null;this.tabs=null;this.sels=null;this.tops=null;this.topOn=false;this.intr=b;this.aRel=d;this.bburl=a;this.lpSel=fetch_object("clp_select");this.numRes=fetch_object("choosekq");this.rel=fetch_object("cas_rel");this.cookieRes=fetch_cookie("fcresult");this.tab=fetch_cookie("clastpost")||c}ChangStat.prototype.init=function(){if(this.cookieRes){this.numRes.value=this.cookieRes}this.regEvents();this.switcher(this.tab);if(this.topOn){this.loadTop()}if(this.aRel==1||this.aRel==0){var a=setInterval("ChangStat.posts()",1000*this.intr)}};ChangStat.prototype.loadTop=function(){for(var c=0;c<=deftop.length-1;c++){var b=deftop[c];var a=fetch_cookie("ctop_"+b[2]);if(a!=null){var d=a.split(":");this.top(d[0],d[1],b[2])}else{this.top(b[0],b[1],b[2])}}};ChangStat.prototype.switcher=function(a){if(a>0){this.menu="inforum";this.fids=listtab[a]}else{this.menu=listtab[a];this.fids=""}if(!this.lpSel){for(var b=0;typeof this.tabs[b]!="undefined";b++){this.tabs[b].style.color=(b==a)?"#000000":""}}else{fetch_object("clp_title").innerHTML=fetch_object("clp_option_"+a).innerHTML}if(this.tab!=a){set_cookie("clastpost",a)}this.posts()};ChangStat.prototype.posts=function(){var a=fetch_object("cprogress_post");a.style.display="inline";YAHOO.util.Connect.asyncRequest("POST","ajaxchangstat.php?do="+this.menu,{success:function(b){if(b.responseXML){fetch_object("changstats_latestposts").innerHTML=b.responseXML.getElementsByTagName("changlp")[0].firstChild.nodeValue;a.style.display="none"}},failure:vBulletin_AJAX_Error_Handler,timeout:vB_Default_Timeout,scope:this},SESSIONURL+"&securitytoken="+SECURITYTOKEN+"&do="+this.menu+this.fids+"&result="+this.numRes.value)};ChangStat.prototype.top=function(c,e,a){var b=c+":"+e;if(fetch_cookie("ctop_"+a)!=b){set_cookie("ctop_"+a,b)}var d=fetch_object("cprogress_top");var f=fetch_object("ctop_title_"+a);d.style.display="inline";f.innerHTML=vbphrase.changwait;this.title[a]=e;this.type[a]=c;YAHOO.util.Connect.asyncRequest("POST","ajaxchangstat.php?do="+c,{success:function(g){if(g.responseXML){f.innerHTML=e;fetch_object("changstats_topbox_"+a).innerHTML=g.responseXML.getElementsByTagName("changtop")[0].firstChild.nodeValue;d.style.display="none"}},failure:vBulletin_AJAX_Error_Handler,timeout:vB_Default_Timeout,scope:this},SESSIONURL+"&securitytoken="+SECURITYTOKEN+"&do="+c+"&result="+this.numRes.value)};ChangStat.prototype.rechooseTop=function(){for(var b=0;b<=deftop.length-1;b++){var a=deftop[b][2];this.top(this.type[a],this.title[a],a)}};ChangStat.prototype.regEvents=function(){if(this.rel){this.rel.obj=this;this.rel.onclick=function(f){this.obj.posts();return false}}if(this.numRes){this.numRes.obj=this;this.numRes.onchange=function(f){this.obj.posts();this.obj.rechooseTop();set_cookie("fcresult",this.value)}}if(!this.lpSel){this.tabs=fetch_tags(fetch_object("changtabs"),"a");for(var c=0;typeof this.tabs[c]!="undefined";c++){this.tabs[c].obj=this;this.tabs[c].num=c;this.tabs[c].onclick=function(f){this.obj.switcher(this.num);return false}}}else{this.sels=fetch_tags(fetch_object("clp_select_menu"),"td");for(var d=0;typeof this.sels[d]!="undefined";d++){this.sels[d].obj=this;this.sels[d].num=d;this.sels[d].onclick=function(f){};this.sels[d].onmouseup=function(f){this.obj.switcher(this.num)}}}for(var b=1;b<=4;b++){var e=fetch_object("ctop_select_"+b+"_menu");if(e){this.tops=fetch_tags(e,"td");for(var a=0;typeof this.tops[a]!="undefined";a++){this.tops[a].obj=this;this.tops[a].num=b;this.tops[a].onclick=function(f){};this.tops[a].onmouseup=function(f){this.obj.top(this.id,this.firstChild.innerHTML,this.num)}}this.topOn=true}}};
