/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/_base/fx","./kernel ./config ./lang ../Evented ./Color ../aspect ../sniff ../dom ../dom-style".split(" "),function(u,C,f,D,h,n,E,x,p){var k=f.mixin,g={},y=g._Line=function(a,b){this.start=a;this.end=b};y.prototype.getValue=function(a){return(this.end-this.start)*a+this.start};var l=g.Animation=function(a){k(this,a);f.isArray(this.curve)&&(this.curve=new y(this.curve[0],this.curve[1]))};l.prototype=new D;f.extend(l,{duration:350,repeat:0,rate:20,_percent:0,_startRepeatCount:0,_getStep:function(){var a=
this._percent,b=this.easing;return b?b(a):a},_fire:function(a,b){var e=b||[];if(this[a])if(C.debugAtAllCosts)this[a].apply(this,e);else try{this[a].apply(this,e)}catch(d){}return this},play:function(a,b){this._delayTimer&&this._clearTimer();if(b)this._stopTimer(),this._active=this._paused=!1,this._percent=0;else if(this._active&&!this._paused)return this;this._fire("beforeBegin",[this.node]);var e=a||this.delay,d=f.hitch(this,"_play",b);if(0<e)return this._delayTimer=setTimeout(d,e),this;d();return this},
_play:function(a){this._delayTimer&&this._clearTimer();this._startTime=(new Date).valueOf();this._paused&&(this._startTime-=this.duration*this._percent);this._active=!0;this._paused=!1;a=this.curve.getValue(this._getStep());this._percent||(this._startRepeatCount||(this._startRepeatCount=this.repeat),this._fire("onBegin",[a]));this._fire("onPlay",[a]);this._cycle();return this},pause:function(){this._delayTimer&&this._clearTimer();this._stopTimer();if(!this._active)return this;this._paused=!0;this._fire("onPause",
[this.curve.getValue(this._getStep())]);return this},gotoPercent:function(a,b){this._stopTimer();this._active=this._paused=!0;this._percent=a;b&&this.play();return this},stop:function(a){this._delayTimer&&this._clearTimer();if(!this._timer)return this;this._stopTimer();a&&(this._percent=1);this._fire("onStop",[this.curve.getValue(this._getStep())]);this._active=this._paused=!1;return this},destroy:function(){this.stop()},status:function(){return this._active?this._paused?"paused":"playing":"stopped"},
_cycle:function(){if(this._active){var a=(new Date).valueOf();a=0===this.duration?1:(a-this._startTime)/this.duration;1<=a&&(a=1);this._percent=a;this.easing&&(a=this.easing(a));this._fire("onAnimate",[this.curve.getValue(a)]);1>this._percent?this._startTimer():(this._active=!1,0<this.repeat?(this.repeat--,this.play(null,!0)):-1==this.repeat?this.play(null,!0):this._startRepeatCount&&(this.repeat=this._startRepeatCount,this._startRepeatCount=0),this._percent=0,this._fire("onEnd",[this.node]),!this.repeat&&
this._stopTimer())}return this},_clearTimer:function(){clearTimeout(this._delayTimer);delete this._delayTimer}});var q=0,r=null,z={run:function(){}};f.extend(l,{_startTimer:function(){this._timer||(this._timer=n.after(z,"run",f.hitch(this,"_cycle"),!0),q++);r||(r=setInterval(f.hitch(z,"run"),this.rate))},_stopTimer:function(){this._timer&&(this._timer.remove(),this._timer=null,q--);0>=q&&(clearInterval(r),r=null,q=0)}});var F=E("ie")?function(a){var b=a.style;b.width.length||"auto"!=p.get(a,"width")||
(b.width="auto")}:function(){};g._fade=function(a){a.node=x.byId(a.node);var b=k({properties:{}},a);a=b.properties.opacity={};a.start="start"in b?b.start:function(){return+p.get(b.node,"opacity")||0};a.end=b.end;a=g.animateProperty(b);n.after(a,"beforeBegin",f.partial(F,b.node),!0);return a};g.fadeIn=function(a){return g._fade(k({end:1},a))};g.fadeOut=function(a){return g._fade(k({end:0},a))};g._defaultEasing=function(a){return.5+Math.sin((a+1.5)*Math.PI)/2};var A=function(a){this._properties=a;for(var b in a){var e=
a[b];e.start instanceof h&&(e.tempColor=new h)}};A.prototype.getValue=function(a){var b={},e;for(e in this._properties){var d=this._properties[e],c=d.start;c instanceof h?b[e]=h.blendColors(c,d.end,a,d.tempColor).toCss():f.isArray(c)||(b[e]=(d.end-c)*a+c+("opacity"!=e?d.units||"px":0))}return b};g.animateProperty=function(a){var b=a.node=x.byId(a.node);a.easing||(a.easing=u._defaultEasing);a=new l(a);n.after(a,"beforeBegin",f.hitch(a,function(){var e={},d;for(d in this.properties){if("width"==d||
"height"==d)this.node.display="block";var c=this.properties[d];f.isFunction(c)&&(c=c(b));c=e[d]=k({},f.isObject(c)?c:{end:c});f.isFunction(c.start)&&(c.start=c.start(b));f.isFunction(c.end)&&(c.end=c.end(b));var t=0<=d.toLowerCase().indexOf("color"),B=function(v,w){var m={height:v.offsetHeight,width:v.offsetWidth}[w];if(void 0!==m)return m;m=p.get(v,w);return"opacity"==w?+m:t?m:parseFloat(m)};"end"in c?"start"in c||(c.start=B(b,d)):c.end=B(b,d);t?(c.start=new h(c.start),c.end=new h(c.end)):c.start=
"opacity"==d?+c.start:parseFloat(c.start)}this.curve=new A(e)}),!0);n.after(a,"onAnimate",f.hitch(p,"set",a.node),!0);return a};g.anim=function(a,b,e,d,c,t){return g.animateProperty({node:a,duration:e||l.prototype.duration,properties:b,easing:d,onEnd:c}).play(t||0)};k(u,g);u._Animation=l;return g});