// ZIM js Interactive Media modules by Dan Zen http://danzen.com (c) 2016
// zimbuild.js adds common building functions for digidos (interactive media) http://zimjs.com
// free to use - donations welcome of course! http://zimjs.com/donate
// classes in this module require createjs namespace to exist and in particular easel.js
// available at http://createjs.com
// (borrows zim.ProportionDamp from ZIM code)
if("undefined"==typeof zog)document.write(''),document.write('');else var zim=function(t){function e(t,e){e?(t.mouseChildren=!0,t.mouseEnabled=!0,t._enabled=!0):(t.mouseChildren=!1,t.mouseEnabled=!1,t._enabled=!1)}return zon&&zog("ZIM BUILD Module"),t.ProportionDamp=function(e,o,n,i,r,a,s){function h(){isNaN(u)||(u=Math.max(u,e),u=Math.min(u,o),l=(u-e)/(o-e),g=i-n,p=a>0?n+g*l:i-g*l,z=p,f=z-w,w+=f*b.damp)}var d,c="baseMin, baseMax, targetMin, targetMax, damp, factor, targetRound";if(d=zob(t.ProportionDamp,arguments,c))return d;zot(n)&&(n=0),zot(i)&&(i=1),zot(r)&&(r=.1),zot(a)&&(a=1),zot(s)&&(s=!1),this.damp=r;var u,l,g,p,f,b=this,z=0,w=0;u=e,w=n;var v=setInterval(h,20);this.immediate=function(t){b.convert(t),h(),w=p,s&&(w=Math.round(w))},this.convert=function(t){return u=t,s?Math.round(w):w},this.dispose=function(){clearInterval(v)}},t.Circle=function(e,o,n,i){function r(){zot(e)&&(e=50),zot(o)&&(o="black");var r=this;this.mouseChildren=!1;var a=this.shape=new createjs.Shape;this.addChild(a);var s=a.graphics,h=s.beginFill(o).command;if(!zot(n)){var d=s.beginStroke(n).command;zot(i)&&(i=1);var c=s.setStrokeStyle(i).command}s.dc(0,0,e),this.width=2*e,this.height=2*e,this.setBounds(-e,-e,this.width,this.height),this.setFill=function(t){zot(t)||(o=t,h.style=o)},Object.defineProperty(r,"color",{get:function(){return o},set:function(t){r.setFill(t)}}),this.setStroke=function(t){d&&!zot(t)&&(n=t,d.style=n)},this.setStrokeSize=function(t){c&&!zot(t)&&(i=t,c.width=i)},this.clone=function(){return new t.Circle(e,o,n,i)}}var a,s="radius, fill, stroke, strokeSize";return(a=zob(t.Circle,arguments,s))?a:(r.prototype=new createjs.Container,r.prototype.constructor=t.Circle,new r)},t.Rectangle=function(e,o,n,i,r,a){function s(){zot(e)&&(e=100),zot(o)&&(o=100),zot(n)&&(n="black"),zot(a)&&(a=0);var s=this;this.mouseChildren=!1;var h=this.shape=new createjs.Shape;this.addChild(h);var d=h.graphics,c=d.beginFill(n).command;if(!zot(i)){var u=d.beginStroke(i).command;zot(r)&&(r=1);var l=d.setStrokeStyle(r).command}a>0?d.rr(0,0,e,o,a):d.r(0,0,e,o),this.width=e,this.height=o,this.setBounds(0,0,this.width,this.height),this.setFill=function(t){zot(t)||(n=t,c.style=n)},Object.defineProperty(s,"color",{get:function(){return n},set:function(t){s.setFill(t)}}),this.setStroke=function(t){u&&!zot(t)&&(i=t,u.style=i)},this.setStrokeSize=function(t){l&&!zot(t)&&(r=t,l.width=r)},this.clone=function(){return new t.Rectangle(e,o,n,i,r,a)}}var h,d="width, height, fill, stroke, strokeSize, corner";return(h=zob(t.Rectangle,arguments,d))?h:(s.prototype=new createjs.Container,s.prototype.constructor=t.Rectangle,new s)},t.Triangle=function(e,o,n,i,r,a,s,h){function d(){zot(e)&&(e=100),zot(o)&&(o=e),zot(n)&&(n=e),-1==n&&(n=Math.sqrt(Math.pow(e,2)+Math.pow(o,2))),zot(i)&&(i="black"),zot(s)&&(s=!0),zot(h)&&(h=0),this.mouseChildren=!1;var d=this,c=[e,o,n];if(c.sort(function(t,e){return e-t}),aa=c[0],bb=c[1],cc=c[2],aa>bb+cc)return void zog("zim build - Triangle(): invalid triangle lengths");var u=this.shape=new createjs.Shape;this.addChild(u);var l=u.graphics,g=l.beginFill(i).command;if(!zot(r)){var p=l.beginStroke(r).command;zot(a)&&(a=1);var f=l.setStrokeStyle(a).command}l.mt(0,0),l.lt(e,0);var b,z=180*Math.acos((Math.pow(bb,2)+Math.pow(cc,2)-Math.pow(aa,2))/(2*bb*cc))/Math.PI,w=180*Math.asin(bb*Math.sin(z*Math.PI/180)/aa)/Math.PI,v=180-z-w;b=n==aa?z:n==bb?w:v;var m=Math.cos(b*Math.PI/180)*o,y=Math.sin(b*Math.PI/180)*o;this.width=Math.max(e,e-m),this.height=y,this.setBounds(0,0,this.width,this.height),u.y=this.height,l.lt(e-m,0-y),l.cp(),s&&(this.regX=this.width/2,this.regY=this.height/2+h),this.setFill=function(t){zot(t)||(i=t,g.style=i)},Object.defineProperty(d,"color",{get:function(){return i},set:function(t){d.setFill(t)}}),this.setStroke=function(t){p&&!zot(t)&&(r=t,p.style=r)},this.setStrokeSize=function(t){f&&!zot(t)&&(a=t,f.width=a)},this.clone=function(){return new t.Triangle(e,o,n,i,r,a,s,h)}}var c,u="a, b, c, fill, stroke, strokeSize, center, adjust";return(c=zob(t.Triangle,arguments,u))?c:(d.prototype=new createjs.Container,d.prototype.constructor=t.Triangle,new d)},t.Label=function(o,n,i,r,a,s,h){function d(){zot(o)&&(o="LABEL"),""==o&&(o=" "),zot(n)&&(n=36),zot(i)&&(i="arial"),zot(r)&&(r="black"),zot(a)&&(a=r),zot(s)&&(s=null),zot(h)&&(h=16);var d=this;this.mouseChildren=!1;var c=this.label=new createjs.Text(String(o),n+"px "+i,r);c.textBaseline="alphabetic",c.textAlign="left",s&&h>0&&(c.shadow=new createjs.Shadow(s,3,3,h)),this.addChild(c);var u=new createjs.Shape;u.graphics.f("black").r(0,0,this.getBounds().width,this.getBounds().height),this.hitArea=u,this.width=this.getBounds().width,this.height=this.getBounds().height,this.setBounds(0,0,this.width,this.height),c.y=n-n/6,Object.defineProperty(d,"text",{get:function(){var t=" "==c.text?"":c.text;return t},set:function(t){zot(t)&&(t=" "),c.text=t,d.setBounds(0,0,c.getBounds().width,c.getBounds().height)}}),this._enabled=!0,Object.defineProperty(d,"enabled",{get:function(){return d._enabled},set:function(t){e(d,t)}}),this.showRollColor=function(t){zot(t)&&(t=!0),t?c.color=a:c.color=r,d.getStage()&&d.getStage().update()},this.on("mouseover",function(t){d.showRollColor()}),this.on("mouseout",function(t){d.showRollColor(!1)}),this.clone=function(){return new t.Label(d.text,n,i,r,a,s,h)},this.dispose=function(){d.removeAllEventListeners()}}var c,u="text, size, font, color, rollColor, shadowColor, shadowBlur";return(c=zob(t.Label,arguments,u))?c:(d.prototype=new createjs.Container,d.prototype.constructor=t.Label,new d)},t.Button=function(o,n,i,r,a,s,h,d,c,u,l){function g(){function g(t){f.on("mouseout",p);var e=b.graphics;e.clear(),e.f(a),s&&e.s(s).ss(h),e.rr(0,0,o,n,d),f.label.showRollColor(),f.getStage()&&f.getStage().update()}function p(t){f.off("mouseout",p);var e=b.graphics;e.clear(),e.f(r),s&&e.s(s).ss(h),e.rr(0,0,o,n,d),f.label.showRollColor(!1),f.getStage()&&f.getStage().update()}zot(o)&&(o=200),zot(n)&&(n=60),zot(r)&&(r="#C60"),zot(a)&&(a="#F93"),zot(s)&&(s=null),zot(h)&&(h=1),zot(d)&&(d=20),zot(c)&&(c="rgba(0,0,0,.3)"),zot(u)&&(u=16),zot(l)&&(l=0),zot(i)&&(i="PRESS"),("string"==typeof i||"number"==typeof i)&&(i=new t.Label(i,36,"arial","white"));var f=this;this.mouseChildren=!1,this.cursor="pointer";var b=new createjs.Shape,z=b.graphics;if(z.f(r),s&&z.s(s).ss(h),z.rr(0,0,o,n,d),this.addChild(b),this.backing=b,l>0){var w=new createjs.Shape;w.graphics.f("#000").r(-l,-l,o+2*l,n+2*l),this.hitArea=w}u>0&&(b.shadow=new createjs.Shadow(c,3,3,u)),this.setBounds(0,0,o,n),this.width=o,this.height=n,i.x=(o-i.getBounds().width)/2+1,i.y=(n-i.getBounds().height)/2+2,this.addChild(i),this.label=i,Object.defineProperty(f,"text",{get:function(){var t=" "==i.text?"":i.text;return t},set:function(t){i.text=t,i.x=(o-i.getBounds().width)/2+1,i.y=(n-i.getBounds().height)/2+2}}),this._enabled=!0,Object.defineProperty(f,"enabled",{get:function(){return f._enabled},set:function(t){e(f,t)}}),this.on("mouseover",g),this.dispose=function(){f.removeAllEventListeners(),f.removeChild(b),f.removeChild(buttonLabel),b=null,buttonLabel=null}}var p,f="width, height, label, color, rollColor, borderColor, borderThickness, corner, shadowColor, shadowBlur, hitPadding";return(p=zob(t.Button,arguments,f))?p:(g.prototype=new createjs.Container,g.prototype.constructor=t.Button,new g)},t.CheckBox=function(o,n,i,r,a){function s(){function s(t){h=!h,d.setChecked(h),d.dispatchEvent("change")}zot(o)&&(o=60),zot(n)&&(n=null),("string"==typeof n||"number"==typeof n)&&(n=new t.Label(n,5*o/6,"arial",r));var h=zot(i)?!1:i;zot(r)&&(r="black"),zot(a)&&(a=10),this.setBounds(-a,-a,o+2*a,o+2*a);var d=this;this.cursor="pointer";var c=new createjs.Shape,u=c.graphics;u.f("rgba(255,255,255,.5)").r(0,0,o,o),u.s(r).ss(o/10).r(o/7,o/7,o-o/7*2,o-o/7*2),this.addChild(c);var l=o;n&&(this.addChild(n),n.x=1.3*o+a,n.y=o/8,this.label=n,this.setBounds(-a,-a,o+3*a+n.getBounds().width,Math.max(o+2*a,n.getBounds().height)),l=n.x+n.width);var g=new createjs.Shape;u=g.graphics,u.f("rgba(0,0,0,.01)").r(this.getBounds().x,this.getBounds().y,l+2*a,this.getBounds().height),this.hitArea=g;var p=new createjs.Shape,f=p.graphics,b="#000";f.f(b).p("AnQAdICBiaIEEDZIF8nfICfB4In/KPg");var z=95;p.setBounds(-z/2,-z/2,z,z);var w=o/(z+66);p.scaleX=p.scaleY=w,p.alpha=.9,p.x=o/2,p.y=o/2,h&&this.addChild(p),this.on("click",s),Object.defineProperty(d,"checked",{get:function(){return h},set:function(t){d.checked!=t&&d.dispatchEvent("change"),d.setChecked(t)}}),Object.defineProperty(p,"color",{get:function(){return b},set:function(t){h&&d.removeChild(p),p=new createjs.Shape,f=p.graphics,b=t,f.f(b).p("AnQAdICBiaIEEDZIF8nfICfB4In/KPg"),p.scaleX=p.scaleY=w,p.alpha=.9,p.x=o/2,p.y=o/2,h&&d.addChild(p),d.getStage()&&d.getStage().update()}}),Object.defineProperty(d,"check",{get:function(){return p},set:function(t){zog("ZIM CheckBox - check is read only")}}),this._enabled=!0,Object.defineProperty(d,"enabled",{get:function(){return d._enabled},set:function(t){e(d,t)}}),this.setChecked=function(t){zot(t)&&(t=!0),h=t,h?d.addChild(p):d.removeChild(p),d.getStage()&&d.getStage().update()},this.dispose=function(){d.removeAllEventListeners()}}var h,d="size, label, startChecked, color, margin";return(h=zob(t.CheckBox,arguments,d))?h:(s.prototype=new createjs.Container,s.prototype.constructor=t.CheckBox,new s)},t.RadioButtons=function(o,n,i,r,a,s,h){function d(){function d(t){var e=p.getChildIndex(t.target);h&&l.selectedIndex==e||(l.setSelected(e),l.dispatchEvent("change"))}function c(){for(var e,s=!1,h=n.length-1;h>=0;h--)e=n[h],e.selected&&e.selected===!0&&(s?e.selected="false":(s=!0,l.id=e.id));p.removeAllChildren();for(var d,c=0,h=0;h=0){e=p.getChildAt(t);var n=-2;g&&(n=g.index),g=e.obj}-1==t||n==g.index?(g=null,l.id=null,l.label=null,l.text=""):(e.addChild(e.check),l.id=g.id,l.label=g.label,l.label&&(l.text=l.label.text)),l.getStage()&&l.getStage().update()}},Object.defineProperty(l,"selected",{get:function(){return g},set:function(t){zog("ZIM RadioButton - selected is read only")}}),Object.defineProperty(l,"selectedIndex",{get:function(){return g?g.index:-1},set:function(t){var e=t;h&&l.selectedIndex==e||(l.setSelected(e),l.dispatchEvent("change"))}}),this._enabled=!0,Object.defineProperty(l,"enabled",{get:function(){return l._enabled},set:function(t){e(l,t)}}),this.dispose=function(){l.removeAllEventListeners()}}}var c,u="size, buttons, vertical, color, spacing, margin, always";return(c=zob(t.RadioButtons,arguments,u))?c:(d.prototype=new createjs.Container,d.prototype.constructor=t.RadioButtons,new d)},t.Pane=function(e,o,n,i,r,a,s,h,d,c,u,l,g){function p(){function p(t,i){return t=Math.max(o/2,Math.min(e.getBounds().width-o/2,t)),i=Math.max(n/2,Math.min(e.getBounds().height-n/2,i)),{x:t,y:i}}if(zot(e)||!e.getBounds)return void zog("zim build - Pane(): Please pass in a reference to a container with bounds set as first parameter");if(!e.getBounds())return void zog("zim build - Pane(): Please give the container bounds using setBounds()");if(zot(e.getStage))return void zog("zim build - Pane(): Please give the container that has a stage property");zot(o)&&(o=200),zot(n)&&(n=200),zot(i)&&(i=null),("string"==typeof i||"number"==typeof i)&&(i=new t.Label(i,40,"arial","black")),zot(r)&&(r="white"),zot(a)&&(a=!1),zot(s)&&(s=!0),zot(h)&&(h=!0),zot(d)&&(d=20),zot(c)&&(c=.14),zot(u)&&(u="rgba(0,0,0,.3)"),zot(l)&&(l=20),zot(g)&&(g=!0);var f=this.backing=new createjs.Shape,b=f.graphics;b.beginFill("black"),b.drawRect(-5e3,-5e3,1e4,1e4),this.setBounds(-o/2,-n/2,o,n),f.alpha=c;var z=this;f.on("click",function(t){z.hide(),z.dispatchEvent("close"),t.stopImmediatePropagation()}),f.on("mousedown",function(t){t.stopImmediatePropagation()}),h&&this.addChild(f);var w=this.display=new createjs.Shape;if(w.setBounds(0,0,o,n),w.regX=o/2,w.regY=n/2,b=w.graphics,b.beginFill(r),b.drawRoundRect(0,0,o,n,d),l>0&&(w.shadow=new createjs.Shadow(u,8,8,l)),w.on("click",function(t){t.stopImmediatePropagation()}),this.resetX,this.resetY,a){w.cursor="pointer";var v,m;w.on("mousedown",function(t){isNaN(z.resetX)&&(z.resetX=z.x),isNaN(z.resetY)&&(z.resetY=z.y),v=t.stageX-z.x,m=t.stageY-z.y,w.cursor="move"}),w.on("pressmove",function(t){var o=p(t.stageX-v,t.stageY-m);z.x=o.x,z.y=o.y,e.getStage().update()}),this.on("pressup",function(t){w.cursor="pointer"})}this.addChild(w),i&&(g&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2),this.addChild(i),this.label=i,this.text=i.text),Object.defineProperty(z,"text",{get:function(){var t=" "==i.text?"":i.text;return t},set:function(t){i.text=t,g&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2)}}),this.hide=function(){e.removeChild(z),e.getStage().update(),s&&(isNaN(z.resetX)||(z.x=z.resetX),isNaN(z.resetY)||(z.y=z.resetY))},this.show=function(){g&&(isNaN(z.resetX)&&(z.x=e.getBounds().width/2,z.y=e.getBounds().height/2),i&&(i.x=-i.getBounds().width/2,i.y=-i.getBounds().height/2)),e.addChild(z),e.getStage().update()},this.dispose=function(){w.removeAllEventListeners(),z.removeChild(w),w=null}}var f,b="container, width, height, label, color, drag, resets, modal, corner, backingAlpha, shadowColor, shadowBlur, center";return(f=zob(t.Pane,arguments,b))?f:(p.prototype=new createjs.Container,p.prototype.constructor=t.Pane,new p)},t.Waiter=function(e,o,n,i,r,a,s){function h(){if(zot(e)||!e.getBounds)return void zog("zim build - Waiter(): Please pass in a reference to a container with bounds set as first parameter");if(!e.getBounds())return void zog("zim build - Waiter(): Please give the container bounds using setBounds()");if(zot(e.getStage))return void zog("zim build - Waiter(): Please give the container that has a stage property");zot(o)&&(o=600),zot(n)&&(n="orange"),zot(i)&&(i="white"),zot(r)&&(r=16),zot(a)&&(a="#444"),zot(s)&&(s=14);var t=40,h=3,d=.6*t/2,c=(t-2*d)/2,u=h*(2*d+c)+c;this.setBounds(-u/2,-t/2,u,t);var l=this,g=this.display=new createjs.Shape;this.addChild(g),g.setBounds(0,0,u,t),g.regX=u/2,g.regY=t/2;var p=g.graphics;p.f(n),p.rr(0,0,u,t,r),s>0&&(g.shadow=new createjs.Shadow(a,3,3,s)),g.on("click",function(t){t.stopImmediatePropagation()});var f=new createjs.Container;this.addChild(f);for(var b,z=0;h>z;z++)b=new createjs.Shape,b.graphics.f(i).dc(0,0,d),b.x=(z-(h-1)/2)*(2*d+c),f.addChild(b),b.cache(-d,-d,2*d,2*d),b.alpha=0;e.getStage().update(),this.hide=function(){createjs.Tween.get(l,{override:!0}).to({alpha:0},300).call(function(){createjs.Ticker.off("tick",l.ticker),e.removeChild(l),e.getStage().update()})},this.show=function(){for(var t,n=0,i=0;io.length-1&&(e=0),0>e&&(e=o.length-1);else{if(e>o.length-1)return void(x.cursor="default");if(x.cursor="pointer",0>e)return}p(e),b.dispatchEvent("change")}function p(t){f=t,a.text=o[f],a.x=x.x+(x.getBounds().width-a.getBounds().width)/2,a.y=x.y+(x.getBounds().height-a.getBounds().height)/2,v.alpha=1,y.setFill(i),v.cursor="pointer",B.alpha=1,S.setFill(i),B.cursor="pointer",l||(0==f&&(v.alpha=.8,y.setFill("#aaa"),v.cursor="default"),f==o.length-1&&(B.alpha=.8,S.setFill("#aaa"),B.cursor="default")),a.getStage()&&a.getStage().update()}zot(o)&&(o=[0,1,2,3,4,5,6,7,8,9]),zot(n)&&(n=200),zot(i)&&(i="white"),zot(r)&&(r=null),zot(a)&&(a=""),("string"==typeof a||"number"==typeof a)&&(a=new t.Label(a,64,"arial","#555")),zot(s)&&(s=!1),zot(h)&&(h=!0),zot(d)&&(d=16),zot(c)&&(c="rgba(0,0,0,.3)"),zot(u)&&(u=14),zot(l)&&(l=!1);var f,b=this,z=100,w=z/4;a.mouseChildren=!1,a.mouseEnabled=!1;var v=this.arrowPrev=new createjs.Container;this.addChild(v);var m=new createjs.Shape;m.graphics.f("rgba(255,255,255,.11)").r(0,0,1.5*z,1.5*z),m.regX=1.5*z/2,m.regY=1.5*z/2+w/2,v.hitArea=m;var y=new t.Triangle(z,.8*z,.8*z,i);u>0&&(v.shadow=new createjs.Shadow(c,3,3,u)),v.addChild(y),v.cursor="pointer",v.on("click",function(t){g(-1)}),s?(v.rotation=0,v.x=n/2,v.y=v.getBounds().height/2):(v.rotation=-90,v.x=v.getBounds().height/2,v.y=v.getBounds().width/2);var x=this.textBox=new createjs.Shape;x.cursor="pointer",this.addChild(x),x.setBounds(0,0,n,z),null!=r&&x.graphics.s(r).ss(1.5),x.graphics.f(i).rr(0,0,n,z,d),u>0&&(x.shadow=new createjs.Shadow(c,3,3,u)),s?x.y=y.height+w:x.x=y.height+w,this.addChild(a),o.length>0&&(f=0,a.text=o[f]),a.x=x.x+(x.getBounds().width-a.getBounds().width)/2,a.y=x.y+(x.getBounds().height-a.getBounds().height)/2;var B=this.arrowNext=new createjs.Container;this.addChild(B);var C=new createjs.Shape;C.graphics.f("rgba(255,255,255,.01)").r(0,0,1.5*z,1.5*z),C.regX=1.5*z/2,C.regY=1.5*z/2+w/2,B.hitArea=C;var S=new t.Triangle(z,.8*z,.8*z,i);u>0&&(B.shadow=new createjs.Shadow(c,3,3,u)),B.addChild(S),B.cursor="pointer",B.on("click",function(t){g(1)}),x.on("click",function(t){g(1)}),s?(B.rotation=180,B.x=n/2,B.y=x.y+x.getBounds().height+B.getBounds().height/2+w):(B.rotation=90,B.x=x.x+x.getBounds().width+B.getBounds().height/2+w,B.y=B.getBounds().width/2),p(f),Object.defineProperty(this,"currentIndex",{get:function(){return f},set:function(t){f=Math.min(o.length-1,Math.max(0,t)),f!=b.currentIndex&&(p(f),b.dispatchEvent("change"))}}),Object.defineProperty(this,"currentValue",{get:function(){return o[f]},set:function(t){o.indexOf(t)>-1&&(f=o.indexOf(t)),f!=b.currentIndex&&(p(f),b.dispatchEvent("change"))}}),Object.defineProperty(this,"loop",{get:function(){return l},set:function(t){l=t,p(f)}}),Object.defineProperty(this,"stepperArray",{get:function(){return o},set:function(t){o=t}}),this._enabled=!0,Object.defineProperty(b,"enabled",{get:function(){return b._enabled},set:function(t){e(b,t),t?p(b.currentIndex):(v.alpha=.8,y.setFill("#aaa"),v.cursor="default",B.alpha=.8,S.setFill("#aaa"),B.cursor="default"),a.getStage()&&a.getStage().update()}}),h&&(this.keyDownEvent=function(t){if(t||(t=event),t.keyCode>=37&&t.keyCode<=40){38==t.keyCode||39==t.keyCode?g(1):(37==t.keyCode||40==t.keyCode)&&g(-1)}},window.addEventListener("keydown",this.keyDownEvent)),this.next=function(){g(1)},this.prev=function(){g(-1)},this.dispose=function(){b.removeAllEventListeners()}}var p,f="list, width, color, strokeColor, label, vertical, arrows, corner, shadowColor, shadowBlur, loop";return(p=zob(t.Stepper,arguments,f))?p:(g.prototype=new createjs.Container,g.prototype.constructor=t.Stepper,new g)},t.Slider=function(o,n,i,r,a,s,h,d,c){function u(){function u(t){return 0==i?t:Math.round(t/i)*i}function l(t,e,o){return t=Math.max(o.x,Math.min(o.width,t)),e=Math.max(o.y,Math.min(o.height,e)),{x:t,y:e}}if(zot(o)&&(o=0),zot(n)&&(n=10),n-o==0)return void zog("ZIM Slider range must not be 0");if(zot(i)&&(i=0),zot(a)&&(a=300),zot(s)&&(s=3),zot(h)&&(h="#666"),zot(d)&&(d=!1),zot(c)&&(c=!1),zot(r)){var g=30,p=40;d&&(g=50,p=40),r=new t.Button(g,p,"","#fff","#ddd","#666",1,0,null,null,30)}var f=this,b=o;this.button=r;var z,w,v,m,y;if(c&&0!=i){m=this.ticks=new createjs.Shape,this.addChild(m),y=m.graphics,y.ss(1).s(h);var x=(n-o)/i,B=a/x}if(d){if(c&&0!=i){for(var C=0;x>=C;C++)y.mt(0,B*C).lt(20,B*C);m.x=10}z=this.bar=new t.Rectangle(s,a,h),this.addChild(z),t.centerReg(r),this.addChild(r),v=z.getBounds(),w=new createjs.Rectangle(v.width/2,v.y,0,v.height)}else{if(c&&0!=i){for(var C=0;x>=C;C++)y.mt(B*C,0).lt(B*C,-20);m.y=-10}z=this.bar=new t.Rectangle(a,s,h),this.addChild(z),t.centerReg(r),this.addChild(r),v=z.getBounds(),w=new createjs.Rectangle(v.x,v.height/2,v.width,0)}r.x=w.x,r.y=w.y;var S,j,k=0;r.on("mousedown",function(t){var e=f.globalToLocal(t.stageX,t.stageY);S=e.x-r.x,j=e.y-r.y}),r.on("pressmove",function(t){var e=f.globalToLocal(t.stageX,t.stageY),i=l(e.x-S,e.y-j,w);d?(r.x=i.x,b=u(i.y/a*(n-o)),r.y=b*a/(n-o),b+=o,r.y!=k&&f.dispatchEvent("change"),k=r.y):(b=u(i.x/a*(n-o)),r.x=b*a/(n-o),b+=o,r.y=i.y,r.x!=k&&f.dispatchEvent("change"),k=r.x),f.getStage().update()}),Object.defineProperty(this,"currentValue",{get:function(){return b},set:function(t){o>t&&(t=o),t>n&&(t=n),b=t=u(t),d?(r.y=(t-o)/(n-o)*a,k=r.y):(r.x=(t-o)/(n-o)*a,k=r.x),f.getStage()&&f.getStage().update()}}),Object.defineProperty(this,"min",{get:function(){return o},set:function(t){zon&&zog("min is read only")}}),Object.defineProperty(this,"max",{get:function(){return n},set:function(t){zon&&zog("max is read only")}}),Object.defineProperty(this,"step",{get:function(){return i},set:function(t){zon&&zog("step is read only")}}),this._enabled=!0,Object.defineProperty(f,"enabled",{get:function(){return f._enabled},set:function(t){e(f,t)}}),this.dispose=function(){r.removeAllEventListeners()}}var l,g="min, max, step, button, barLength, barWidth, barColor, vertical, useTicks";return(l=zob(t.Slider,arguments,g))?l:(u.prototype=new createjs.Container,u.prototype.constructor=t.Slider,new u)},t.Parallax=function(e,o,n,i){function r(t){d.step()}var a,s="stage, damp, layers, auto";if(a=zob(t.Parallax,arguments,s))return a;if(zon&&zog("zim build - Parallax"),zot(e)||!e.getBounds)return void zog("zim build - Parallax(): please pass in the stage with bounds as first parameter");if(!e.getBounds())return void zog("zim build - Parallax(): Please give the stage bounds using setBounds()");zot(i)&&(i=!0);var h=e.getBounds().width,d=(e.getBounds().height,this);this.damp=zot(o)?.1:o,this.addLayer=function(e){if(!(zot(e.obj)||zot(e.prop)||zot(e.propChange))){var o={obj:e.obj,prop:e.prop};o[o.prop]=e.propChange,zot(e.input)&&(e.input="mouseX"),o.input=e.input;var n=zot(e.inMin)?0:e.inMin,i=zot(e.inMax)?h:e.inMax,r=zot(e.factor)?1:e.factor,a=zot(e.integer)?!1:e.integer;return o["p_"+o.prop]=new t.ProportionDamp(n,i,0,o[o.prop],d.damp,r,a),"scale"==o.prop?o["s_"+o.prop]=o.obj.scaleX:"frame"==o.prop?o["s_"+o.prop]=o.obj.currentFrame:o["s_"+o.prop]=o.obj[o.prop],c.push(o),c.length-1}},this.removeLayer=function(t){if(!zot(t)){var e=c[t];e["p_"+e.prop].dispose(),c.splice(t,1)}},this.immediate=function(t){for(var e,o=0;o0?u.x<0&&c.xg&&u.x>c.x?u.x=c.x-c.getBounds().width+l.gapFix:c.x>g&&c.x>u.x&&(c.x=u.x-u.getBounds().width+l.gapFix)):(c.y-=l.speed*l.direction,u.y-=l.speed*l.direction,l.direction*l.speed>0?u.y<0&&c.yp&&u.y>c.y?u.y=c.y-c.getBounds().height+l.gapFix:c.y>p&&c.y>u.y&&(c.y=u.y-u.getBounds().height+l.gapFix)),c.getStage().update())}}var h,d="backing1, backing2, speed, direction, horizontal, gapFix";if(h=zob(t.Scroller,arguments,d))return h;var c=e,u=o;if(!zot(c)&&c.getBounds&&!zot(u)&&u.getBounds){zot(r)&&(r=!0);var l=this;if(this.speed=zot(n)?1:n,this.direction=zot(i)?1:i,this.gapFix=zot(a)?0:a,!c.getBounds()||!u.getBounds())return void zog("zim build - Scroller(): please setBounds() on backing objects");if(!c.getStage())return void zog("zim build - Scroller(): please add backing objects to stage to start");var g,p;r?u.x=c.getBounds().width:u.y=c.getBounds().height;var f=createjs.Ticker.on("tick",s);createjs.Ticker.setFPS(60),this.dispose=function(){zon&&zog("bye from Scroller"),createjs.Ticker.off("tick",f)}}},t}(zim||{});