Tmobile.util.Anim=function(b,a,c,d){if(b){this.init(b,a,c,d)}};Tmobile.util.Anim.prototype={doMethod:function(b,c,a){return this.method(this.currentFrame,c,a-c,this.totalFrames)},setAttribute:function(b,c,a){Tmobile.util.Dom.setStyle(this.getEl(),b,c+a)},getAttribute:function(a){return parseFloat(Tmobile.util.Dom.getStyle(this.getEl(),a))},defaultUnit:"px",defaultUnits:{opacity:" "},init:function(d,h,g,b){var c=false;var e=null;var i=null;var f=0;var a={};d=Tmobile.util.Dom.get(d);this.attributes=h||{};this.duration=g||1;this.method=b||Tmobile.util.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=Tmobile.util.AnimMgr.fps;this.getEl=function(){return d};this.setDefault=function(k,l){if(l.constructor!=Array&&(l=="auto"||isNaN(l))){switch(k){case"width":l=d.clientWidth||d.offsetWidth;break;case"height":l=d.clientHeight||d.offsetHeight;break;case"left":if(Tmobile.util.Dom.getStyle(d,"position")=="absolute"){l=d.offsetLeft}else{l=0}break;case"top":if(Tmobile.util.Dom.getStyle(d,"position")=="absolute"){l=d.offsetTop}else{l=0}break;default:l=0}}a[k]=l};this.getDefault=function(k){return a[k]};this.isAnimated=function(){return c};this.getStartTime=function(){return e};this.animate=function(){if(this.isAnimated()){return false}this.onStart.fire();this._onStart.fire();this.totalFrames=(this.useSeconds)?Math.ceil(Tmobile.util.AnimMgr.fps*this.duration):this.duration;Tmobile.util.AnimMgr.registerElement(this);var k=this.attributes;var l=this.getEl();var n;for(var m in k){n=this.getAttribute(m);this.setDefault(m,n)}c=true;f=0;e=new Date()};this.stop=function(){if(!this.isAnimated()){return false}this.currentFrame=0;i=new Date();var k={time:i,duration:i-e,frames:f,fps:f/this.duration};c=false;f=0;this.onComplete.fire(k)};var j=function(){var r;var l=null;var q;var p;var m=this["attributes"];for(var o in m){p=m[o]["unit"]||this.defaultUnits[o]||this.defaultUnit;if(typeof m[o]["from"]!="undefined"){r=m[o]["from"]}else{r=this.getDefault(o)}if(typeof m[o]["to"]!="undefined"){l=m[o]["to"]}else{if(typeof m[o]["by"]!="undefined"){if(typeof r!=="string"){l=[];for(var n=0,k=r.length;n<k;++n){l[n]=r[n]+m[o]["by"][n]}}else{l=r+m[o]["by"]}}}if(l!==null&&typeof l!="undefined"){q=this.doMethod(o,r,l);if((o=="width"||o=="height"||o=="opacity")&&q<0){q=0}this.setAttribute(o,q,p)}}f+=1};this._onStart=new Tmobile.util.CustomEvent("_onStart",this);this.onStart=new Tmobile.util.CustomEvent("start",this);this.onTween=new Tmobile.util.CustomEvent("tween",this);this._onTween=new Tmobile.util.CustomEvent("_tween",this);this.onComplete=new Tmobile.util.CustomEvent("complete",this);this._onTween.subscribe(j)}};Tmobile.util.AnimMgr=new function(){var c=null;var b=[];var a=0;this.fps=200;this.delay=1;this.registerElement=function(e){if(e.isAnimated()){return false}b[b.length]=e;a+=1;this.start()};this.start=function(){if(c===null){c=setInterval(this.run,this.delay)}};this.stop=function(g){if(!g){clearInterval(c);for(var f=0,e=b.length;f<e;++f){if(b[f].isAnimated()){b[f].stop()}}b=[];c=null;a=0}else{g.stop();a-=1;if(a<=0){this.stop()}}};this.run=function(){for(var g=0,e=b.length;g<e;++g){var f=b[g];if(!f||!f.isAnimated()){continue}if(f.currentFrame<f.totalFrames||f.totalFrames===null){f.currentFrame+=1;if(f.useSeconds){d(f)}f.onTween.fire();f._onTween.fire()}else{Tmobile.util.AnimMgr.stop(f)}}};var d=function(f){var i=f.totalFrames;var h=f.currentFrame;var g=(f.currentFrame*f.duration*1000/f.totalFrames);var e=(new Date()-f.getStartTime());var j=0;if(e<f.duration*1000){j=Math.round((e/g-1)*f.currentFrame)}else{j=i-(h+1)}if(j>0&&isFinite(j)){if(f.currentFrame+j>=i){j=i-(h+1)}f.currentFrame+=j}}};Tmobile.util.Bezier=new function(){this.getPosition=function(e,d){var f=e.length;var c=[];for(var b=0;b<f;++b){c[b]=[e[b][0],e[b][1]]}for(var a=1;a<f;++a){for(b=0;b<f-a;++b){c[b][0]=(1-d)*c[b][0]+d*c[parseInt(b+1,10)][0];c[b][1]=(1-d)*c[b][1]+d*c[parseInt(b+1,10)][1]}}return[c[0][0],c[0][1]]}};Tmobile.util.Easing=new function(){this.easeNone=function(e,a,g,f){return a+g*(e/=f)};this.easeIn=function(e,a,g,f){return a+g*((e/=f)*e*e)};this.easeOut=function(f,e,i,h){var g=(f/=h)*f;var a=g*f;return e+i*(a+-3*g+3*f)};this.easeBoth=function(f,e,i,h){var g=(f/=h)*f;var a=g*f;return e+i*(-2*a+3*g)};this.backIn=function(f,e,i,h){var g=(f/=h)*f;var a=g*f;return e+i*(-3.4005*a*g+10.2*g*g+-6.2*a+0.4*g)};this.backOut=function(f,e,i,h){var g=(f/=h)*f;var a=g*f;return e+i*(8.292*a*g+-21.88*g*g+22.08*a+-12.69*g+5.1975*f)};this.backBoth=function(f,e,i,h){var g=(f/=h)*f;var a=g*f;return e+i*(0.402*a*g+-2.1525*g*g+-3.2*a+8*g+-2.05*f)}};Tmobile.util.Motion=function(b,a,c,d){if(b){this.initMotion(b,a,c,d)}};Tmobile.util.Motion.prototype=new Tmobile.util.Anim();Tmobile.util.Motion.prototype.defaultUnits.points="px";Tmobile.util.Motion.prototype.doMethod=function(c,f,a){var e=null;if(c=="points"){var d=this.getTranslatedPoints();var b=this.method(this.currentFrame,0,100,this.totalFrames)/100;if(d){e=Tmobile.util.Bezier.getPosition(d,b)}}else{e=this.method(this.currentFrame,f,a-f,this.totalFrames)}return e};Tmobile.util.Motion.prototype.getAttribute=function(a){var b=null;if(a=="points"){b=[this.getAttribute("left"),this.getAttribute("top")];if(isNaN(b[0])){b[0]=0}if(isNaN(b[1])){b[1]=0}}else{b=parseFloat(Tmobile.util.Dom.getStyle(this.getEl(),a))}return b};Tmobile.util.Motion.prototype.setAttribute=function(b,c,a){if(b=="points"){Tmobile.util.Dom.setStyle(this.getEl(),"left",c[0]+a);Tmobile.util.Dom.setStyle(this.getEl(),"top",c[1]+a)}else{Tmobile.util.Dom.setStyle(this.getEl(),b,c+a)}};Tmobile.util.Motion.prototype.initMotion=function(d,h,f,a){Tmobile.util.Anim.call(this,d,h,f,a);h=h||{};h.points=h.points||{};h.points.control=h.points.control||[];this.attributes=h;var b;var g=null;var c=null;this.getTranslatedPoints=function(){return c};var e=function(k,j){var l=Tmobile.util.Dom.getXY(j.getEl());k=[k[0]-l[0]+b[0],k[1]-l[1]+b[1]];return k};var i=function(){b=this.getAttribute("points");var k=this.attributes;var m=k.points["control"]||[];if(m.length>0&&m[0].constructor!=Array){m=[m]}if(Tmobile.util.Dom.getStyle(this.getEl(),"position")=="static"){Tmobile.util.Dom.setStyle(this.getEl(),"position","relative")}if(typeof k.points["from"]!="undefined"){Tmobile.util.Dom.setXY(this.getEl(),k.points["from"]);b=this.getAttribute("points")}else{if((b[0]===0||b[1]===0)){Tmobile.util.Dom.setXY(this.getEl(),Tmobile.util.Dom.getXY(this.getEl()));b=this.getAttribute("points")}}var l,j;if(typeof k.points["to"]!="undefined"){g=e(k.points["to"],this);for(l=0,j=m.length;l<j;++l){m[l]=e(m[l],this)}}else{if(typeof k.points["by"]!="undefined"){g=[b[0]+k.points["by"][0],b[1]+k.points["by"][1]];for(l=0,j=m.length;l<j;++l){m[l]=[b[0]+m[l][0],b[1]+m[l][1]]}}}if(g){c=[b];if(m.length>0){c=c.concat(m)}c[c.length]=g}};this._onStart.subscribe(i)};Tmobile.util.Scroll=function(b,a,c,d){if(b){Tmobile.util.Anim.call(this,b,a,c,d)}};Tmobile.util.Scroll.prototype=new Tmobile.util.Anim();Tmobile.util.Scroll.prototype.defaultUnits.scroll=" ";Tmobile.util.Scroll.prototype.doMethod=function(b,d,a){var c=null;if(b=="scroll"){c=[this.method(this.currentFrame,d[0],a[0]-d[0],this.totalFrames),this.method(this.currentFrame,d[1],a[1]-d[1],this.totalFrames)]}else{c=this.method(this.currentFrame,d,a-d,this.totalFrames)}return c};Tmobile.util.Scroll.prototype.getAttribute=function(b){var c=null;var a=this.getEl();if(b=="scroll"){c=[a.scrollLeft,a.scrollTop]}else{c=parseFloat(Tmobile.util.Dom.getStyle(a,b))}return c};Tmobile.util.Scroll.prototype.setAttribute=function(c,d,b){var a=this.getEl();if(c=="scroll"){a.scrollLeft=d[0];a.scrollTop=d[1]}else{Tmobile.util.Dom.setStyle(a,c,d+b)}};