ccl.Animate=new function(){var $=null,B=[],C=0;this.fps=1000;this.delay=1;var A=this;this.add=function(_){B[B.length]=_;C+=1;_.event.trigger("beforeplay");if($===null)$=setInterval(A.run,A.delay)};this.remove=function($,D){$.event.trigger("endplay");D=D||_($);if(D!=-1)B.splice(D,1);C-=1;if(C<=0)A.clear()};this.clear=function(_){if(!_){clearInterval($);for(var D=0,E=B.length;D<E;D++)if(B[D].played)A.remove(B[D],D);B=[];$=null;C=0}else A.remove(_)};this.run=function(){for(var _=0,C=B.length;_<C;_++){var $=B[_];if(!$||!$.played)continue;if($.currentFrame<$.totalFrames||$.totalFrames===null){$.currentFrame+=1;if($.useSeconds)D($);$.event.trigger("framechange")}else A.remove($,_)}};var _=function($){for(var _=0,A=B.length;_<A;_++)if(B[_]==$)return _;return-1},D=function($){var _=$.totalFrames,A=$.currentFrame,D=($.currentFrame*$.duration*1000/$.totalFrames),C=(new Date()-$.startTime),B=0;if(C<$.duration*1000)B=Math.round((C/D-1)*$.currentFrame);else B=_-(A+1);if(B>0&&isFinite(B)){if($.currentFrame+B>=_)B=_-(A+1);$.currentFrame+=B}}};ccl.Animate.Base=function(D,C,$,A){this.node=D;this.attributes=C||{};this.duration=$||0.5;this.method=A||ccl.Animate.Method.easeNone;this.played=false;this.useSeconds=true;this.currentFrame=0;this.totalFrames=1;this.startTime=null;this.runtime={};this.event=new ccl.Utility.Event();this.event.inject("beforeplay","endplay","framechange");var _=function(){for(var $ in this.attributes)this.setRuntime($);this.played=true;this.startTime=new Date()};this.event.on("beforeplay",_,this);var E=function(){for(var $ in this.runtime)this.setAttribute($,this.doMethod($))};this.event.on("framechange",E,this);var B=function(){this.played=false};this.event.on("endplay",B,this)};ccl.Animate.Base.prototype={patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i,color:/color$/i,transparent:/^transparent|rgba\(0, 0, 0, 0\)$/},doMethod:function(A){var D,G,F,B=this.currentFrame,E=this.totalFrames,_=this.runtime;D=_[A].start;G=_[A].end;if(_[A].type=="color"){F=[];for(var $=0,C=D.length;$<C;$++)F[$]=this.method(B,D[$],G[$]-D[$],E);F="rgb("+Math.floor(F[0])+","+Math.floor(F[1])+","+Math.floor(F[2])+")"}else F=this.method(B,D,G-D,E);return F+_[A].unit},setAttribute:function($,_){ccl.$ss(this.node,$,_)},getAttribute:function(C){var A=this.node,D=ccl.$gs(A,C);if(this.runtime[C].type=="color"){if(this.patterns.transparent.test(D)){var _=A.parentNode;D=ccl.$gs(_,C);while(_&&this.patterns.transparent.test(D)){_=_.parentNode;D=ccl.$gs(_,C);if(_.tagName.toUpperCase()=="HTML")D="#fff"}}}else{if(D!=="auto"&&!this.patterns.offsetUnit.test(D))return parseFloat(D);var $=this.patterns.offsetAttribute.exec(C)||[],_=!!($[3]),B=!!($[2]);if(B||ccl.$gs(A,"position")=="absolute"&&_)D=A["offset"+$[0].charAt(0).toUpperCase()+$[0].substr(1)];else D=0}return D},setRuntime:function(A){var _=this,E,F,B,D=this.attributes;this.runtime[A]={};if((D[A]["to"]==undefined)&&!D[A]["by"])return;this.runtime[A]={};if(this.patterns.color.test(A))this.runtime[A].type=B="color";else this.runtime[A].type=B="number";E=(D[A]["from"]!=undefined)?D[A]["from"]:this.getAttribute(A);if(B=="color")E=E.parseColor();if(D[A]["to"]!=undefined){F=D[A]["to"];if(B=="color")F=F.parseColor()}else if(D[A]["by"])if(B=="color"){F=D[A]["by"].parseColor();for(var $=0,C=E.length;$<C;$++)F[$]=E[$]+F[$]}else if(E.constructor==Array){F=[];for($=0,C=E.length;$<C;$++)F[$]=E[$]+D[A]["by"][$]}else F=E+D[A]["by"];this.runtime[A].start=E;this.runtime[A].end=F;this.runtime[A].unit=D[A].unit?D[A]["unit"]:(this.patterns.defaultUnit.test(A)?"px":"")},play:function($,_){if(typeof $=="function")this.event.on("endplay",function(){$.call(_||this,this)},this,{once:true});if(this.played)return false;this.currentFrame=0;this.totalFrames=(this.useSeconds)?Math.ceil(ccl.Animate.fps*this.duration):this.duration;ccl.Animate.add(this)}};ccl.Animate.Scroll=function(B,A,$,_){ccl.Animate.Scroll.superclass.constructor.call(this,B,A,$,_)};ccl.inherit(ccl.Animate.Scroll,ccl.Animate.Base,{doMethod:function(_){var A,$=this.runtime[_];if(_=="scroll")A=[this.method(this.currentFrame,$.start[0],$.end[0]-$.start[0],this.totalFrames),this.method(this.currentFrame,$.start[1],$.end[1]-$.start[1],this.totalFrames)];else A=this.constructor.superclass.doMethod.call(this,_);return A},getAttribute:function($){var A=[0,0],_=this.node;if($=="scroll")A=[_.scrollLeft,_.scrollTop];else A=this.constructor.superclass.getAttribute.call(this,$);return A},setAttribute:function($,A){var _=this.node;if($=="scroll"){_.scrollLeft=A[0];_.scrollTop=A[1]}else this.constructor.superclass.setAttribute.call(this,$,A)}});ccl.Animate.Motion=function(B,A,$,_){ccl.Animate.Motion.superclass.constructor.call(this,B,A,$,_)};ccl.inherit(ccl.Animate.Motion,ccl.Animate.Base,{setAttribute:function(_,B){var $=this.constructor.superclass,A=this.runtime[_].unit||"px";if(_=="points"){$.setAttribute.call(this,"left",B[0]+A);$.setAttribute.call(this,"top",B[1]+A)}else $.setAttribute.call(this,_,B)},getAttribute:function(_){var $=this.constructor.superclass;if(_=="points")var A=[ccl.$gs(this.node,"left"),ccl.$gs(this.node,"top")];else A=$.getAttribute.call(this,_);if(isNaN(A[0]))A[0]=0;if(isNaN(A[1]))A[1]=0;return A},doMethod:function(_){var D=[0,0],$=this.constructor.superclass,B=this.runtime[_].start,C=this.runtime[_].end;if(_=="points"){var A=this.method(this.currentFrame,0,100,this.totalFrames)/100;D=ccl.Animate.Method.bezier(this.runtime[_],A)}else D=$.doMethod.call(this,_);return D},setRuntime:function(E){var $=this.constructor.superclass;if(E!="points"){$.setRuntime.call(this,E);return}var H=function(_,B,A){var $=ccl.DOM.getXY(_);B=[B[0]-$[0]+A[0],B[1]-$[1]+A[1]];return B},C=this.attributes,I,J,_,G=this.node;_=C["points"]["control"]||[];if(_.length>0&&ccl.getType(_)!="array")_=[_];else{var F=[];for(var D=0,B=_.length;D<B;D++)F[D]=_[D];_=F}ccl.DOM.position(G);if(I=C["points"]["from"])ccl.DOM.setXY(G,I);else I=this.getAttribute("points");if(J=C["points"]["to"]){J=H(G,J,I);var A=ccl.DOM.getXY(G);for(D=0,B=_.length;D<B;D++)_[D]=H(G,_[D],I)}else if(J=C["points"]["by"]){J=[I[0]+J[0],I[1]+J[1]];for(D=0,B=_.length;D<B;D++)_[D]=[I[0]+_[D][0],I[1]+_[D][1]]}this.runtime[E]=[I];if(_.length>0)this.runtime[E]=this.runtime[E].concat(_);this.runtime[E][this.runtime[E].length]=J}});ccl.Animate.Method={easeNone:function(A,B,_,$){return _*A/$+B},easeIn:function(A,B,_,$){return _*(A/=$)*A+B},easeOut:function(A,B,_,$){return-_*(A/=$)*(A-2)+B},easeBoth:function(A,B,_,$){if((A/=$/2)<1)return _/2*A*A+B;return-_/2*((--A)*(A-2)-1)+B},easeInStrong:function(A,B,_,$){return _*(A/=$)*A*A*A+B},easeOutStrong:function(A,B,_,$){return-_*((A=A/$-1)*A*A*A-1)+B},easeBothStrong:function(A,B,_,$){if((A/=$/2)<1)return _/2*A*A*A*A+B;return-_/2*((A-=2)*A*A*A-2)+B},elasticIn:function(B,D,A,$,_,C){if(B==0)return D;if((B/=$)==1)return D+A;if(!C)C=$*0.3;if(!_||_<Math.abs(A)){_=A;var E=C/4}else E=C/(2*Math.PI)*Math.asin(A/_);return-(_*Math.pow(2,10*(B-=1))*Math.sin((B*$-E)*(2*Math.PI)/C))+D},elasticOut:function(B,D,A,$,_,C){if(B==0)return D;if((B/=$)==1)return D+A;if(!C)C=$*0.3;if(!_||_<Math.abs(A)){_=A;var E=C/4}else E=C/(2*Math.PI)*Math.asin(A/_);return _*Math.pow(2,-10*B)*Math.sin((B*$-E)*(2*Math.PI)/C)+A+D},elasticBoth:function(B,D,A,$,_,C){if(B==0)return D;if((B/=$/2)==2)return D+A;if(!C)C=$*(0.3*1.5);if(!_||_<Math.abs(A)){_=A;var E=C/4}else E=C/(2*Math.PI)*Math.asin(A/_);if(B<1)return-0.5*(_*Math.pow(2,10*(B-=1))*Math.sin((B*$-E)*(2*Math.PI)/C))+D;return _*Math.pow(2,-10*(B-=1))*Math.sin((B*$-E)*(2*Math.PI)/C)*0.5+A+D},backIn:function(A,B,_,$,C){if(typeof C=="undefined")C=1.70158;return _*(A/=$)*A*((C+1)*A-C)+B},backOut:function(A,B,_,$,C){if(typeof C=="undefined")C=1.70158;return _*((A=A/$-1)*A*((C+1)*A+C)+1)+B},backBoth:function(A,B,_,$,C){if(typeof C=="undefined")C=1.70158;if((A/=$/2)<1)return _/2*(A*A*(((C*=(1.525))+1)*A-C))+B;return _/2*((A-=2)*A*(((C*=(1.525))+1)*A+C)+2)+B},bounceIn:function(A,B,_,$){return _-ccl.Animate.Method.bounceOut($-A,0,_,$)+B},bounceOut:function(A,B,_,$){if((A/=$)<(1/2.75))return _*(7.5625*A*A)+B;else if(A<(2/2.75))return _*(7.5625*(A-=(1.5/2.75))*A+0.75)+B;else if(A<(2.5/2.75))return _*(7.5625*(A-=(2.25/2.75))*A+0.9375)+B;return _*(7.5625*(A-=(2.625/2.75))*A+0.984375)+B},bounceBoth:function(A,B,_,$){if(A<$/2)return ccl.Animate.Method.bounceIn(A*2,0,_,$)*0.5+B;return ccl.Animate.Method.bounceOut(A*2-$,0,_,$)*0.5+_*0.5+B},bezier:function(C,A){var D=C.length,_=[];for(var $=0;$<D;$++)_[$]=[C[$][0],C[$][1]];for(var B=1;B<D;B++)for($=0;$<D-B;++$){_[$][0]=(1-A)*_[$][0]+A*_[parseInt($+1,10)][0];_[$][1]=(1-A)*_[$][1]+A*_[parseInt($+1,10)][1]}return[_[0][0],_[0][1]]}}