Animator=function(B,A,F,D,E){this.step=5; this.rate=5; this.power=2; this.type=this.EASEINOUT; this.duration=0; this.min=B; this.max=A; this.isReversing=false; this.animateFunction=F; this.terminateFunction=D; this.reversalFunction=E; this.precalc=new Array(100); for(var C=0; C<=100; C++){this.precalc[C]=this.calculate(C) }}; Animator.prototype.NONE=0; Animator.prototype.EASEIN=1; Animator.prototype.EASEOUT=2; Animator.prototype.EASEINOUT=3; Animator.prototype.setDuration=function(A){this.duration=A }; Animator.prototype.setStep=function(A){this.step=A }; Animator.prototype.setRate=function(A){this.rate=A }; Animator.prototype.setPower=function(B){this.power=B; for(var A=0; A<=100; A++){this.precalc[A]=this.calculate(A) }}; Animator.prototype.setType=function(B){this.type=B; for(var A=0; A<=100; A++){this.precalc[A]=this.calculate(A) }}; Animator.prototype.setAnimateFunction=function(A){this.animateFunction=A }; Animator.prototype.start=function(){if(this.interval){return }this.time=0; this.startTime=new Date(); this.isReversing=false; this.interval=setInterval(this.method(this.animate),this.rate) }; Animator.prototype.reverse=function(){this.isReversing=(this.isReversing)?false:true }; Animator.prototype.stop=function(){if(this.interval){clearInterval(this.interval) }this.timeLeft=0; this.interval=null }; Animator.prototype.pause=function(){if(this.interval){clearInterval(this.interval) }this.interval=null; if(this.duration){var A=new Date()-this.startTime; this.timeElapsed=A }}; Animator.prototype.resume=function(){if(this.duration){var A=new Date().getTime(); this.startTime=new Date(A-this.timeElapsed) }this.interval=setInterval(this.method(this.animate),this.rate) }; Animator.prototype.isAnimating=function(){return Boolean(this.interval) }; Animator.prototype.animate=function(){var B=false; if(this.duration){var A=new Date()-this.startTime; if(A=0&&this.time<=100){this.animateFunction(this.precalc[this.time]); this.time=(this.isReversing)?this.time-this.step:this.time+this.step }else{B=true }}if(B){clearInterval(this.interval); this.animateFunction(this.max); this.interval=null; if(!this.isReversing&&this.terminateFunction){this.terminateFunction() }if(this.isReversing&&this.reversalFunction){this.reversalFunction() }}}; Animator.prototype.calculate=function(B){if(!this.duration){B=B/100 }var A; switch(this.type){case this.NONE:A=this.easeNone(B); break; case this.EASEIN:A=this.easeIn(B); break; case this.EASEOUT:A=this.easeOut(B); break; case this.EASEINOUT:A=this.easeInOut(B); break }return parseInt(this.min+A*(this.max-this.min)) }; Animator.prototype.easeNone=function(A){return A }; Animator.prototype.easeIn=function(A){return Math.pow(A,this.power) }; Animator.prototype.easeOut=function(A){return 1-this.easeIn(1-A) }; Animator.prototype.easeInOut=function(A){if(A<0.5){return this.easeIn(A*2)/2 }return 0.5+this.easeOut((A-0.5)*2)/2 }; Animator.prototype.method=function(B){var A=this; return function(){return B.apply(A,arguments) } };