forked from hyperandroid/CAAT
/
caat-css-min.js
306 lines (297 loc) · 150 KB
/
caat-css-min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
The MIT License
Copyright (c) 2010-2011-2012 Ibon Tolosana [@hyperandroid]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Version: 0.2 build: 48
Created on:
DATE: 2012-01-24
TIME: 23:32:25
*/
var CAAT=CAAT||{};Function.prototype.bind=Function.prototype.bind||function(){var a=this,b=Array.prototype.slice.call(arguments),c=b.shift();return function(){return a.apply(c,b.concat(Array.prototype.slice.call(arguments)))}};CAAT.__CSS__=1;(function(){CAAT.BrowserDetect=function(){this.init();return this};CAAT.BrowserDetect.prototype={browser:"",version:0,OS:"",init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var b=0;b<a.length;b++){var c=a[b].string,d=a[b].prop;this.versionSearchString=a[b].versionSearch||
a[b].identity;if(c){if(c.indexOf(a[b].subString)!==-1)return a[b].identity}else if(d)return a[b].identity}},searchVersion:function(a){var b=a.indexOf(this.versionSearchString);return b===-1?void 0:parseFloat(a.substring(b+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},
{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Explorer",identity:"Explorer",
versionSearch:"Explorer"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]}})();function extend(a,b){var c=a.prototype,d=function(){};d.prototype=b.prototype;a.prototype=new d;a.superclass=b.prototype;a.prototype.constructor=a;if(b.prototype.constructor===Object.prototype.constructor)b.prototype.constructor=b;for(var e in c)c.hasOwnProperty(e)&&(a.prototype[e]=c[e])}
function proxy(a,b,c,d){if(typeof a==="function")return a.__isProxy?a:function(a){var e=function(){b&&b({fn:a,arguments:Array.prototype.slice.call(arguments)});var e=null;try{e=a.apply(a,Array.prototype.slice.call(arguments)),c&&c({fn:a,arguments:Array.prototype.slice.call(arguments)})}catch(f){if(d)e=d({fn:a,arguments:Array.prototype.slice.call(arguments),exception:f});else throw f;}return e};e.__isProxy=true;return e}(a);if(!typeof a==="object"||a.constructor===Array||a.constructor===String||a.__isProxy)return a;
var e=new function(){};e.__object=a;e.__isProxy=true;for(var f in a)typeof a[f]==="function"&&(e[f]=function(a,e,f){return function(){b&&b({object:a.__object,method:f,arguments:Array.prototype.slice.call(arguments)});var j=null;try{j=e.apply(a.__object,arguments),c&&c({object:a.__object,method:f,arguments:Array.prototype.slice.call(arguments)})}catch(k){if(d)j=d({object:a.__object,method:f,arguments:Array.prototype.slice.call(arguments),exception:k});else throw k;}return j}}(e,a[f],f));return e};(function(){CAAT.Matrix3=function(){this.matrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];this.fmatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return this};CAAT.Matrix3.prototype={matrix:null,fmatrix:null,transformCoord:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.matrix[0][0]+c*this.matrix[0][1]+d*this.matrix[0][2]+this.matrix[0][3];a.y=b*this.matrix[1][0]+c*this.matrix[1][1]+d*this.matrix[1][2]+this.matrix[1][3];a.z=b*this.matrix[2][0]+c*this.matrix[2][1]+d*this.matrix[2][2]+this.matrix[2][3];return a},
initialize:function(a,b,c,d,e,f,g,h,i){this.identity();this.matrix[0][0]=a;this.matrix[0][1]=b;this.matrix[0][2]=c;this.matrix[1][0]=d;this.matrix[1][1]=e;this.matrix[1][2]=f;this.matrix[2][0]=g;this.matrix[2][1]=h;this.matrix[2][2]=i;return this},initWithMatrix:function(a){this.matrix=a;return this},flatten:function(){var a=this.fmatrix,b=this.matrix;a[0]=b[0][0];a[1]=b[1][0];a[2]=b[2][0];a[3]=b[3][0];a[4]=b[0][1];a[5]=b[1][1];a[6]=b[2][1];a[7]=b[2][1];a[8]=b[0][2];a[9]=b[1][2];a[10]=b[2][2];a[11]=
b[3][2];a[12]=b[0][3];a[13]=b[1][3];a[14]=b[2][3];a[15]=b[3][3];return this.fmatrix},identity:function(){for(var a=0;a<4;a++)for(var b=0;b<4;b++)this.matrix[a][b]=a===b?1:0;return this},getMatrix:function(){return this.matrix},rotateXY:function(a){return this.rotate(a,0,0)},rotateXZ:function(a){return this.rotate(0,a,0)},rotateYZ:function(a){return this.rotate(0,0,a)},setRotate:function(a,b,c){this.copy(this.rotate(a,b,c));return this},rotate:function(a,b,c){var d=new CAAT.Matrix3,e,f;a!==0&&(f=new CAAT.Matrix3,
e=Math.sin(a),a=Math.cos(a),f.matrix[1][1]=a,f.matrix[1][2]=-e,f.matrix[2][1]=e,f.matrix[2][2]=a,d.multiply(f));b!==0&&(f=new CAAT.Matrix3,e=Math.sin(b),a=Math.cos(b),f.matrix[0][0]=a,f.matrix[0][2]=-e,f.matrix[2][0]=e,f.matrix[2][2]=a,d.multiply(f));c!==0&&(f=new CAAT.Matrix3,e=Math.sin(c),a=Math.cos(c),f.matrix[0][0]=a,f.matrix[0][1]=-e,f.matrix[1][0]=e,f.matrix[1][1]=a,d.multiply(f));return d},getClone:function(){var a=new CAAT.Matrix3;a.copy(this);return a},multiply:function(a){var b=this.getClone().matrix,
c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],n=b[2][2],b=b[2][3],l=a.matrix,a=l[0][0],o=l[0][1],p=l[0][2],q=l[0][3],r=l[1][0],s=l[1][1],t=l[1][2],u=l[1][3],v=l[2][0],w=l[2][1],x=l[2][2],y=l[2][3],z=l[3][0],A=l[3][1],B=l[3][2],l=l[3][3];this.matrix[0][0]=c*a+d*r+e*v+f*z;this.matrix[0][1]=c*o+d*s+e*w+f*A;this.matrix[0][2]=c*p+d*t+e*x+f*B;this.matrix[0][3]=c*q+d*u+e*y+f*l;this.matrix[1][0]=g*a+h*r+i*v+j*z;this.matrix[1][1]=g*o+h*s+i*w+j*A;this.matrix[1][2]=
g*p+h*t+i*x+j*B;this.matrix[1][3]=g*q+h*u+i*y+j*l;this.matrix[2][0]=k*a+m*r+n*v+b*z;this.matrix[2][1]=k*o+m*s+n*w+b*A;this.matrix[2][2]=k*p+m*t+n*x+b*B;this.matrix[2][3]=k*q+m*u+n*y+b*l;return this},premultiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],n=b[2][2],b=b[2][3],l=a.matrix,a=l[0][0],o=l[0][1],p=l[0][2],q=l[0][3],r=l[1][0],s=l[1][1],t=l[1][2],u=l[1][3],v=l[2][0],w=l[2][1],x=l[2][2],l=l[2][3];
this.matrix[0][0]=c*a+d*r+e*v;this.matrix[0][1]=c*o+d*s+e*w;this.matrix[0][2]=c*p+d*t+e*x;this.matrix[0][3]=c*q+d*u+e*l+f;this.matrix[1][0]=g*a+h*r+i*v;this.matrix[1][1]=g*o+h*s+i*w;this.matrix[1][2]=g*p+h*t+i*x;this.matrix[1][3]=g*q+h*u+i*l+j;this.matrix[2][0]=k*a+m*r+n*v;this.matrix[2][1]=k*o+m*s+n*w;this.matrix[2][2]=k*p+m*t+n*x;this.matrix[2][3]=k*q+m*u+n*l+b;return this},setTranslate:function(a,b,c){this.identity();this.matrix[0][3]=a;this.matrix[1][3]=b;this.matrix[2][3]=c;return this},translate:function(a,
b,c){var d=new CAAT.Matrix3;d.setTranslate(a,b,c);return d},setScale:function(a,b,c){this.identity();this.matrix[0][0]=a;this.matrix[1][1]=b;this.matrix[2][2]=c;return this},scale:function(a,b,c){var d=new CAAT.Matrix3;d.setScale(a,b,c);return d},rotateModelView:function(a,b,c){var d=Math.sin(a),e=Math.sin(b),f=Math.sin(c),a=Math.cos(a),b=Math.cos(b),c=Math.cos(c);this.matrix[0][0]=b*a;this.matrix[0][1]=-b*d;this.matrix[0][2]=e;this.matrix[0][3]=0;this.matrix[1][0]=f*e*a+d*c;this.matrix[1][1]=c*a-
f*e*d;this.matrix[1][2]=-f*b;this.matrix[1][3]=0;this.matrix[2][0]=f*d-c*e*a;this.matrix[2][1]=c*e*d+f*a;this.matrix[2][2]=c*b;this.matrix[2][3]=0;this.matrix[3][0]=0;this.matrix[3][1]=0;this.matrix[3][2]=0;this.matrix[3][3]=1;return this},copy:function(a){for(var b=0;b<4;b++)for(var c=0;c<4;c++)this.matrix[b][c]=a.matrix[b][c];return this},calculateDeterminant:function(){var a=this.matrix,b=a[0][0],c=a[0][1],d=a[0][2],e=a[0][3],f=a[1][0],g=a[1][1],h=a[1][2],i=a[1][3],j=a[2][0],k=a[2][1],m=a[2][2],
n=a[2][3],l=a[3][0],o=a[3][1],p=a[3][2],a=a[3][3];return e*g*m*l+c*i*m*l+e*h*j*o+d*i*j*o+d*f*n*o+b*h*n*o+e*f*k*p+b*i*k*p+d*g*j*a+c*h*j*a+c*f*m*a+b*g*m*a+e*h*k*l-d*i*k*l-d*g*n*l-c*h*n*l-e*f*m*o-b*i*m*o-e*g*j*p-c*i*j*p-c*f*n*p-b*g*n*p-d*f*k*a-b*h*k*a},getInverse:function(){var a=this.matrix,b=a[0][0],c=a[0][1],d=a[0][2],e=a[0][3],f=a[1][0],g=a[1][1],h=a[1][2],i=a[1][3],j=a[2][0],k=a[2][1],m=a[2][2],n=a[2][3],l=a[3][0],o=a[3][1],p=a[3][2],a=a[3][3],q=new CAAT.Matrix3;q.matrix[0][0]=h*n*o+i*k*p+g*m*a-
i*m*o-g*n*p-h*k*a;q.matrix[0][1]=e*m*o+c*n*p+d*k*a-c*m*a-d*n*o-e*k*p;q.matrix[0][2]=d*i*o+c*h*a+e*g*p-c*i*p-d*g*a-e*h*o;q.matrix[0][3]=e*h*k+c*i*m+d*g*n-d*i*k-e*g*m-c*h*n;q.matrix[1][0]=i*m*l+f*n*p+h*j*a-h*n*l-i*j*p-f*m*a;q.matrix[1][1]=d*n*l+e*j*p+b*m*a-e*m*l-b*n*p-d*j*a;q.matrix[1][2]=e*h*l+b*i*p+d*f*a-d*i*l-e*f*p-b*h*a;q.matrix[1][3]=d*i*j+e*f*m+b*h*n-e*h*j-b*i*m-d*f*n;q.matrix[2][0]=g*n*l+i*j*o+f*k*a-i*k*l-f*n*o-g*j*a;q.matrix[2][1]=e*k*l+b*n*o+c*j*a-b*k*a-c*n*l-e*j*o;q.matrix[2][2]=d*i*l+e*f*
o+b*g*a-e*g*l-b*i*o-c*f*a;q.matrix[2][3]=e*g*j+b*i*k+c*f*n-b*g*n-c*i*j-e*f*k;q.matrix[3][0]=h*k*l+f*m*o+g*j*p-g*m*l-h*j*o-f*k*p;q.matrix[3][1]=c*m*l+d*j*o+b*k*p-d*k*l-b*m*o-c*j*p;q.matrix[3][2]=d*g*l+b*h*o+c*f*p-b*g*p-c*h*l-d*f*o;q.matrix[3][3]=c*h*j+d*f*k+b*g*m-d*g*j-b*h*k-c*f*m;return q.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;b<4;b++)for(c=0;c<4;c++)this.matrix[b][c]*=a;return this}}})();
(function(){CAAT.Matrix=function(){this.matrix=[1,0,0,0,1,0,0,0,1];return this};CAAT.Matrix.prototype={matrix:null,transformCoord:function(a){var b=a.x,c=a.y,d=this.matrix;a.x=b*d[0]+c*d[1]+d[2];a.y=b*d[3]+c*d[4]+d[5];return a},rotate:function(a){var b=new CAAT.Matrix;b.setRotation(a);return b},setRotation:function(a){this.identity();var b=this.matrix,c=Math.cos(a),a=Math.sin(a);b[0]=c;b[1]=-a;b[3]=a;b[4]=c;return this},scale:function(a,b){var c=new CAAT.Matrix;c.matrix[0]=a;c.matrix[4]=b;return c},
setScale:function(a,b){this.identity();this.matrix[0]=a;this.matrix[4]=b;return this},translate:function(a,b){var c=new CAAT.Matrix;c.matrix[2]=a;c.matrix[5]=b;return c},setTranslate:function(a,b){this.identity();this.matrix[2]=a;this.matrix[5]=b;return this},copy:function(a){var a=a.matrix,b=this.matrix;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},identity:function(){var a=this.matrix;a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=
0;a[8]=1;return this},multiply:function(a){var b=this.matrix,c=a.matrix,a=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],m=c[0],n=c[1],l=c[2],o=c[3],p=c[4],q=c[5],r=c[6],s=c[7],c=c[8];b[0]=a*m+d*o+e*r;b[1]=a*n+d*p+e*s;b[2]=a*l+d*q+e*c;b[3]=f*m+g*o+h*r;b[4]=f*n+g*p+h*s;b[5]=f*l+g*q+h*c;b[6]=i*m+j*o+k*r;b[7]=i*n+j*p+k*s;b[8]=i*l+j*q+k*c;return this},premultiply:function(a){var b=a.matrix[0]*this.matrix[1]+a.matrix[1]*this.matrix[4]+a.matrix[2]*this.matrix[7],c=a.matrix[0]*this.matrix[2]+
a.matrix[1]*this.matrix[5]+a.matrix[2]*this.matrix[8],d=a.matrix[3]*this.matrix[0]+a.matrix[4]*this.matrix[3]+a.matrix[5]*this.matrix[6],e=a.matrix[3]*this.matrix[1]+a.matrix[4]*this.matrix[4]+a.matrix[5]*this.matrix[7],f=a.matrix[3]*this.matrix[2]+a.matrix[4]*this.matrix[5]+a.matrix[5]*this.matrix[8],g=a.matrix[6]*this.matrix[0]+a.matrix[7]*this.matrix[3]+a.matrix[8]*this.matrix[6],h=a.matrix[6]*this.matrix[1]+a.matrix[7]*this.matrix[4]+a.matrix[8]*this.matrix[7],i=a.matrix[6]*this.matrix[2]+a.matrix[7]*
this.matrix[5]+a.matrix[8]*this.matrix[8];this.matrix[0]=a.matrix[0]*this.matrix[0]+a.matrix[1]*this.matrix[3]+a.matrix[2]*this.matrix[6];this.matrix[1]=b;this.matrix[2]=c;this.matrix[3]=d;this.matrix[4]=e;this.matrix[5]=f;this.matrix[6]=g;this.matrix[7]=h;this.matrix[8]=i;return this},getInverse:function(){var a=this.matrix,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],a=a[8],j=new CAAT.Matrix,k=b*(f*a-i*g)-e*(c*a-i*d)+h*(c*g-f*d);if(k===0)return null;var m=j.matrix;m[0]=f*a-g*i;m[1]=d*
i-c*a;m[2]=c*g-d*f;m[3]=g*h-e*a;m[4]=b*a-d*h;m[5]=d*e-b*g;m[6]=e*i-f*h;m[7]=c*h-b*i;m[8]=b*f-c*e;j.multiplyScalar(1/k);return j},multiplyScalar:function(a){var b;for(b=0;b<9;b++)this.matrix[b]*=a;return this},transformRenderingContextSet:null,transformRenderingContext:null,transformRenderingContextSet_NoClamp:function(a){var b=this.matrix;a.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);return this},transformRenderingContext_NoClamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2],
b[5]);return this},transformRenderingContextSet_Clamp:function(a){var b=this.matrix;a.setTransform(b[0],b[3],b[1],b[4],b[2]>>0,b[5]>>0);return this},transformRenderingContext_Clamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2]>>0,b[5]>>0);return this}};CAAT.Matrix.prototype.transformRenderingContext=CAAT.Matrix.prototype.transformRenderingContext_Clamp;CAAT.Matrix.prototype.transformRenderingContextSet=CAAT.Matrix.prototype.transformRenderingContextSet_Clamp})();
(function(){CAAT.MatrixStack=function(){this.stack=[];this.saved=[];return this};CAAT.MatrixStack.prototype={stack:null,saved:null,pushMatrix:function(a){this.stack.push(a);return this},popMatrix:function(){return this.stack.pop()},save:function(){this.saved.push(this.stack.length);return this},restore:function(){for(var a=this.saved.pop();this.stack.length!==a;)this.popMatrix();return this},getMatrix:function(){for(var a=new CAAT.Matrix,b=0;b<this.stack.length;b++)a.multiply(this.stack[b]);return a}}})();(function(){CAAT.Color=function(){return this};CAAT.Color.prototype={hsvToRgb:function(a,b,c){var d,e,f,a=Math.max(0,Math.min(360,a)),b=Math.max(0,Math.min(100,b)),c=Math.max(0,Math.min(100,c));b/=100;c/=100;if(b===0)return d=b=c,[Math.round(d*255),Math.round(b*255),Math.round(c*255)];a/=60;d=Math.floor(a);e=a-d;a=c*(1-b);f=c*(1-b*e);e=c*(1-b*(1-e));switch(d){case 0:d=c;b=e;c=a;break;case 1:d=f;b=c;c=a;break;case 2:d=a;b=c;c=e;break;case 3:d=a;b=f;break;case 4:d=e;b=a;break;default:d=c,b=a,c=f}return new CAAT.Color.RGB(Math.round(d*
255),Math.round(b*255),Math.round(c*255))},RampEnumeration:{RAMP_RGBA:0,RAMP_RGB:1,RAMP_CHANNEL_RGB:2,RAMP_CHANNEL_RGBA:3,RAMP_CHANNEL_RGB_ARRAY:4,RAMP_CHANNEL_RGBA_ARRAY:5},interpolate:function(a,b,c,d,e,f,g,h){if(h<=0)return{r:a,g:b,b:c};else if(h>=g)return{r:d,g:e,b:f};a=a+(d-a)/g*h>>0;b=b+(e-b)/g*h>>0;c=c+(f-c)/g*h>>0;a>255?a=255:a<0&&(a=0);b>255?b=255:b<0&&(b=0);c>255?c=255:c<0&&(c=0);return{r:a,g:b,b:c}},makeRGBColorRamp:function(a,b,c){var d=[],e=a.length-1;b/=e;for(var f=0;f<e;f++){var g=
a[f],h=g>>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],m=((k>>24&255)-h)/b,n=(((k&16711680)>>16)-i)/b,l=(((k&65280)>>8)-j)/b,k=((k&255)-g)/b,o=0;o<b;o++){var p=h+m*o>>0,q=i+n*o>>0,r=j+l*o>>0,s=g+k*o>>0;switch(c){case this.RampEnumeration.RAMP_RGBA:d.push("argb("+p+","+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_RGB:d.push("rgb("+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_CHANNEL_RGB:d.push(4278190080|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA:d.push(p<<
24|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA_ARRAY:d.push([q,r,s,p]);break;case this.RampEnumeration.RAMP_CHANNEL_RGB_ARRAY:d.push([q,r,s])}}}return d}}})();(function(){CAAT.Color.RGB=function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this};CAAT.Color.RGB.prototype={r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}})();(function(){CAAT.Rectangle=function(){return this};CAAT.Rectangle.prototype={x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,
d);return this},contains:function(a,b){return a>=0&&a<this.width&&b>=0&&b<this.height},isEmpty:function(){return this.width===-1&&this.height===-1},union:function(a,b){if(this.isEmpty())this.x1=this.x=a,this.y1=this.y=b,this.height=this.width=0;else{this.x1=this.x+this.width;this.y1=this.y+this.height;if(b<this.y)this.y=b;if(a<this.x)this.x=a;if(b>this.y1)this.y1=b;if(a>this.x1)this.x1=a;this.width=this.x1-this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1,
a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.x1<this.x?false:a.x>this.x1?false:a.y1<this.y?false:a.y>this.y1?false:true}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha=
0.5;for(var b=0;b<this.coordlist.length;b++)a.fillStyle="#7f7f00",a.beginPath(),a.arc(this.coordlist[b].x,this.coordlist[b].y,this.HANDLE_SIZE/2,0,2*Math.PI,false),a.fill();a.restore()}},update:function(){this.calcLength()},solve:function(){},getContour:function(a){var b=[],c;for(c=0;c<=a;c++){var d=new CAAT.Point;this.solve(d,c/a);b.push(d)}return b},getBoundingBox:function(a){a||(a=new CAAT.Rectangle);a.setEmpty();a.union(this.coordlist[0].x,this.coordlist[0].y);for(var b=new CAAT.Point,c=this.k;c<=
1+this.k;c+=this.k)this.solve(b,c),a.union(b.x,b.y);return a},calcLength:function(){var a,b;a=this.coordlist[0].x;b=this.coordlist[0].y;for(var c=0,d=new CAAT.Point,e=this.k;e<=1+this.k;e+=this.k)this.solve(d,e),c+=Math.sqrt((d.x-a)*(d.x-a)+(d.y-b)*(d.y-b)),a=d.x,b=d.y;return this.length=c},getLength:function(){return this.length},endCurvePosition:function(){return this.coordlist[this.coordlist.length-1]},startCurvePosition:function(){return this.coordlist[0]},setPoints:function(){},setPoint:function(a,
b){b>=0&&b<this.coordlist.length&&(this.coordlist[b]=a)},applyAsPath:function(){}}})();
(function(){CAAT.Bezier=function(){CAAT.Bezier.superclass.constructor.call(this);return this};CAAT.Bezier.prototype={cubic:false,applyAsPath:function(a){var b=this.coordlist;this.cubic?a.ctx.bezierCurveTo(b[1].x,b[1].y,b[2].x,b[2].y,b[3].x,b[3].y):a.ctx.quadraticCurveTo(b[1].x,b[1].y,b[2].x,b[2].y);return this},isQuadric:function(){return!this.cubic},isCubic:function(){return this.cubic},setCubic:function(a,b,c,d,e,f,g,h){this.coordlist=[];this.coordlist.push((new CAAT.Point).set(a,b));this.coordlist.push((new CAAT.Point).set(c,
d));this.coordlist.push((new CAAT.Point).set(e,f));this.coordlist.push((new CAAT.Point).set(g,h));this.cubic=true;this.update();return this},setQuadric:function(a,b,c,d,e,f){this.coordlist=[];this.coordlist.push((new CAAT.Point).set(a,b));this.coordlist.push((new CAAT.Point).set(c,d));this.coordlist.push((new CAAT.Point).set(e,f));this.cubic=false;this.update();return this},setPoints:function(a){if(a.length===3)this.coordlist=a,this.cubic=false,this.update();else if(a.length===4)this.coordlist=a,
this.cubic=true,this.update();else throw"points must be an array of 3 or 4 CAAT.Point instances.";return this},paint:function(a){this.cubic?this.paintCubic(a):this.paintCuadric(a);CAAT.Bezier.superclass.paint.call(this,a)},paintCuadric:function(a){var b,c;b=this.coordlist[0].x;c=this.coordlist[0].y;a=a.ctx;a.save();a.beginPath();a.moveTo(b,c);b=new CAAT.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x,b.y);a.stroke();a.restore()},paintCubic:function(a){var b,c;b=this.coordlist[0].x;
c=this.coordlist[0].y;a=a.ctx;a.save();a.beginPath();a.moveTo(b,c);b=new CAAT.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x,b.y);a.stroke();a.restore()},solve:function(a,b){return this.cubic?this.solveCubic(a,b):this.solveQuadric(a,b)},solveCubic:function(a,b){var c=b*b,d=b*c,e=this.coordlist,f=e[0],g=e[1],h=e[2],e=e[3];a.x=f.x+b*(-f.x*3+b*(3*f.x-f.x*b))+b*(3*g.x+b*(-6*g.x+g.x*3*b))+c*(h.x*3-h.x*3*b)+e.x*d;a.y=f.y+b*(-f.y*3+b*(3*f.y-f.y*b))+b*(3*g.y+b*(-6*g.y+g.y*3*b))+c*(h.y*
3-h.y*3*b)+e.y*d;return a},solveQuadric:function(a,b){var c=this.coordlist,d=c[0],e=c[1],c=c[2],f=1-b;a.x=f*f*d.x+2*f*b*e.x+b*b*c.x;a.y=f*f*d.y+2*f*b*e.y+b*b*c.y;return a}};extend(CAAT.Bezier,CAAT.Curve,null)})();
(function(){CAAT.CatmullRom=function(){CAAT.CatmullRom.superclass.constructor.call(this);return this};CAAT.CatmullRom.prototype={setCurve:function(a,b,c,d,e,f,g,h){this.coordlist=[];this.coordlist.push((new CAAT.Point).set(a,b));this.coordlist.push((new CAAT.Point).set(c,d));this.coordlist.push((new CAAT.Point).set(e,f));this.coordlist.push((new CAAT.Point).set(g,h));this.cubic=true;this.update()},paint:function(a){var b,c;b=this.coordlist[0].x;c=this.coordlist[0].y;var d=a.ctx;d.save();d.beginPath();
d.moveTo(b,c);b=new CAAT.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),d.lineTo(b.x,b.y);d.stroke();d.restore();CAAT.CatmullRom.superclass.paint.call(this,a)},solve:function(a,b){var c=b*b,d=b*c,e=this.coordlist;a.x=0.5*(2*e[1].x+(-e[0].x+e[2].x)*b+(2*e[0].x-5*e[1].x+4*e[2].x-e[3].x)*c+(-e[0].x+3*e[1].x-3*e[2].x+e[3].x)*d);a.y=0.5*(2*e[1].y+(-e[0].y+e[2].y)*b+(2*e[0].y-5*e[1].y+4*e[2].y-e[3].y)*c+(-e[0].y+3*e[1].y-3*e[2].y+e[3].y)*d);return a}};extend(CAAT.CatmullRom,CAAT.Curve,null)})();(function(){CAAT.Point=function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this};CAAT.Point.prototype={x:0,y:0,z:0,set:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},clone:function(){return new CAAT.Point(this.x,this.y,this.z)},translate:function(a,b,c){this.x+=a;this.y+=b;this.z+=c;return this},translatePoint:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},subtract:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a){this.x*=a;this.y*=a;this.z*=
a;return this},rotate:function(a){var b=this.x,c=this.y;this.x=b*Math.cos(a)-Math.sin(a)*c;this.y=b*Math.sin(a)+Math.cos(a)*c;this.z=0;return this},setAngle:function(a){var b=this.getLength();this.x=Math.cos(a)*b;this.y=Math.sin(a)*b;this.z=0;return this},setLength:function(a){var b=this.getLength();b?this.multiply(a/b):this.x=this.y=this.z=a;return this},normalize:function(){var a=this.getLength();this.x/=a;this.y/=a;this.z/=a;return this},getAngle:function(){return Math.atan2(this.y,this.x)},limit:function(a){var b=
this.getLengthSquared();if(b+0.01>a*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y,
a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}})();(function(){CAAT.Interpolator=function(){this.interpolated=new CAAT.Point(0,0,0);return this};CAAT.Interpolator.prototype={interpolated:null,paintScale:90,createLinearInterpolator:function(a,b){this.getPosition=function(c){var d=c;a&&(c<0.5?c*=2:c=1-(c-0.5)*2);b!==null&&b&&(c=1-c);return this.interpolated.set(d,c)};return this},createBackOutInterpolator:function(a){this.getPosition=function(b){var c=b;a&&(b<0.5?b*=2:b=1-(b-0.5)*2);b-=1;return this.interpolated.set(c,b*b*(2.70158*b+1.70158)+1)};return this},
createExponentialInInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c<0.5?c*=2:c=1-(c-0.5)*2);return this.interpolated.set(d,Math.pow(c,a))};return this},createExponentialOutInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c<0.5?c*=2:c=1-(c-0.5)*2);return this.interpolated.set(d,1-Math.pow(1-c,a))};return this},createExponentialInOutInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c<0.5?c*=2:c=1-(c-0.5)*2);return c*2<1?this.interpolated.set(d,
Math.pow(c*2,a)/2):this.interpolated.set(d,1-Math.abs(Math.pow(c*2-2,a))/2)};return this},createQuadricBezierInterpolator:function(a,b,c,d){this.getPosition=function(e){var f=e;d&&(e<0.5?e*=2:e=1-(e-0.5)*2);e=(1-e)*(1-e)*a.y+2*(1-e)*e*b.y+e*e*c.y;return this.interpolated.set(f,e)};return this},createCubicBezierInterpolator:function(a,b,c,d,e){this.getPosition=function(f){var g=f;e&&(f<0.5?f*=2:f=1-(f-0.5)*2);var h=f*f,f=a.y+f*(-a.y*3+f*(3*a.y-a.y*f))+f*(3*b.y+f*(-6*b.y+b.y*3*f))+h*(c.y*3-c.y*3*f)+
d.y*f*h;return this.interpolated.set(g,f)};return this},createElasticOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d<0.5?d*=2:d=1-(d-0.5)*2);if(d===0)return{x:0,y:0};if(d===1)return{x:1,y:1};var e=b/(2*Math.PI)*Math.asin(1/a);return this.interpolated.set(d,a*Math.pow(2,-10*d)*Math.sin((d-e)*2*Math.PI/b)+1)};return this},createElasticInInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d<0.5?d*=2:d=1-(d-0.5)*2);if(d===0)return{x:0,y:0};if(d===1)return{x:1,y:1};var e=b/
(2*Math.PI)*Math.asin(1/a);return this.interpolated.set(d,-(a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*2*Math.PI/b)))};return this},createElasticInOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d<0.5?d*=2:d=1-(d-0.5)*2);var e=b/(2*Math.PI)*Math.asin(1/a);d*=2;return d<=1?this.interpolated.set(d,-0.5*a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*2*Math.PI/b)):this.interpolated.set(d,1+0.5*a*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*2*Math.PI/b))};return this},bounce:function(a){return(a/=1)<1/2.75?
{x:a,y:7.5625*a*a}:a<2/2.75?{x:a,y:7.5625*(a-=1.5/2.75)*a+0.75}:a<2.5/2.75?{x:a,y:7.5625*(a-=2.25/2.75)*a+0.9375}:{x:a,y:7.5625*(a-=2.625/2.75)*a+0.984375}},createBounceOutInterpolator:function(a){this.getPosition=function(b){a&&(b<0.5?b*=2:b=1-(b-0.5)*2);return this.bounce(b)};return this},createBounceInInterpolator:function(a){this.getPosition=function(b){a&&(b<0.5?b*=2:b=1-(b-0.5)*2);b=this.bounce(1-b);b.y=1-b.y;return b};return this},createBounceInOutInterpolator:function(a){this.getPosition=
function(b){a&&(b<0.5?b*=2:b=1-(b-0.5)*2);if(b<0.5)return b=this.bounce(1-b*2),b.y=(1-b.y)*0.5,b;b=this.bounce(b*2-1,a);b.y=b.y*0.5+0.5;return b};return this},paint:function(a){a=a.crc;a.save();a.beginPath();a.moveTo(0,this.getPosition(0).y*this.paintScale);for(var b=0;b<=this.paintScale;b++)a.lineTo(b,this.getPosition(b/this.paintScale).y*this.paintScale);a.strokeStyle="black";a.stroke();a.restore()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/a,y:this.getPosition(c/a).y});return b},
enumerateInterpolators:function(){return[(new CAAT.Interpolator).createLinearInterpolator(false,false),"Linear pingpong=false, inverse=false",(new CAAT.Interpolator).createLinearInterpolator(true,false),"Linear pingpong=true, inverse=false",(new CAAT.Interpolator).createLinearInterpolator(false,true),"Linear pingpong=false, inverse=true",(new CAAT.Interpolator).createLinearInterpolator(true,true),"Linear pingpong=true, inverse=true",(new CAAT.Interpolator).createExponentialInInterpolator(2,false),
"ExponentialIn pingpong=false, exponent=2",(new CAAT.Interpolator).createExponentialOutInterpolator(2,false),"ExponentialOut pingpong=false, exponent=2",(new CAAT.Interpolator).createExponentialInOutInterpolator(2,false),"ExponentialInOut pingpong=false, exponent=2",(new CAAT.Interpolator).createExponentialInInterpolator(2,true),"ExponentialIn pingpong=true, exponent=2",(new CAAT.Interpolator).createExponentialOutInterpolator(2,true),"ExponentialOut pingpong=true, exponent=2",(new CAAT.Interpolator).createExponentialInOutInterpolator(2,
true),"ExponentialInOut pingpong=true, exponent=2",(new CAAT.Interpolator).createExponentialInInterpolator(4,false),"ExponentialIn pingpong=false, exponent=4",(new CAAT.Interpolator).createExponentialOutInterpolator(4,false),"ExponentialOut pingpong=false, exponent=4",(new CAAT.Interpolator).createExponentialInOutInterpolator(4,false),"ExponentialInOut pingpong=false, exponent=4",(new CAAT.Interpolator).createExponentialInInterpolator(4,true),"ExponentialIn pingpong=true, exponent=4",(new CAAT.Interpolator).createExponentialOutInterpolator(4,
true),"ExponentialOut pingpong=true, exponent=4",(new CAAT.Interpolator).createExponentialInOutInterpolator(4,true),"ExponentialInOut pingpong=true, exponent=4",(new CAAT.Interpolator).createExponentialInInterpolator(6,false),"ExponentialIn pingpong=false, exponent=6",(new CAAT.Interpolator).createExponentialOutInterpolator(6,false),"ExponentialOut pingpong=false, exponent=6",(new CAAT.Interpolator).createExponentialInOutInterpolator(6,false),"ExponentialInOut pingpong=false, exponent=6",(new CAAT.Interpolator).createExponentialInInterpolator(6,
true),"ExponentialIn pingpong=true, exponent=6",(new CAAT.Interpolator).createExponentialOutInterpolator(6,true),"ExponentialOut pingpong=true, exponent=6",(new CAAT.Interpolator).createExponentialInOutInterpolator(6,true),"ExponentialInOut pingpong=true, exponent=6",(new CAAT.Interpolator).createBounceInInterpolator(false),"BounceIn pingpong=false",(new CAAT.Interpolator).createBounceOutInterpolator(false),"BounceOut pingpong=false",(new CAAT.Interpolator).createBounceInOutInterpolator(false),"BounceInOut pingpong=false",
(new CAAT.Interpolator).createBounceInInterpolator(true),"BounceIn pingpong=true",(new CAAT.Interpolator).createBounceOutInterpolator(true),"BounceOut pingpong=true",(new CAAT.Interpolator).createBounceInOutInterpolator(true),"BounceInOut pingpong=true",(new CAAT.Interpolator).createElasticInInterpolator(1.1,0.4,false),"ElasticIn pingpong=false, amp=1.1, d=.4",(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4,false),"ElasticOut pingpong=false, amp=1.1, d=.4",(new CAAT.Interpolator).createElasticInOutInterpolator(1.1,
0.4,false),"ElasticInOut pingpong=false, amp=1.1, d=.4",(new CAAT.Interpolator).createElasticInInterpolator(1.1,0.4,true),"ElasticIn pingpong=true, amp=1.1, d=.4",(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4,true),"ElasticOut pingpong=true, amp=1.1, d=.4",(new CAAT.Interpolator).createElasticInOutInterpolator(1.1,0.4,true),"ElasticInOut pingpong=true, amp=1.1, d=.4",(new CAAT.Interpolator).createElasticInInterpolator(1,0.2,false),"ElasticIn pingpong=false, amp=1.0, d=.2",(new CAAT.Interpolator).createElasticOutInterpolator(1,
0.2,false),"ElasticOut pingpong=false, amp=1.0, d=.2",(new CAAT.Interpolator).createElasticInOutInterpolator(1,0.2,false),"ElasticInOut pingpong=false, amp=1.0, d=.2",(new CAAT.Interpolator).createElasticInInterpolator(1,0.2,true),"ElasticIn pingpong=true, amp=1.0, d=.2",(new CAAT.Interpolator).createElasticOutInterpolator(1,0.2,true),"ElasticOut pingpong=true, amp=1.0, d=.2",(new CAAT.Interpolator).createElasticInOutInterpolator(1,0.2,true),"ElasticInOut pingpong=true, amp=1.0, d=.2"]}}})();(function(){CAAT.Behavior=function(){this.lifecycleListenerList=[];this.setDefaultInterpolator();return this};CAAT.Behavior.Status={NOT_STARTED:0,STARTED:1,EXPIRED:2};var a=(new CAAT.Interpolator).createLinearInterpolator(false),b=(new CAAT.Interpolator).createLinearInterpolator(true);CAAT.Behavior.prototype={lifecycleListenerList:null,behaviorStartTime:-1,behaviorDuration:-1,cycleBehavior:false,status:CAAT.Behavior.NOT_STARTED,interpolator:null,actor:null,id:0,timeOffset:0,doValueApplication:true,
setValueApplication:function(a){this.doValueApplication=a;return this},setTimeOffset:function(a){this.timeOffset=a;return this},setId:function(a){this.id=a;return this},setDefaultInterpolator:function(){this.interpolator=a;return this},setPingPong:function(){this.interpolator=b;return this},setStatus:function(a){this.status=a},setFrameTime:function(a,b){this.behaviorStartTime=a;this.behaviorDuration=b;this.setStatus(CAAT.Behavior.Status.NOT_STARTED);return this},setOutOfFrameTime:function(){this.setStatus(CAAT.Behavior.Status.EXPIRED);
this.behaviorStartTime=Number.MAX_VALUE;this.behaviorDuration=0;return this},setInterpolator:function(a){this.interpolator=a;return this},apply:function(a,b){a+=this.timeOffset*this.behaviorDuration;var e=a;this.isBehaviorInTime(a,b)&&(a=this.normalizeTime(a),this.fireBehaviorAppliedEvent(b,e,a,this.setForTime(a,b)))},setCycle:function(a){this.cycleBehavior=a;return this},addListener:function(a){this.lifecycleListenerList.push(a);return this},emptyListenerList:function(){this.lifecycleListenerList=
[];return this},getStartTime:function(){return this.behaviorStartTime},getDuration:function(){return this.behaviorDuration},isBehaviorInTime:function(a,b){var e=CAAT.Behavior.Status;if(this.status===e.EXPIRED||this.behaviorStartTime<0)return false;this.cycleBehavior&&a>=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=
e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a&&a<this.behaviorStartTime+this.behaviorDuration},fireBehaviorStartedEvent:function(a,b){for(var e=0;e<this.lifecycleListenerList.length;e++)this.lifecycleListenerList[e].behaviorStarted&&this.lifecycleListenerList[e].behaviorStarted(this,b,a)},fireBehaviorExpiredEvent:function(a,b){for(var e=0;e<this.lifecycleListenerList.length;e++)this.lifecycleListenerList[e].behaviorExpired(this,b,a)},fireBehaviorAppliedEvent:function(a,
b,e,f){for(var g=0;g<this.lifecycleListenerList.length;g++)this.lifecycleListenerList[g].behaviorApplied&&this.lifecycleListenerList[g].behaviorApplied(this,b,e,a,f)},normalizeTime:function(a){a-=this.behaviorStartTime;this.cycleBehavior&&(a%=this.behaviorDuration);return this.interpolator.getPosition(a/this.behaviorDuration).y},setExpired:function(a,b){this.status=CAAT.Behavior.Status.EXPIRED;this.setForTime(this.interpolator.getPosition(1).y,a);this.fireBehaviorExpiredEvent(a,b)},setForTime:function(){},
initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this},getPropertyName:function(){return""}}})();
(function(){CAAT.ContainerBehavior=function(){CAAT.ContainerBehavior.superclass.constructor.call(this);this.behaviors=[];return this};CAAT.ContainerBehavior.prototype={behaviors:null,conformToDuration:function(a){this.duration=a;a/=this.duration;for(var b,c=0;c<this.behavior.length;c++)b=this.behavior[c],b.setFrameTime(b.getStartTime()*a,b.getDuration()*a);return this},addBehavior:function(a){this.behaviors.push(a);a.addListener(this);return this},apply:function(a,b){a+=this.timeOffset*this.behaviorDuration;
if(this.isBehaviorInTime(a,b)){a-=this.getStartTime();this.cycleBehavior&&(a%=this.getDuration());for(var c=this.behaviors,d=0;d<c.length;d++)c[d].apply(a,b)}},behaviorExpired:function(a){this.cycleBehavior&&a.setStatus(CAAT.Behavior.Status.STARTED)},setForTime:function(a,b){for(var c=this.behaviors,d=0;d<c.length;d++)c[d].setForTime(a,b);return null},setExpired:function(a,b){CAAT.ContainerBehavior.superclass.setExpired.call(this,a,b);for(var c=this.behaviors,d=0;d<c.length;d++){var e=c[d];e.status!==
CAAT.Behavior.Status.EXPIRED&&e.setExpired(a,b-this.behaviorStartTime)}this.fireBehaviorExpiredEvent(a,b);return this},setFrameTime:function(a,b){CAAT.ContainerBehavior.superclass.setFrameTime.call(this,a,b);for(var c=this.behaviors,d=0;d<c.length;d++)c[d].setStatus(CAAT.Behavior.Status.NOT_STARTED);return this},calculateKeyFrameData:function(a,b,c){function d(a){if(g[a])i+=g[a];else if(c&&(j=c[a]))i+=j,g[a]=j}var e,f,g={},h;for(e=0;e<this.behaviors.length;e++)f=this.behaviors[e],f.status!==CAAT.Behavior.Status.EXPIRED&&
!(f instanceof CAAT.GenericBehavior)&&(h=a*this.behaviorDuration,f.behaviorStartTime<=h&&f.behaviorStartTime+f.behaviorDuration>=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}},calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return"";
typeof c==="undefined"&&(c=100);for(var d=null,e="@-"+a+"-keyframes "+b+" {",f,b=0;b<=c;b++)f=this.interpolator.getPosition(b/c).y,d=this.calculateKeyFrameData(f,a,d),f=""+b/c*100+"%{"+d.rules+"}\n",d=d.ret,e+=f;e+="}";return e}};extend(CAAT.ContainerBehavior,CAAT.Behavior,null)})();
(function(){CAAT.RotateBehavior=function(){CAAT.RotateBehavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.RotateBehavior.prototype={startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);this.doValueApplication&&b.setRotationAnchored(c,this.anchorX,this.anchorY);return c},setValues:function(a,b,c,d){this.startAngle=a;this.endAngle=
b;if(typeof c!=="undefined"&&typeof d!=="undefined")this.anchorX=c,this.anchorY=d;return this},setAngles:function(a,b){return this.setValues(a,b)},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"rotate("+(this.startAngle+a*(this.endAngle-this.startAngle))+"rad)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=
c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}\n",e+=d;e+="}";return e}};extend(CAAT.RotateBehavior,CAAT.Behavior,null)})();
(function(){CAAT.GenericBehavior=function(){CAAT.GenericBehavior.superclass.constructor.call(this);return this};CAAT.GenericBehavior.prototype={start:0,end:0,target:null,property:null,callback:null,setForTime:function(a,b){var c=this.start+a*(this.end-this.start);this.callback&&this.callback(c,this.target,b);this.property&&(this.target[this.property]=c)},setValues:function(a,b,c,d,e){this.start=a;this.end=b;this.target=c;this.property=d;this.callback=e;return this}};extend(CAAT.GenericBehavior,CAAT.Behavior,
null)})();
(function(){CAAT.ScaleBehavior=function(){CAAT.ScaleBehavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.ScaleBehavior.prototype={startScaleX:1,endScaleX:1,startScaleY:1,endScaleY:1,anchorX:0.5,anchorY:0.5,getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScaleX+a*(this.endScaleX-this.startScaleX),d=this.startScaleY+a*(this.endScaleY-this.startScaleY);0===c&&(c=0.01);0===d&&(d=0.01);this.doValueApplication&&b.setScaleAnchored(c,
d,this.anchorX,this.anchorY);return{scaleX:c,scaleY:d}},setValues:function(a,b,c,d,e,f){this.startScaleX=a;this.endScaleX=b;this.startScaleY=c;this.endScaleY=d;if(typeof e!=="undefined"&&typeof f!=="undefined")this.anchorX=e,this.anchorY=f;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"scaleX("+(this.startScaleX+a*(this.endScaleX-this.startScaleX))+") scaleY("+(this.startScaleY+
a*(this.endScaleY-this.startScaleY))+")"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e}};extend(CAAT.ScaleBehavior,CAAT.Behavior,null)})();
(function(){CAAT.AlphaBehavior=function(){CAAT.AlphaBehavior.superclass.constructor.call(this);return this};CAAT.AlphaBehavior.prototype={startAlpha:0,endAlpha:0,getPropertyName:function(){return"opacity"},setForTime:function(a,b){var c=this.startAlpha+a*(this.endAlpha-this.startAlpha);this.doValueApplication&&b.setAlpha(c);return c},setValues:function(a,b){this.startAlpha=a;this.endAlpha=b;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return this.startAlpha+
a*(this.endAlpha-this.startAlpha)},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}};extend(CAAT.AlphaBehavior,CAAT.Behavior,null)})();
(function(){CAAT.PathBehavior=function(){CAAT.PathBehavior.superclass.constructor.call(this);return this};CAAT.PathBehavior.autorotate={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2};CAAT.PathBehavior.prototype={path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.PathBehavior.autorotate.FREE,translateX:0,translateY:0,getPropertyName:function(){return"translate"},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this},
setValues:function(a){return this.setPath(a)},setTranslation:function(a,b){this.translateX=a;this.translateY=b;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+(a.x-this.translateX)+"px) translateY("+(a.y-this.translateY)+"px)"},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/
c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x-this.translateX,c.y-this.translateY),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.SpriteImage.prototype,h=CAAT.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):
(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x-this.translateX,c.y-this.translateY),{x:b.x,y:b.y}):{x:c.x-this.translateX,y:c.y-this.translateY}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),
this.path.getPosition(a)):{x:-1,y:-1}}};extend(CAAT.PathBehavior,CAAT.Behavior)})();(function(){CAAT.ColorBehavior=function(){return this};CAAT.ColorBehavior.prototype={};extend(CAAT.ColorBehavior,CAAT.Behavior)})();
(function(){CAAT.Scale1Behavior=function(){CAAT.Scale1Behavior.superclass.constructor.call(this);this.anchor=CAAT.Actor.prototype.ANCHOR_CENTER;return this};CAAT.Scale1Behavior.prototype={startScale:1,endScale:1,anchorX:0.5,anchorY:0.5,sx:1,sy:1,applyOnX:true,getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScale+a*(this.endScale-this.startScale);0===c&&(c=0.01);this.doValueApplication&&(this.applyOnX?b.setScaleAnchored(c,b.scaleY,this.anchorX,this.anchorY):b.setScaleAnchored(b.scaleX,
c,this.anchorX,this.anchorY));return c},setValues:function(a,b,c,d,e){this.startScale=a;this.endScale=b;this.applyOnX=!!c;if(typeof d!=="undefined"&&typeof e!=="undefined")this.anchorX=d,this.anchorY=e;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.startScale+a*(this.endScale-this.startScale);return this.applyOnX?"scaleX("+a+")":"scaleY("+a+")"},calculateKeyFramesData:function(a,
b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e}};extend(CAAT.Scale1Behavior,CAAT.Behavior)})();(function(){CAAT.Debug=function(){return this};CAAT.Debug.prototype={width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:' <style type="text/css"> #caat-debug { z-index: 10000; position:fixed; bottom:0; left:0; width:100%; background-color: rgba(0,0,0,0.8); } #caat-debug.caat_debug_max { margin-bottom: 0px; } .caat_debug_bullet { display:inline-block; background-color:#f00; width:8px; height:8px; border-radius: 4px; margin-left:10px; margin-right:2px; } .caat_debug_description { font-size:11px; font-family: helvetica, arial; color: #aaa; display: inline-block; } .caat_debug_value { font-size:11px; font-family: helvetica, arial; color: #fff; width:25px; text-align: right; display: inline-block; margin-right: .3em; } .caat_debug_indicator { float: right; } #debug_tabs { border-top: 1px solid #888; height:25px; } .tab_max_min { font-family: helvetica, arial; font-size: 12px; font-weight: bold; color: #888; border-right: 1px solid #888; float: left; cursor: pointer; padding-left: 5px; padding-right: 5px; padding-top: 5px; height: 20px; } .debug_tabs_content_hidden { display: none; width: 100%; } .debug_tabs_content_visible { display: block; width: 100%; } .checkbox_enabled { display:inline-block; background-color:#eee; border: 1px solid #eee; width:6px; height:8px; margin-left:12px; margin-right:2px; cursor: pointer; } .checkbox_disabled { display:inline-block; width:6px; height:8px; background-color: #333; border: 1px solid #eee; margin-left:12px; margin-right:2px; cursor: pointer; } .checkbox_description { font-size:11px; font-family: helvetica, arial; color: #fff; } .debug_tab { font-family: helvetica, arial; font-size: 12px; color: #fff; border-right: 1px solid #888; float: left; padding-left: 5px; padding-right: 5px; height: 20px; padding-top: 5px; cursor: default; } .debug_tab_selected { background-color: #444; cursor: default; } .debug_tab_not_selected { background-color: #000; cursor: pointer; } </style> <div id="caat-debug"> <div id="debug_tabs"> <span class="tab_max_min" onCLick="javascript: var debug = document.getElementById(\'debug_tabs_content\');if (debug.className === \'debug_tabs_content_visible\') {debug.className = \'debug_tabs_content_hidden\'} else {debug.className = \'debug_tabs_content_visible\'}"> CAAT Debug panel </span> <span id="caat-debug-tab0" class="debug_tab debug_tab_selected">Performance</span> <span id="caat-debug-tab1" class="debug_tab debug_tab_not_selected">Controls</span> <span class="caat_debug_indicator"> <span class="caat_debug_bullet" style="background-color:#0f0;"></span> <span class="caat_debug_description">Draw Time: </span> <span class="caat_debug_value" id="textDrawTime">5.46</span> <span class="caat_debug_description">ms.</span> </span> <span class="caat_debug_indicator"> <span class="caat_debug_bullet" style="background-color:#f00;"></span> <span class="caat_debug_description">FPS: </span> <span class="caat_debug_value" id="textFPS">48</span> </span> </div> <div id="debug_tabs_content" class="debug_tabs_content_hidden"> <div id="caat-debug-tab0-content"> <canvas id="caat-debug-canvas" height="60"></canvas> <div> <span> <span class="caat_debug_bullet" style="background-color:#0f0;"></span> <span class="caat_debug_description">RAF Time:</span> <span class="caat_debug_value" id="textRAFTime">20.76</span> <span class="caat_debug_description">ms.</span> </span> <span> <span class="caat_debug_bullet" style="background-color:#0ff;"></span> <span class="caat_debug_description">Entities Total: </span> <span class="caat_debug_value" id="textEntitiesTotal">41</span> </span> <span> <span class="caat_debug_bullet" style="background-color:#0ff;"></span> <span class="caat_debug_description">Entities Active: </span> <span class="caat_debug_value" id="textEntitiesActive">37</span> </span> <span> <span class="caat_debug_bullet" style="background-color:#00f;"></span> <span class="caat_debug_description">Draws: </span> <span class="caat_debug_value" id="textDraws">0</span> </span> </div> </div> <div id="caat-debug-tab1-content"> <div> <div> <span id="control-sound"></span> <span class="checkbox_description">Sound</span> </div> <div> <span id="control-music"></span> <span class="checkbox_description">Music</span> </div> <div> <span id="control-aabb"></span> <span class="checkbox_description">AA Bounding Boxes</span> </div> <div> <span id="control-bb"></span> <span class="checkbox_description">Bounding Boxes</span> </div> </div> </div> </div> </div>',
setScale:function(a){this.scale=a;return this},initialize:function(a,b){this.width=a=window.innerWidth;this.height=b;this.framerate={refreshInterval:CAAT.FPS_REFRESH||500,frames:0,timeLastRefresh:0,fps:0,prevFps:-1,fpsMin:1E3,fpsMax:0};if(!document.getElementById("caat-debug")){var c=document.createElement("div");c.innerHTML=this.debugTpl;document.body.appendChild(c);eval(' function initCheck( name, bool, callback ) { var elem= document.getElementById(name); if ( elem ) { elem.className= (bool) ? "checkbox_enabled" : "checkbox_disabled"; if ( callback ) { elem.addEventListener( "click", (function(elem, callback) { return function(e) { elem.__value= !elem.__value; elem.className= (elem.__value) ? "checkbox_enabled" : "checkbox_disabled"; callback(e,elem.__value); } })(elem, callback), false ); } elem.__value= bool; } } function setupTabs() { var numTabs=0; var elem; var elemContent; do { elem= document.getElementById("caat-debug-tab"+numTabs); if ( elem ) { elemContent= document.getElementById("caat-debug-tab"+numTabs+"-content"); if ( elemContent ) { elemContent.style.display= numTabs===0 ? \'block\' : \'none\'; elem.className= numTabs===0 ? "debug_tab debug_tab_selected" : "debug_tab debug_tab_not_selected"; elem.addEventListener( "click", (function(tabIndex) { return function(e) { for( var i=0; i<numTabs; i++ ) { var _elem= document.getElementById("caat-debug-tab"+i); var _elemContent= document.getElementById("caat-debug-tab"+i+"-content"); _elemContent.style.display= i===tabIndex ? \'block\' : \'none\'; _elem.className= i===tabIndex ? "debug_tab debug_tab_selected" : "debug_tab debug_tab_not_selected"; } } })(numTabs), false ); } numTabs++; } } while( elem ); } initCheck( "control-sound", CAAT.director[0].isSoundEffectsEnabled(), function(e, bool) { CAAT.director[0].setSoundEffectsEnabled(bool); } ); initCheck( "control-music", CAAT.director[0].isMusicEnabled(), function(e, bool) { CAAT.director[0].setMusicEnabled(bool); } ); initCheck( "control-aabb", CAAT.DEBUGAABB, function(e,bool) { CAAT.director[0].currentScene.dirty= true; CAAT.DEBUGAABB= bool; } ); initCheck( "control-bb", CAAT.DEBUGBB, function(e,bool) { CAAT.director[0].currentScene.dirty= true; CAAT.DEBUGBB= bool; } ); setupTabs();')}this.canvas=
document.getElementById("caat-debug-canvas");if(null===this.canvas)this.canDebug=false;else return this.canvas.width=a,this.canvas.height=b,this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#000",this.ctx.fillRect(0,0,this.width,this.height),this.textFPS=document.getElementById("textFPS"),this.textDrawTime=document.getElementById("textDrawTime"),this.textRAFTime=document.getElementById("textRAFTime"),this.textEntitiesTotal=document.getElementById("textEntitiesTotal"),this.textEntitiesActive=
document.getElementById("textEntitiesActive"),this.textDraws=document.getElementById("textDraws"),this.canDebug=true,this},debugInfo:function(a){this.statistics=a;this.frameTimeAcc+=CAAT.FRAME_TIME;this.frameRAFAcc+=CAAT.REQUEST_ANIMATION_FRAME_TIME;this.framerate.frames++;if(CAAT.RAF>this.framerate.timeLastRefresh+this.framerate.refreshInterval)this.framerate.fps=this.framerate.frames*1E3/(CAAT.RAF-this.framerate.timeLastRefresh)|0,this.framerate.fpsMin=this.framerate.frames>0?Math.min(this.framerate.fpsMin,
this.framerate.fps):this.framerate.fpsMin,this.framerate.fpsMax=Math.max(this.framerate.fpsMax,this.framerate.fps),this.textFPS.innerHTML=this.framerate.fps,a=(this.frameTimeAcc*100/this.framerate.frames|0)/100,this.frameTimeAcc=0,this.textDrawTime.innerHTML=a,a=(this.frameRAFAcc*100/this.framerate.frames|0)/100,this.frameRAFAcc=0,this.textRAFTime.innerHTML=a,this.framerate.timeLastRefresh=CAAT.RAF,this.framerate.frames=0,this.paint(a);this.textEntitiesTotal.innerHTML=this.statistics.size_total;this.textEntitiesActive.innerHTML=
this.statistics.size_active;this.textDraws.innerHTML=this.statistics.draws},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle="black";b.beginPath();b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*
this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle="#0ff";b.beginPath();b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE*this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}})();(function(){CAAT.Actor=function(){this.behaviorList=[];this.lifecycleListenerList=[];this.scaleAnchor=this.ANCHOR_CENTER;this.behaviorList=[];this.domElement=document.createElement("div");this.domElement.style.position="absolute";this.domElement.style["-webkit-transform"]="translate3d(0,0,0)";this.domElement.style["-webkit-transition"]="all 0s linear";this.style("display","none");this.setVisible(true);this.resetTransform();this.setScale(1,1);this.setRotation(0);this.modelViewMatrix=new CAAT.Matrix;
this.worldModelViewMatrix=new CAAT.Matrix;return this};CAAT.Actor.prototype={lifecycleListenerList:null,behaviorList:null,x:0,y:0,width:0,height:0,start_time:0,duration:Number.MAX_VALUE,clip:false,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,alpha:1,rotationX:0.5,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false,domParent:null,domElement:null,visible:true,ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,
ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9,mouseEnabled:true,time:0,inFrame:false,backgroundImage:null,size_active:1,size_total:1,id:null,getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent&&this.domParent.removeChild(this.domElement);this.parent=a;null!=a?(this.parent.domElement.appendChild(this.domElement),this.domParent=this.parent.domElement):this.domParent=null;this.dirty=true;return this},setBackgroundImage:function(a,
b){if(a){if(a instanceof HTMLImageElement)a=(new CAAT.SpriteImage).initialize(a,1,1);else if(a instanceof HTMLCanvasElement)a.src=a.toDataURL(),a=(new CAAT.SpriteImage).initialize(a,1,1);else if(a instanceof CAAT.SpriteImage){if(a.image instanceof HTMLCanvasElement&&!a.image.src)a.image.src=a.image.toDataURL()}else throw"Invalid image object to set actor's background";a.setOwner(this);this.backgroundImage=a;(typeof b==="undefined"||b)&&this.setSize(a.getWidth(),a.getHeight());this.style("background",
"url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())}else this.backgroundImage=null,this.style("background","none");return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setBackgroundImageOffset:function(a,b){this.backgroundImage&&(this.backgroundImage.setOffset(a,b),
this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setAnimationImageIndex:function(a){this.backgroundImage&&(this.backgroundImage.setAnimationImageIndex(a),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setImageTransformation:function(a){this.transformation=a;a===CAAT.SpriteImage.prototype.TR_FIXED_TO_SIZE&&this.style("background-size",
"100%");return this},centerOn:function(a,b){this.setLocation(a-this.width/2,b-this.height/2);return this},setVisible:function(a){this.visible=a;return this},style:function(a,b){this.domElement.style[a]=b},style3:function(){var a="";this.transformation===CAAT.SpriteImage.prototype.TR_FLIP_HORIZONTAL&&(a=" scale(-1,1) ");a="rotate("+this.rotationAngle+"rad) scale("+this.scaleX+","+this.scaleY+")"+a;this.domElement.style["-ms-transform"]=a;this.domElement.style["-webkit-transform"]="translate3d(0,0,0) "+
a;this.domElement.style.OTransform=a;this.domElement.style.MozTransform=a;this.domElement.style.transform=a;a=""+this.rotationX*100+"% "+this.rotationY*100+"% ";this.domElement.style["transform-origin"]=a;this.domElement.style["-webkit-transform-origin"]=a;this.domElement.style["-ms-transform-origin"]=a;this.domElement.style.OTransformOrigin=a;this.domElement.style.MozTransformOrigin=a;return this},styleAlpha:function(){this.domElement.style.filter="alpha(opacity="+(this.alpha*100>>0)+")";this.domElement.style.Oopacity=
this.alpha;this.domElement.style.MozOpacity=this.alpha;this.domElement.style["-khtml-opacity"]=this.alpha;this.domElement.style.opacity=this.alpha;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);this.style("display","none");return this},addListener:function(a){this.lifecycleListenerList.push(a)},removeListener:function(a){for(var b=this.lifecycleListenerList.length;b--;)if(this.lifecycleListenerList[b]===a){this.lifecycleListenerList.splice(b,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=
a;return this},fireEvent:function(a,b){for(var c=0;c<this.lifecycleListenerList.length;c++)this.lifecycleListenerList[c].actorLifeCycleEvent(this,a,b)},setExpired:function(a){this.expired=true;this.style("display","none");this.fireEvent("expired",a);return this},enableEvents:function(a){this.mouseEnabled=a;return this},emptyBehaviorList:function(){this.behaviorList=[];return this},setFillStyle:function(a){this.style("background",a);return this},setStrokeStyle:function(){return this},setPaint:function(){},
setAlpha:function(a){this.alpha=a;return this},resetTransform:function(){this.rotationAngle=0;this.rotationY=this.rotationX=0.5;this.scaleY=this.scaleX=1;this.scaleTY=this.scaleTX=0.5;this.scaleAnchor=0;this.oldY=this.oldX=-1;this.style3();this.dirty=true;return this},setFrameTime:function(a,b){this.start_time=a;this.duration=b;this.expired=false;this.dirty=true;return this},paint:function(){},setScale:function(a,b){this.setScaleAnchored(a,b,0.5,0.5);return this},getAnchor:function(a){var b=0,c=0;
switch(a){case this.ANCHOR_CENTER:c=b=0.5;break;case this.ANCHOR_TOP:b=0.5;c=0;break;case this.ANCHOR_BOTTOM:b=0.5;c=1;break;case this.ANCHOR_LEFT:b=0;c=0.5;break;case this.ANCHOR_RIGHT:b=1;c=0.5;break;case this.ANCHOR_TOP_RIGHT:b=1;c=0;break;case this.ANCHOR_BOTTOM_LEFT:b=0;c=1;break;case this.ANCHOR_BOTTOM_RIGHT:c=b=1;break;case this.ANCHOR_TOP_LEFT:c=b=0}return{x:b,y:c}},getAnchorPercent:function(a){var b=[0.5,0.5,0.5,0,0.5,1,0,0.5,1,0.5,0,0,1,0,0,1,1,1];return{x:b[a*2],y:b[a*2+1]}},setScaleAnchored:function(a,
b,c,d){this.rotationX=c;this.rotationY=d;this.scaleTX=c;this.scaleTY=d;this.scaleX=a;this.scaleY=b;this.style3();this.dirty=true;return this},setRotation:function(a){this.setRotationAnchored(a,0.5,0.5);return this},setRotationAnchored:function(a,b,c){this.rotationAngle=a;this.rotationX=b?b:0;this.rotationY=c?c:0;this.style3();this.dirty=true;return this},setSize:function(a,b){this.width=a;this.height=b;this.style("width",""+a+"px");this.style("height",""+b+"px");this.dirty=true;return this},setBounds:function(a,
b,c,d){this.x=a;this.y=b;this.width=c;this.height=d;this.setLocation(a,b);this.setSize(c,d);return this},setLocation:function(a,b){this.x=a;this.y=b;this.style("left",a+"px");this.style("top",b+"px");this.dirty=true;return this},isInAnimationFrame:function(a){if(this.expired)return false;if(this.duration===Number.MAX_VALUE)return this.start_time<=a?true:false;return a>=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a<this.start_time+this.duration},contains:function(a,
b){return a>=0&&b>=0&&a<this.width&&b<this.height},create:function(){return this},addBehavior:function(a){this.behaviorList.push(a);return this},removeBehaviour:function(a){for(var b=this.behaviorList,c=b.length-1;c;)if(b[c]===a){b.splice(c,1);break}return this},removeBehaviorById:function(a){for(var b=this.behaviorList,c=0;c<b.length;c++)b[c].id===a&&b.splice(c,1);return this},getBehavior:function(a){for(var b=this.behaviorList,c=0;c<b.length;c++){var d=b[c];if(d.id===a)return d}return null},setDiscardable:function(a){this.discardable=
a;return this},destroy:function(a){this.domParent=this.parent=null;this.fireEvent("destroyed",a)},modelToView:function(a){if(a instanceof Array)for(var b=0;b<a.length;b++)this.worldModelViewMatrix.transformCoord(a[b]);else this.worldModelViewMatrix.transformCoord(a);return a},viewToModel:function(a){this.worldModelViewMatrixI=this.worldModelViewMatrix.getInverse();this.worldModelViewMatrixI.transformCoord(a);return a},modelToModel:function(a,b){return b.viewToModel(this.modelToView(a))},findActorAtPosition:function(a){if(!this.mouseEnabled||
!this.isInAnimationFrame(this.time))return null;this.setModelViewMatrix();this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(a);return this.contains(a.x,a.y)?this:null},enableDrag:function(){this.my=this.mx=this.ay=this.ax=0;this.asy=this.asx=1;this.screeny=this.screenx=this.ara=0;this.mouseEnter=function(){this.ay=this.ax=-1;this.pointed=true;CAAT.setCursor("move")};this.mouseExit=function(){this.ay=this.ax=-1;this.pointed=false;CAAT.setCursor("default")};
this.mouseMove=function(a){this.mx=a.point.x;this.my=a.point.y};this.mouseUp=function(){this.ay=this.ax=-1};this.mouseDrag=function(a){if(this.ax===-1||this.ay===-1)this.ax=a.point.x,this.ay=a.point.y,this.asx=this.scaleX,this.asy=this.scaleY,this.ara=this.rotationAngle,this.screenx=a.screenPoint.x,this.screeny=a.screenPoint.y;if(a.isShiftDown()){var b=(a.screenPoint.x-this.screenx)/100,c=(a.screenPoint.y-this.screeny)/100;a.isAltDown()||(c=b=a=Math.max(b,c));this.setScale(b+this.asx,c+this.asy)}else a.isControlDown()?
this.setRotation(-Math.atan2(a.screenPoint.x-this.screenx,a.screenPoint.y-this.screeny)+this.ara):(this.setLocation(this.x+a.point.x-this.ax,this.y+a.point.y-this.ay),this.ax=a.point.x,this.ay=a.point.y)};return this},mouseClick:function(){},mouseDblClick:function(){},mouseEnter:function(){this.pointed=true},mouseExit:function(){this.pointed=false},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},mouseOut:function(){},mouseOver:function(){},drawScreenBoundingBox:function(){},
animate:function(a,b){if(this.isInAnimationFrame(b))this.style("display",this.visible?"block":"none");else return this.inFrame=false,this.dirty=true,this.style("display","none"),false;for(var c=0;c<this.behaviorList.length;c++)this.behaviorList[c].apply(b,this);this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:1;this.styleAlpha(this.frameAlpha);this.inFrame=true;this.setModelViewMatrix(false);return true},setModelViewMatrix:function(){var a,b,c,d,e,f,g,h,i,j,k;this.wdirty=false;if(this.dirty){k=
this.modelViewMatrix.identity().matrix;g=k[0];d=k[1];h=k[2];i=k[3];f=k[4];j=k[5];h+=this.x;j+=this.y;this.rotationAngle&&(h+=g*this.rotationX*this.width+d*this.rotationY*this.height,j+=i*this.rotationX*this.width+f*this.rotationY*this.height,a=Math.cos(this.rotationAngle),b=Math.sin(this.rotationAngle),c=g,e=i,g=c*a+d*b,d=-c*b+d*a,i=e*a+f*b,f=-e*b+f*a,h+=-g*this.rotationX*this.width-d*this.rotationY*this.height,j+=-i*this.rotationX*this.width-f*this.rotationY*this.height);if(this.scaleX!=1||this.scaleY!=
1)h+=g*this.scaleTX*this.width+d*this.scaleTY*this.height,j+=i*this.scaleTX*this.width+f*this.scaleTY*this.height,g*=this.scaleX,d*=this.scaleY,i*=this.scaleX,f*=this.scaleY,h+=-g*this.scaleTX*this.width-d*this.scaleTY*this.height,j+=-i*this.scaleTX*this.width-f*this.scaleTY*this.height;k[0]=g;k[1]=d;k[2]=h;k[3]=i;k[4]=f;k[5]=j}if(this.parent){if(this.dirty||this.parent.wdirty)this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix),this.worldModelViewMatrix.multiply(this.modelViewMatrix),
this.wdirty=true}else{if(this.dirty)this.wdirty=true;this.worldModelViewMatrix.identity()}this.dirty=false;return this},paintActor:function(){return true},endAnimate:function(){return this},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this},setClip:function(a){this.clip=a;this.style("overflow",this.clip?"hidden":"visible");return this},cacheAsBitmap:function(){return this},setAsButton:function(a,b,c,d,e,f){this.setBackgroundImage(a,true);this.iNormal=b||0;this.iOver=c||b;this.iPress=
d||b;this.iDisabled=e||b;this.fnOnClick=f;this.enabled=true;this.setSpriteIndex(b);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled)};this.actionPerformed=function(){this.enabled&&null!==this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.setSpriteIndex(this.iNormal);CAAT.setCursor("default")};
this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(){this.setSpriteIndex(this.iNormal);this.dragging=false};this.mouseClick=function(){};this.mouseDrag=function(){if(this.enabled)this.dragging=true};this.setButtonImageIndex=function(a,b,c,d){this.iNormal=a;this.iOver=b;this.iPress=c;this.iDisabled=d;this.setSpriteIndex(this.iNormal);return this};return this}}})();
(function(){CAAT.ActorContainer=function(){CAAT.ActorContainer.superclass.constructor.call(this);this.childrenList=[];this.pendingChildrenList=[];if(typeof hint!=="undefined")this.addHint=hint,this.boundingBox=new CAAT.Rectangle;return this};CAAT.ActorContainer.AddHint={CONFORM:1};CAAT.ActorContainer.prototype={childrenList:null,activeChildren:null,pendingChildrenList:null,addHint:0,boundingBox:null,runion:new CAAT.Rectangle,emptyChildren:function(){this.parentNode.innerHTML="";this.childrenList=
[];return this},paintActor:function(){return true},animate:function(a,b){var c=this.activeChildren=null;if(false===CAAT.ActorContainer.superclass.animate.call(this,a,b))return false;var d;for(d=this.size_total=this.size_active=0;d<this.pendingChildrenList.length;d++)this.addChild(this.pendingChildrenList[d]);this.pendingChildrenList=[];var e=this.childrenList;for(d=0;d<e.length;d++){var f=e[d];f.time=b;this.size_total+=f.size_total;f.animate(a,b)?(this.activeChildren?(f.__next=null,c.__next=f):(this.activeChildren=
f,f.__next=null),c=f,this.size_active+=f.size_active):f.expired&&f.discardable&&(this.domElement.removeChild(f.domElement),f.destroy(b),e.splice(d,1))}return true},endAnimate:function(){},addChildImmediately:function(a){return this.addChild(a)},addChild:function(a){a.setParent(this);this.childrenList.push(a);a.dirty=true;this.addHint===CAAT.ActorContainer.AddHint.CONFORM&&this.recalcSize();return this},recalcSize:function(){var a=this.boundingBox;a.setEmpty();for(var b=this.childrenList,c,d=0;d<b.length;d++)c=
b[d],this.runion.setBounds(c.x<0?0:c.x,c.y<0?0:c.y,c.width,c.height),a.unionRectangle(this.runion);this.setSize(a.x1,a.y1);return this},addChildDelayed:function(a){this.pendingChildrenList.push(a);return this},addChildAt:function(a,b){if(b<=0)return a.parent=this,a.dirty=true,this.childrenList.splice(0,0,a),this;else if(b>=this.childrenList.length)b=this.childrenList.length;a.setParent(this);this.childrenList.splice(b,0,a);this.domElement.insertBefore(a.domElement,this.domElement.childNodes[b]);a.dirty=
true;return this},findChild:function(a){for(var b=0,c=this.childrenList.length,b=0;b<c;b++)if(this.childrenList[b]===a)return b;return-1},removeChild:function(a){a=this.findChild(a);-1!==a&&(this.childrenList[a].setParent(null),this.childrenList.splice(a,1));return this},findActorAtPosition:function(a){if(null===CAAT.ActorContainer.superclass.findActorAtPosition.call(this,a))return null;for(var b=this.childrenList.length-1;b>=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);
if(null!==c)return c}return this},destroy:function(){for(var a=this.childrenList.length-1;a>=0;a--)this.childrenList[a].destroy();CAAT.ActorContainer.superclass.destroy.call(this);return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length},getChildAt:function(a){return this.childrenList[a]},setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c){if(b>=d.length)d.splice(c,1),d.push(a);
else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}for(var c=0,e=d.length;c<e;c++)d[c].domElement.style["z-index"]=c}}}};extend(CAAT.ActorContainer,CAAT.Actor,null)})();(function(){CAAT.AudioManager=function(){this.browserInfo=new CAAT.BrowserDetect;return this};CAAT.AudioManager.prototype={browserInfo:null,musicEnabled:true,fxEnabled:true,audioCache:null,channels:null,workingChannels:null,loopingChannels:[],audioTypes:{mp3:"audio/mpeg;",ogg:'audio/ogg; codecs="vorbis"',wav:'audio/wav; codecs="1"',mp4:'audio/mp4; codecs="mp4a.40.2"'},initialize:function(a){this.audioCache=[];this.channels=[];this.workingChannels=[];for(var b=0;b<a;b++){var c=document.createElement("audio");
if(null!==c){c.finished=-1;this.channels.push(c);var d=this;c.addEventListener("ended",function(a){var a=a.target,b;for(b=0;b<d.workingChannels.length;b++)if(d.workingChannels[b]===a){d.workingChannels.splice(b,1);break}a.caat_callback&&a.caat_callback(a.caat_id);d.channels.push(a)},false)}}return this},addAudioFromURL:function(a,b,c){var d=null,e=document.createElement("audio");if(null!==e){if(!e.canPlayType)return false;d=b.substr(b.lastIndexOf(".")+1);d=e.canPlayType(this.audioTypes[d]);if(d!==
""&&d!=="no"){e.src=b;e.preload="auto";e.load();if(c)e.caat_callback=c,e.caat_id=a;this.audioCache.push({id:a,audio:e});return true}}return false},addAudioFromDomNode:function(a,b,c){var d=b.src.substr(b.src.lastIndexOf(".")+1);if(b.canPlayType(this.audioTypes[d])){if(c)b.caat_callback=c,b.caat_id=a;this.audioCache.push({id:a,audio:b});return true}return false},addAudioElement:function(a,b,c){if(typeof b==="string")return this.addAudioFromURL(a,b,c);else try{if(b instanceof HTMLAudioElement)return this.addAudioFromDomNode(a,
b,c)}catch(d){}return false},addAudio:function(a,b,c){if(b instanceof Array)for(var d=0;d<b.length;d++){if(this.addAudioElement(a,b[d],c))break}else this.addAudioElement(a,b,c);return this},getAudio:function(a){for(var b=0;b<this.audioCache.length;b++)if(this.audioCache[b].id===a)return this.audioCache[b].audio;return null},play:function(a){if(!this.fxEnabled)return this;a=this.getAudio(a);if(null!==a&&this.channels.length>0){var b=this.channels.shift();b.src=a.src;b.load();b.play();this.workingChannels.push(b)}return this},
loop:function(a){if(!this.musicEnabled)return this;a=this.getAudio(a);if(null!==a){var b=document.createElement("audio");if(null!==b)return b.src=a.src,b.preload="auto",this.browserInfo.browser==="Firefox"?b.addEventListener("ended",function(a){a.target.currentTime=0},false):b.loop=true,b.load(),b.play(),this.loopingChannels.push(b),b}return null},endSound:function(){var a;for(a=0;a<this.workingChannels.length;a++)this.workingChannels[a].pause(),this.channels.push(this.workingChannels[a]);for(a=0;a<
this.loopingChannels.length;a++)this.loopingChannels[a].pause();return this},setSoundEffectsEnabled:function(a){this.fxEnabled=a;return this},isSoundEffectsEnabled:function(){return this.fxEnabled},setMusicEnabled:function(a){this.musicEnabled=a;for(var b=0;b<this.loopingChannels.length;b++)a?this.loopingChannels[b].play():this.loopingChannels[b].pause();return this},isMusicEnabled:function(){return this.musicEnabled}}})();(function(){CAAT.Dock=function(){CAAT.Dock.superclass.constructor.call(this);return this};CAAT.Dock.prototype={scene:null,ttask:null,minSize:0,maxSize:0,range:2,layoutOp:0,OP_LAYOUT_BOTTOM:0,OP_LAYOUT_TOP:1,OP_LAYOUT_LEFT:2,OP_LAYOUT_RIGHT:3,initialize:function(a){this.scene=a;return this},setApplicationRange:function(a){this.range=a;return this},setLayoutOp:function(a){this.layoutOp=a;return this},setSizes:function(a,b){this.minSize=a;this.maxSize=b;for(var c=0;c<this.childrenList.length;c++)this.childrenList[c].width=
a,this.childrenList[c].height=a;return this},layout:function(){var a,b;if(this.layoutOp===this.OP_LAYOUT_BOTTOM||this.layoutOp===this.OP_LAYOUT_TOP){var c=b=0;for(a=0;a<this.getNumChildren();a++)b+=this.getChildAt(a).width;c=(this.width-b)/2;for(a=0;a<this.getNumChildren();a++)b=this.getChildAt(a),b.x=c,c+=b.width,b.y=this.layoutOp===this.OP_LAYOUT_BOTTOM?this.maxSize-b.height:0}else{for(a=c=b=0;a<this.getNumChildren();a++)b+=this.getChildAt(a).height;c=(this.height-b)/2;for(a=0;a<this.getNumChildren();a++)b=
this.getChildAt(a),b.y=c,c+=b.height,b.x=this.layoutOp===this.OP_LAYOUT_LEFT?0:this.width-b.width}},mouseMove:function(){this.actorNotPointed()},mouseExit:function(){this.actorNotPointed()},actorNotPointed:function(){var a,b=this;for(a=0;a<this.getNumChildren();a++){var c=this.getChildAt(a);c.emptyBehaviorList();c.addBehavior((new CAAT.GenericBehavior).setValues(c.width,this.minSize,c,"width").setFrameTime(this.scene.time,250)).addBehavior((new CAAT.GenericBehavior).setValues(c.height,this.minSize,
c,"height").setFrameTime(this.scene.time,250));a===this.getNumChildren()-1&&c.behaviorList[0].addListener({behaviorApplied:function(a,b,c,g){g.parent.layout()},behaviorExpired:function(d,e,f){for(a=0;a<b.getNumChildren();a++)c=b.getChildAt(a),c.width=b.minSize,c.height=b.minSize;f.parent.layout()}})}},actorPointed:function(a,b,c){for(var d=this.findChild(c),e=0,e=this.layoutOp===this.OP_LAYOUT_BOTTOM||this.layoutOp===this.OP_LAYOUT_TOP?a/c.width:b/c.height,a=0;a<this.childrenList.length;a++)b=this.childrenList[a],
b.emptyBehaviorList(),c=0,c=a<d-this.range||a>d+this.range?this.minSize:a===d?this.maxSize:a<d?this.minSize+(this.maxSize-this.minSize)*(Math.cos((a-d-e+1)/this.range*Math.PI)+1)/2:this.minSize+(this.maxSize-this.minSize)*(Math.cos((a-d-e)/this.range*Math.PI)+1)/2,b.height=c,b.width=c;this.layout()},actorMouseExit:function(){null!==this.ttask&&this.ttask.cancel();var a=this;this.ttask=this.scene.createTimer(this.scene.time,100,function(){a.actorNotPointed()},null,null)},actorMouseEnter:function(){if(null!==
this.ttask)this.ttask.cancel(),this.ttask=null},addChild:function(a){var b=this;a.__Dock_mouseEnter=a.mouseEnter;a.__Dock_mouseExit=a.mouseExit;a.__Dock_mouseMove=a.mouseMove;a.mouseEnter=function(a){b.actorMouseEnter(a);this.__Dock_mouseEnter(a)};a.mouseExit=function(a){b.actorMouseExit(a);this.__Dock_mouseExit(a)};a.mouseMove=function(a){b.actorPointed(a.point.x,a.point.y,a.source);this.__Dock_mouseMove(a)};a.width=this.minSize;a.height=this.minSize;return CAAT.Dock.superclass.addChild.call(this,
a)}};extend(CAAT.Dock,CAAT.ActorContainer,null)})();(function(){CAAT.Director=function(){CAAT.Director.superclass.constructor.call(this);this.browserInfo=new CAAT.BrowserDetect;this.audioManager=(new CAAT.AudioManager).initialize(8);this.scenes=[];this.mousePoint=new CAAT.Point(0,0,0);this.prevMousePoint=new CAAT.Point(0,0,0);this.screenMousePoint=new CAAT.Point(0,0,0);this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.cDirtyRects=[];this.dirtyRects=[];for(var a=0;a<64;a++)this.dirtyRects.push(new CAAT.Rectangle);this.dirtyRectsIndex=
0;return this};CAAT.Director.CLEAR_DIRTY_RECTS=1;CAAT.Director.CLEAR_ALL=true;CAAT.Director.CLEAR_NONE=false;CAAT.Director.prototype={debug:false,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:false,lastSelectedActor:null,dragging:false,scenes:null,currentScene:null,canvas:null,crc:null,ctx:null,time:0,timeline:0,imagesCache:null,audioManager:null,clear:true,transitionScene:null,browserInfo:null,gl:null,glEnabled:false,glTextureManager:null,
glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:false,statistics:{size_total:0,size_active:0,draws:0},currentTexturePage:0,currentOpacity:1,intervalId:null,frameCounter:0,RESIZE_NONE:1,RESIZE_WIDTH:2,RESIZE_HEIGHT:4,RESIZE_BOTH:8,RESIZE_PROPORTIONAL:16,resize:1,onResizeCallback:null,__gestureScale:0,__gestureRotation:0,dirtyRects:null,cDirtyRects:null,dirtyRectsIndex:0,dirtyRectsEnabled:false,checkDebug:function(){if(CAAT.DEBUG){var a=
(new CAAT.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){switch(this.resize){case this.RESIZE_WIDTH:this.setBounds(0,0,a,this.height);break;case this.RESIZE_HEIGHT:this.setBounds(0,0,this.width,b);break;case this.RESIZE_BOTH:this.setBounds(0,0,a,b);break;case this.RESIZE_PROPORTIONAL:this.setScaleProportional(a,b)}this.glEnabled&&this.glReset();if(this.onResizeCallback)this.onResizeCallback(this,
a,b)},setScaleProportional:function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.canvas.width=this.referenceWidth*c;this.canvas.height=this.referenceHeight*c;this.crc=this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");this.glEnabled&&this.glReset()},enableResizeEvents:function(a,b){a===this.RESIZE_BOTH||a===this.RESIZE_WIDTH||a===this.RESIZE_HEIGHT||a===this.RESIZE_PROPORTIONAL?(this.referenceWidth=this.width,this.referenceHeight=
this.height,this.resize=a,CAAT.registerResizeListener(this),this.onResizeCallback=b,this.windowResized(window.innerWidth,window.innerHeight)):(CAAT.unregisterResizeListener(this),this.onResizeCallback=null)},setBounds:function(a,b,c,d){CAAT.Director.superclass.setBounds.call(this,a,b,c,d);this.canvas.width=c;this.canvas.height=d;this.crc=this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");for(a=0;a<this.scenes.length;a++)this.scenes[a].setBounds(0,0,c,d);this.glEnabled&&this.glReset();
return this},initialize:function(a,b,c,d){this.canvas=c=c||document.createElement("canvas");typeof d==="undefined"&&(d=c);this.setBounds(0,0,a,b);this.create();this.enableEvents(d);this.timeline=(new Date).getTime();this.transitionScene=(new CAAT.Scene).create().setBounds(0,0,a,b);c=document.createElement("canvas");c.width=a;c.height=b;a=(new CAAT.Actor).create().setBackgroundImage(c);this.transitionScene.ctx=c.getContext("2d");this.transitionScene.addChildImmediately(a);this.transitionScene.setEaseListener(this);
this.checkDebug();return this},glReset:function(){this.pMatrix=makeOrtho(0,this.referenceWidth,this.referenceHeight,0,-1,1);this.gl.viewport(0,0,this.canvas.width,this.canvas.height);this.glColorProgram.setMatrixUniform(this.pMatrix);this.glTextureProgram.setMatrixUniform(this.pMatrix);this.gl.viewportWidth=this.canvas.width;this.gl.viewportHeight=this.canvas.height},initializeGL:function(a,b,c){c=c||document.createElement("canvas");c.width=a;c.height=b;this.referenceWidth=a;this.referenceHeight=
b;try{this.gl=c.getContext("experimental-webgl"),this.gl.viewportWidth=a,this.gl.viewportHeight=b}catch(d){}if(this.gl)this.canvas=c,this.create(),this.setBounds(0,0,a,b),this.crc=this.ctx,this.enableEvents(c),this.timeline=(new Date).getTime(),this.glColorProgram=(new CAAT.ColorProgram(this.gl)).create().initialize(),this.glTextureProgram=(new CAAT.TextureProgram(this.gl)).create().initialize(),this.glTextureProgram.useProgram(),this.glReset(),this.coords=new Float32Array(6144),this.uv=new Float32Array(4096),
this.gl.clearColor(0,0,0,255),this.front_to_back?(this.gl.clearDepth(1),this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LESS)):this.gl.disable(this.gl.DEPTH_TEST),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.glEnabled=true,this.checkDebug();else return this.initialize(a,b,c);return this},createScene:function(){var a=(new CAAT.Scene).create();this.addScene(a);return a},setImagesCache:function(a,b,c){var d;if(null!==this.glTextureManager)this.glTextureManager.deletePages(),
this.glTextureManager=null;if(this.imagesCache){var e=[];for(d=0;d<this.imagesCache.length;d++)e.push(this.imagesCache[d].id);for(d=0;d<e.length;d++)delete this.imagesCache[e[d]]}if(this.imagesCache=a)for(d=0;d<a.length;d++)this.imagesCache[a[d].id]=a[d].image;this.tpW=b||2048;this.tpH=c||2048;this.updateGLPages()},updateGLPages:function(){if(this.glEnabled)this.glTextureManager=new CAAT.GLTexturePageManager,this.glTextureManager.createPages(this.gl,this.tpW,this.tpH,this.imagesCache),this.currentTexturePage=
this.glTextureManager.pages[0],this.glTextureProgram.setTexture(this.currentTexturePage.texture)},setGLTexturePage:function(a){this.currentTexturePage=a;this.glTextureProgram.setTexture(a.texture);return this},addImage:function(a,b,c){if(this.getImage(a))for(var d=0;d<this.imagesCache.length;d++){if(this.imagesCache[d].id===a){this.imagesCache[d].image=b;break}}else this.imagesCache.push({id:a,image:b});this.imagesCache[a]=b;c||this.updateGLPages()},deleteImage:function(a,b){for(var c=0;c<this.imagesCache.length;c++)if(this.imagesCache[c].id===
a){delete this.imagesCache[a];this.imagesCache.splice(c,1);break}b||this.updateGLPages()},setGLCurrentOpacity:function(a){this.currentOpacity=a;this.glTextureProgram.setAlpha(a)},glRender:function(a,b,c){var a=a||this.coords,c=c||this.uv,b=b||this.coordsIndex,d=this.gl,b=b/12*2;this.glTextureProgram.updateVertexBuffer(a);this.glTextureProgram.updateUVBuffer(c);d.drawElements(d.TRIANGLES,3*b,d.UNSIGNED_SHORT,0)},glFlush:function(){this.coordsIndex!==0&&this.glRender(this.coords,this.coordsIndex,this.uv);
this.uvIndex=this.coordsIndex=0;this.statistics.draws++},findActorAtPosition:function(a){for(var b=this.childrenList.length-1;b>=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0},render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|
this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c<b;c++)if(e=this.childrenList[c],e.isInAnimationFrame(this.time)){d=e.time-e.start_time;if(e.onRenderStart)e.onRenderStart(d);e.paintActorGL(this,d);if(e.onRenderEnd)e.onRenderEnd(d);e.isPaused()||(e.time+=a);CAAT.DEBUG&&(this.statistics.size_total+=e.size_total,this.statistics.size_active+=e.size_active)}this.glFlush()}else{f.globalAlpha=1;f.globalCompositeOperation="source-over";f.save();if(this.dirtyRectsEnabled){f.beginPath();f.rect(0,
0,120,40);d=this.cDirtyRects;for(c=0;c<d.length;c++)e=d[c],e.isEmpty()||f.rect(e.x|0,e.y|0,1+(e.width|0),1+(e.height|0));f.clip()}else this.clear===true&&f.clearRect(0,0,this.width,this.height);for(c=0;c<b;c++)if(e=this.childrenList[c],e.isInAnimationFrame(this.time)){d=e.time-e.start_time;if(e.onRenderStart)e.onRenderStart(d);e.paintActor(this,d);if(e.onRenderEnd)e.onRenderEnd(d);if(CAAT.DEBUGAABB)f.globalAlpha=1,f.globalCompositeOperation="source-over",this.modelViewMatrix.transformRenderingContextSet(f),
e.drawScreenBoundingBox(this,d);e.isPaused()||(e.time+=a);CAAT.DEBUG&&(this.statistics.size_total+=e.size_total,this.statistics.size_active+=e.size_active)}f.restore()}this.frameCounter++},animate:function(){this.setModelViewMatrix(this);this.invalid=this.dirty=false;this.dirtyRectsIndex=-1;this.cDirtyRects=[];for(var a=this.childrenList,b,c=0;c<a.length;c++)b=a[c],b.animate(this,b.time-b.start_time);return this},addDirtyRect:function(a){if(!a.isEmpty()){var b,c,d,e,f=this.cDirtyRects;for(b=0;b<f.length;b++)if(c=
f[b],!c.isEmpty()&&c.intersects(a)){for(var g=true;g;){c.unionRectangle(a);for(d=0;d<f.length;d++)if(d!==b&&(e=f[d],!e.isEmpty()&&e.intersects(c))){c.unionRectangle(e);e.setEmpty();break}d==f.length&&(g=false)}for(d=0;d<f.length;d++)f[d].isEmpty()&&f.splice(d,1);return}this.dirtyRectsIndex++;if(this.dirtyRectsIndex>=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;
this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=
e;a.restore();this.ctx=c;this.crc=d}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),this.renderToContext(this.transitionScene.ctx,
d),d=this.transitionScene;a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform();a.setLocation(0,0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,
h,f,j);this.childrenList=[];this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e<0.33?(e=CAAT.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=
(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,
c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)},setScene:function(a){a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)},switchToPrevScene:function(a,
b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a,b){b?(this.currentScene=
a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b<this.scenes.length;b++)if(this.scenes[b]===a)return b;return-1},getScene:function(a){return this.scenes[a]},getCurrentSceneIndex:function(){return this.getSceneIndex(this.currentScene)},getBrowserName:function(){return this.browserInfo.browser},getBrowserVersion:function(){return this.browserInfo.version},getOSName:function(){return this.browserInfo.OS},getImage:function(a){var b=
this.imagesCache[a];if(b)return b;for(b=0;b<this.imagesCache.length;b++)if(this.imagesCache[b].id===a)return this.imagesCache[b].image;return null},addAudio:function(a,b){this.audioManager.addAudio(a,b);return this},audioPlay:function(a){this.audioManager.play(a)},audioLoop:function(a){return this.audioManager.loop(a)},endSound:function(){return this.audioManager.endSound()},setSoundEffectsEnabled:function(a){return this.audioManager.setSoundEffectsEnabled(a)},setMusicEnabled:function(a){return this.audioManager.setMusicEnabled(a)},
isMusicEnabled:function(){return this.audioManager.isMusicEnabled()},isSoundEffectsEnabled:function(){return this.audioManager.isSoundEffectsEnabled()},emptyScenes:function(){this.scenes=[]},addChild:function(a){a.parent=this;this.childrenList.push(a)},loop:function(a,b,c){if(c)this.onRenderStart=b,this.onRenderEnd=c;else if(b)this.onRenderEnd=b;CAAT.loop()},renderFrame:function(){var a=(new Date).getTime(),b=a-this.timeline;b>500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);
this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled=true;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,
null))?g.getPropertyValue("position"):null,/^(fixed)$/.test(g))break;else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset");return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+
document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown=true;var b=this.findActorAtPosition(this.mousePoint);
if(null!==b){var c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&
c.actionPerformed(a),c.mouseUp((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,
this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x=c.x;this.prevMousePoint.y=c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,
this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),
b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);
a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time);this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_=this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,
0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,
this.mousePoint.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();if(!this.gesturing)for(var b=0;b<a.targetTouches.length;b++)b||this.__mouseMoveHandler(a.targetTouches[b])},__gestureStart:function(){this.gesturing=true;this.__gestureRotation=
this.lastSelectedActor.rotationAngle;this.__gestureSX=this.lastSelectedActor.scaleX-1;this.__gestureSY=this.lastSelectedActor.scaleY-1},__gestureChange:function(a,b){if(!(typeof a==="undefined"||typeof b==="undefined")&&this.lastSelectedActor!==null&&this.lastSelectedActor.isGestureEnabled())this.lastSelectedActor.setRotation(b*Math.PI/180+this.__gestureRotation),this.lastSelectedActor.setScale(this.__gestureSX+a,this.__gestureSY+a)},__gestureEnd:function(){this.gesturing=false;this.__gestureScale=
this.__gestureRotation=0},addHandlers:function(a){var b=this;a.addEventListener("mouseup",function(a){a.preventDefault();b.__mouseUpHandler(a)},false);a.addEventListener("mousedown",function(a){a.preventDefault();b.__mouseDownHandler(a)},false);a.addEventListener("mouseover",function(a){a.preventDefault();b.__mouseOverHandler(a)},false);a.addEventListener("mouseout",function(a){a.preventDefault();b.__mouseOutHandler(a)},false);a.addEventListener("mousemove",function(a){a.preventDefault();b.__mouseMoveHandler(a)},
false);a.addEventListener("dblclick",function(a){a.preventDefault();b.__mouseDBLClickHandler(a)},false);a.addEventListener("touchstart",this.__touchStartHandler.bind(this),false);a.addEventListener("touchmove",this.__touchMoveHandler.bind(this),false);a.addEventListener("touchend",this.__touchEndHandler.bind(this),false);a.addEventListener("gesturestart",function(a){a.preventDefault();b.__gestureStart(a.scale,a.rotation)},false);a.addEventListener("gestureend",function(a){a.preventDefault();b.__gestureEnd(a.scale,
a.rotation)},false);a.addEventListener("gesturechange",function(a){a.preventDefault();b.__gestureChange(a.scale,a.rotation)},false)},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=false;this.createEventHandler(a)},createEventHandler:function(a){this.in_=false;this.addHandlers(a)}};if(CAAT.__CSS__)CAAT.Director.prototype.clip=true,CAAT.Director.prototype.glEnabled=false,CAAT.Director.prototype.getRenderType=function(){return"CSS"},CAAT.Director.prototype.setScaleProportional=function(a,
b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.eventHandler.style.width=""+this.referenceWidth+"px";this.eventHandler.style.height=""+this.referenceHeight+"px"},CAAT.Director.prototype.setBounds=function(a,b,c,d){CAAT.Director.superclass.setBounds.call(this,a,b,c,d);for(a=0;a<this.scenes.length;a++)this.scenes[a].setBounds(0,0,c,d);this.eventHandler.style.width=c+"px";this.eventHandler.style.height=d+"px";return this},CAAT.Director.prototype.initialize=
function(a,b,c){this.timeline=(new Date).getTime();this.domElement=c;this.style("position","absolute");this.style("width",""+a+"px");this.style("height",""+b+"px");this.style("overflow","hidden");this.enableEvents(c);this.setBounds(0,0,a,b);this.checkDebug();return this},CAAT.Director.prototype.render=function(a){this.time+=a;this.animate(this,a);var b,c,d;CAAT.DEBUG&&this.resetStats();for(b=0,c=this.childrenList.length;b<c;b++){var e=this.childrenList[b];if(e.isInAnimationFrame(this.time)){d=e.time-
e.start_time;if(e.onRenderStart)e.onRenderStart(d);if(e.onRenderEnd)e.onRenderEnd(d);e.isPaused()||(e.time+=a);CAAT.DEBUG&&(this.statistics.size_total+=e.size_total,this.statistics.size_active+=e.size_active)}}this.frameCounter++},CAAT.Director.prototype.addScene=function(a){a.setVisible(true);a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&&this.setScene(0);this.domElement.appendChild(a.domElement)},CAAT.Director.prototype.emptyScenes=
function(){this.scenes=[];this.domElement.innerHTML="";this.createEventHandler()},CAAT.Director.prototype.setClear=function(){return this},CAAT.Director.prototype.createEventHandler=function(){this.eventHandler=document.createElement("div");this.domElement.appendChild(this.eventHandler);this.eventHandler.style.position="absolute";this.eventHandler.style.left="0";this.eventHandler.style.top="0";this.eventHandler.style.zIndex=999999;this.eventHandler.style.width=""+this.width+"px";this.eventHandler.style.height=
""+this.height+"px";var a=this.eventHandler;this.in_=false;this.addHandlers(a)};extend(CAAT.Director,CAAT.ActorContainer,null)})();(function(){CAAT.MouseEvent=function(){this.point=new CAAT.Point(0,0,0);this.screenPoint=new CAAT.Point(0,0,0);return this};CAAT.MouseEvent.prototype={screenPoint:null,point:null,time:0,source:null,shift:false,control:false,alt:false,meta:false,sourceEvent:null,init:function(a,b,c,d,e,f){this.point.set(a,b);this.source=d;this.screenPoint=e;this.alt=c.altKey;this.control=c.ctrlKey;this.shift=c.shiftKey;this.meta=c.metaKey;this.sourceEvent=c;this.x=a;this.y=b;this.time=f;return this},isAltDown:function(){return this.alt},
isControlDown:function(){return this.control},isShiftDown:function(){return this.shift},isMetaDown:function(){return this.meta},getSourceEvent:function(){return this.sourceEvent}}})();
CAAT.setCoordinateClamping=function(a){a?(CAAT.Matrix.prototype.transformRenderingContext=CAAT.Matrix.prototype.transformRenderingContext_Clamp,CAAT.Matrix.prototype.transformRenderingContextSet=CAAT.Matrix.prototype.transformRenderingContextSet_Clamp):(CAAT.Matrix.prototype.transformRenderingContext=CAAT.Matrix.prototype.transformRenderingContext_NoClamp,CAAT.Matrix.prototype.transformRenderingContextSet=CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp)};CAAT.PMR=64;CAAT.DEBUG=false;
CAAT.DEBUGBB=false;CAAT.DEBUGBBBCOLOR="#00f";CAAT.DEBUGAABB=false;CAAT.DEBUGAABBCOLOR="#f00";CAAT.log=function(){window.console&&window.console.log(Array.prototype.slice.call(arguments))};CAAT.FRAME_TIME=0;CAAT.GlobalEventsEnabled=false;CAAT.prevOnDeviceMotion=null;CAAT.onDeviceMotion=null;CAAT.accelerationIncludingGravity={x:0,y:0,z:0};CAAT.rotationRate={alpha:0,beta:0,gamma:0};CAAT.DRAG_THRESHOLD_X=5;CAAT.DRAG_THRESHOLD_Y=5;CAAT.renderEnabled=false;CAAT.FPS=60;CAAT.windowResizeListeners=[];
CAAT.registerResizeListener=function(a){CAAT.windowResizeListeners.push(a)};CAAT.unregisterResizeListener=function(a){for(var b=0;b<CAAT.windowResizeListeners.length;b++)if(a===CAAT.windowResizeListeners[b]){CAAT.windowResizeListeners.splice(b,1);break}};CAAT.keyListeners=[];CAAT.registerKeyListener=function(a){CAAT.keyListeners.push(a)};
CAAT.Keys={ENTER:13,BACKSPACE:8,TAB:9,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPSLOCK:20,ESCAPE:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,SELECT:93,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,
SUBTRACT:109,DECIMALPOINT:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SCROLLLOCK:145,SEMICOLON:186,EQUALSIGN:187,COMMA:188,DASH:189,PERIOD:190,FORWARDSLASH:191,GRAVEACCENT:192,OPENBRACKET:219,BACKSLASH:220,CLOSEBRAKET:221,SINGLEQUOTE:222};CAAT.SHIFT_KEY=16;CAAT.CONTROL_KEY=17;CAAT.ALT_KEY=18;CAAT.ENTER_KEY=13;CAAT.KEY_MODIFIERS={alt:false,control:false,shift:false};
CAAT.KeyEvent=function(a,b,c,d){this.keyCode=a;this.action=b;this.modifiers=c;this.sourceEvent=d;this.preventDefault=function(){this.sourceEvent.preventDefault()};this.getKeyCode=function(){return this.keyCode};this.getAction=function(){return this.action};this.modifiers=function(){return this.modifiers};this.isShiftPressed=function(){return this.modifiers.shift};this.isControlPressed=function(){return this.modifiers.control};this.isAltPressed=function(){return this.modifiers.alt};this.getSourceEvent=
function(){return this.sourceEvent}};
CAAT.GlobalEnableEvents=function(){if(!CAAT.GlobalEventsEnabled)this.GlobalEventsEnabled=true,window.addEventListener("keydown",function(a){var b=a.which?a.which:a.keyCode;if(b===CAAT.SHIFT_KEY)CAAT.KEY_MODIFIERS.shift=true;else if(b===CAAT.CONTROL_KEY)CAAT.KEY_MODIFIERS.control=true;else if(b===CAAT.ALT_KEY)CAAT.KEY_MODIFIERS.alt=true;else for(var c=0;c<CAAT.keyListeners.length;c++)CAAT.keyListeners[c](new CAAT.KeyEvent(b,"down",{alt:CAAT.KEY_MODIFIERS.alt,control:CAAT.KEY_MODIFIERS.control,shift:CAAT.KEY_MODIFIERS.shift},
a))},false),window.addEventListener("keyup",function(a){var b=a.which?a.which:a.keyCode;if(b===CAAT.SHIFT_KEY)CAAT.KEY_MODIFIERS.shift=false;else if(b===CAAT.CONTROL_KEY)CAAT.KEY_MODIFIERS.control=false;else if(b===CAAT.ALT_KEY)CAAT.KEY_MODIFIERS.alt=false;else for(var c=0;c<CAAT.keyListeners.length;c++)CAAT.keyListeners[c](new CAAT.KeyEvent(b,"up",{alt:CAAT.KEY_MODIFIERS.alt,control:CAAT.KEY_MODIFIERS.control,shift:CAAT.KEY_MODIFIERS.shift},a))},false),window.addEventListener("resize",function(){for(var a=
0;a<CAAT.windowResizeListeners.length;a++)CAAT.windowResizeListeners[a].windowResized(window.innerWidth,window.innerHeight)},false)};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/CAAT.FPS)}}();CAAT.SET_INTERVAL=0;
CAAT.loop=function(a){if(!CAAT.renderEnabled)CAAT.FPS=a||60,CAAT.renderEnabled=true,CAAT.NO_PERF?setInterval(function(){for(var a=(new Date).getTime(),c=0,d=CAAT.director.length;c<d;c++)CAAT.director[c].renderFrame();CAAT.FRAME_TIME=a-CAAT.SET_INTERVAL;CAAT.SET_INTERVAL=a},1E3/CAAT.FPS):CAAT.renderFrame()};CAAT.FPS_REFRESH=500;CAAT.RAF=0;CAAT.REQUEST_ANIMATION_FRAME_TIME=0;
CAAT.renderFrame=function(){for(var a=(new Date).getTime(),b=0,c=CAAT.director.length;b<c;b++)CAAT.director[b].renderFrame();a=(new Date).getTime()-a;CAAT.FRAME_TIME=a;if(CAAT.RAF)CAAT.REQUEST_ANIMATION_FRAME_TIME=(new Date).getTime()-CAAT.RAF;CAAT.RAF=(new Date).getTime();window.requestAnimFrame(CAAT.renderFrame,0)};CAAT.setCursor=function(a){if(navigator.browser!=="iOS")document.body.style.cursor=a};CAAT.RegisterDirector=function(a){if(!CAAT.director)CAAT.director=[];CAAT.director.push(a);CAAT.GlobalEnableEvents()};
(function(){function a(a){CAAT.rotationRate={alpha:0,beta:a[0],gamma:a[1]}}window.DeviceOrientationEvent?window.addEventListener("deviceorientation",function(b){a([b.beta,b.gamma])},true):window.DeviceMotionEvent?window.addEventListener("devicemotion",function(b){a([b.acceleration.x*2,b.acceleration.y*2])},true):window.addEventListener("MozOrientation",function(b){a([-b.y*45,b.x*45])},true)})();(function(){CAAT.SpriteImageHelper=function(a,b,c,d,e,f){this.x=a;this.y=b;this.width=c;this.height=d;this.setGL(a/e,b/f,(a+c-1)/e,(b+d-1)/f);return this};CAAT.SpriteImageHelper.prototype={x:0,y:0,width:0,height:0,u:0,v:0,u1:0,v1:0,setGL:function(a,b,c,d){this.u=a;this.v=b;this.u1=c;this.v1=d;return this}}})();
(function(){CAAT.SpriteImage=function(){this.paint=this.paintN;this.setAnimationImageIndex([0]);this.mapInfo={};return this};CAAT.SpriteImage.prototype={animationImageIndex:null,prevAnimationTime:-1,changeFPS:1E3,transformation:0,spriteIndex:0,TR_NONE:0,TR_FLIP_HORIZONTAL:1,TR_FLIP_VERTICAL:2,TR_FLIP_ALL:3,TR_FIXED_TO_SIZE:4,TR_TILE:5,image:null,rows:1,columns:1,width:0,height:0,singleWidth:0,singleHeight:0,scaleX:1,scaleY:1,offsetX:0,offsetY:0,ownerActor:null,mapInfo:null,map:null,setOwner:function(a){this.ownerActor=
a;return this},getRows:function(){return this.rows},getColumns:function(){return this.columns},getWidth:function(){return this.mapInfo[this.spriteIndex].width},getHeight:function(){return this.mapInfo[this.spriteIndex].height},getRef:function(){var a=new CAAT.SpriteImage;a.image=this.image;a.rows=this.rows;a.columns=this.columns;a.width=this.width;a.height=this.height;a.singleWidth=this.singleWidth;a.singleHeight=this.singleHeight;a.mapInfo=this.mapInfo;a.offsetX=this.offsetX;a.offsetY=this.offsetY;
a.scaleX=this.scaleX;a.scaleY=this.scaleY;return a},setOffsetX:function(a){this.offsetX=a;return this},setOffsetY:function(a){this.offsetY=a;return this},setOffset:function(a,b){this.offsetX=a;this.offsetY=b;return this},initialize:function(a,b,c){this.image=a;this.rows=b;this.columns=c;this.width=a.width;this.height=a.height;this.singleWidth=Math.floor(this.width/c);this.singleHeight=Math.floor(this.height/b);this.mapInfo={};var d,e,f,g;if(a.__texturePage){a.__du=this.singleWidth/a.__texturePage.width;
a.__dv=this.singleHeight/a.__texturePage.height;e=this.singleWidth;f=this.singleHeight;var h=this.columns;if(a.inverted)d=e,e=f,f=d,h=this.rows;var a=this.image.__tx,i=this.image.__ty,j=this.image.__texturePage;for(d=0;d<b*c;d++){g=a+(d%h>>0)*e;var k=i+(d/h>>0)*f,m=g+e,n=k+f;g=(new CAAT.SpriteImageHelper(g,k,m-g,n-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,n/j.height);this.mapInfo[d]=g}}else for(d=0;d<b*c;d++)e=(d%this.columns|0)*this.singleWidth,f=(d/this.columns|0)*this.singleHeight,
g=new CAAT.SpriteImageHelper(e,f,this.singleWidth,this.singleHeight,a.width,a.height),this.mapInfo[d]=g;return this},paintTiled:function(a,b,c,d){this.setSpriteIndexAtTime(b);var b=this.mapInfo[this.spriteIndex],e=this.getWidth(),f=this.getHeight(),g=this.offsetX%e;g>0&&(g-=e);var h=this.offsetY%f;h>0&&(h-=f);var e=((this.ownerActor.width-g)/e>>0)+1,f=((this.ownerActor.height-h)/f>>0)+1,i,j;for(i=0;i<f;i++)for(j=0;j<e;j++)a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,c+g+j*b.width>>0,d+h+i*
b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,
b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,
b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return"-"+(a.x-this.offsetX)+"px -"+(a.y-this.offsetY)+"px "+(this.transformation===this.TR_TILE?
"":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=
g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;switch(a){case this.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case this.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case this.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case this.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case this.TR_TILE:this.paint=this.paintTiled;break;
default:this.paint=this.paintN}return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1)this.prevAnimationTime===-1?(this.prevAnimationTime=a,this.spriteIndex=0):(a-=this.prevAnimationTime,a/=this.changeFPS,a%=this.animationImageIndex.length,this.spriteIndex=this.animationImageIndex[Math.floor(a)])},initializeFromMap:function(a,
b){this.initialize(a,1,1);var c,d,e=0;for(c in b)d=b[c],d=new CAAT.SpriteImageHelper(d.x,d.y,d.width,d.height,a.width,a.height),this.mapInfo[c]=d,e||this.setAnimationImageIndex([c]),e++;return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.SpriteImageHelper(f.x,f.y,f.width,f.height,a.width,a.height);d.xoffset=typeof f.xoffset==="undefined"?0:f.xoffset;d.yoffset=typeof f.yoffset==="undefined"?0:f.yoffset;d.xadvance=typeof f.xadvance==="undefined"?
f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},stringWidth:function(a){var b,c,d=0,e;for(b=0,c=a.length;b<c;b++)(e=this.mapInfo[a.charAt(b)])&&(d+=e.xadvance);return d},drawString:function(a,b,c,d){var e,f,g,h;for(e=0,f=b.length;e<f;e++)if(g=this.mapInfo[b.charAt(e)])h=g.width,a.drawImage(this.image,g.x,g.y,h,g.height,c+g.xoffset,d+g.yoffset,h,g.height),c+=g.xadvance}}})();(function(){CAAT.ImagePreloader=function(){this.images=[];return this};CAAT.ImagePreloader.prototype={images:null,notificationCallback:null,imageCounter:0,loadImages:function(a,b){a||b&&b(0,[]);var c=this,d;this.notificationCallback=b;this.images=[];for(d=0;d<a.length;d++)this.images.push({id:a[d].id,image:new Image});for(d=0;d<a.length;d++)this.images[d].image.onload=function(){c.imageCounter++;c.notificationCallback(c.imageCounter,c.images)},this.images[d].image.src=a[d].url;a.length===0&&b(0,[])}}})();(function(){CAAT.TimerTask=function(){return this};CAAT.TimerTask.prototype={startTime:0,duration:0,callback_timeout:null,callback_tick:null,callback_cancel:null,scene:null,taskId:0,remove:false,create:function(a,b,c,d,e){this.startTime=a;this.duration=b;this.callback_timeout=c;this.callback_tick=d;this.callback_cancel=e;return this},checkTask:function(a){var b=a;b-=this.startTime;b>=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)):this.callback_tick&&this.callback_tick(a,
b,this);return this},reset:function(a){this.remove=false;this.startTime=a;this.scene.ensureTimerTask(this);return this},cancel:function(){this.remove=true;null!=this.callback_cancel&&this.callback_cancel(this.scene.time,this.scene.time-this.startTime,this);return this}}})();(function(){CAAT.Scene=function(){CAAT.Scene.superclass.constructor.call(this);this.timerList=[];this.style("overflow","hidden");return this};CAAT.Scene.prototype={easeContainerBehaviour:null,easeContainerBehaviourListener:null,easeIn:false,EASE_ROTATION:1,EASE_SCALE:2,EASE_TRANSLATE:3,timerList:null,timerSequence:0,paused:false,isPaused:function(){return this.paused},setPaused:function(a){this.paused=a},checkTimers:function(a){for(var b=this.timerList.length-1;b>=0;)this.timerList[b].remove||this.timerList[b].checkTask(a),
b--},ensureTimerTask:function(a){this.hasTimer(a)||this.timerList.push(a);return this},hasTimer:function(a){for(var b=this.timerList.length-1;b>=0;){if(this.timerList[b]===a)return true;b--}return false},createTimer:function(a,b,c,d,e){a=(new CAAT.TimerTask).create(a,b,c,d,e);a.taskId=this.timerSequence++;a.sceneTime=this.time;a.scene=this;this.timerList.push(a);return a},removeExpiredTimers:function(){var a;for(a=0;a<this.timerList.length;a++)this.timerList[a].remove&&this.timerList.splice(a,1)},
animate:function(a,b){this.checkTimers(b);CAAT.Scene.superclass.animate.call(this,a,b);this.removeExpiredTimers()},createAlphaBehaviour:function(a,b){var c=new CAAT.AlphaBehavior;c.setFrameTime(0,a);c.startAlpha=b?0:1;c.endAlpha=b?1:0;this.easeContainerBehaviour.addBehavior(c)},easeTranslationIn:function(a,b,c,d){this.easeTranslation(a,b,c,true,d)},easeTranslationOut:function(a,b,c,d){this.easeTranslation(a,b,c,false,d)},easeTranslation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.ContainerBehavior;
this.easeIn=d;var f=new CAAT.PathBehavior;e&&f.setInterpolator(e);f.setFrameTime(0,a);c<1?c=1:c>4&&(c=4);switch(c){case CAAT.Actor.prototype.ANCHOR_TOP:d?f.setPath((new CAAT.Path).setLinear(0,-this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,-this.height));break;case CAAT.Actor.prototype.ANCHOR_BOTTOM:d?f.setPath((new CAAT.Path).setLinear(0,this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,this.height));break;case CAAT.Actor.prototype.ANCHOR_LEFT:d?f.setPath((new CAAT.Path).setLinear(-this.width,
0,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,-this.width,0));break;case CAAT.Actor.prototype.ANCHOR_RIGHT:d?f.setPath((new CAAT.Path).setLinear(this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,this.width,0))}b&&this.createAlphaBehaviour(a,d);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);a=f.path.startCurvePosition();this.setLocation(a.x,a.y);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,
this.easeContainerBehaviour)},easeScaleIn:function(a,b,c,d,e){this.easeScale(a,b,c,d,true,e);this.easeIn=true},easeScaleOut:function(a,b,c,d,e){this.easeScale(a,b,c,d,false,e);this.easeIn=false},easeScale:function(a,b,c,d,e,f){this.easeContainerBehaviour=new CAAT.ContainerBehavior;var g=0,h=0,i=0,j=0;switch(d){case CAAT.Actor.prototype.ANCHOR_TOP_LEFT:case CAAT.Actor.prototype.ANCHOR_TOP_RIGHT:case CAAT.Actor.prototype.ANCHOR_BOTTOM_LEFT:case CAAT.Actor.prototype.ANCHOR_BOTTOM_RIGHT:case CAAT.Actor.prototype.ANCHOR_CENTER:j=
i=1;break;case CAAT.Actor.prototype.ANCHOR_TOP:case CAAT.Actor.prototype.ANCHOR_BOTTOM:i=g=1;h=0;j=1;break;case CAAT.Actor.prototype.ANCHOR_LEFT:case CAAT.Actor.prototype.ANCHOR_RIGHT:j=h=1;g=0;i=1;break;default:alert("scale anchor ?? "+d)}if(!e){var k;k=g;g=i;i=k;k=h;h=j;j=k}c&&this.createAlphaBehaviour(b,e);c=this.getAnchorPercent(d);a=(new CAAT.ScaleBehavior).setFrameTime(a,b).setValues(g,i,h,j,c.x,c.y);f&&a.setInterpolator(f);this.easeContainerBehaviour.addBehavior(a);this.easeContainerBehaviour.setFrameTime(this.time,
b);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},addBehavior:function(){return this},easeRotationIn:function(a,b,c,d){this.easeRotation(a,b,c,true,d);this.easeIn=true},easeRotationOut:function(a,b,c,d){this.easeRotation(a,b,c,false,d);this.easeIn=false},easeRotation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.ContainerBehavior;var f=0,g=0;if(c==CAAT.Actor.prototype.ANCHOR_CENTER)c=CAAT.Actor.prototype.ANCHOR_TOP;
switch(c){case CAAT.Actor.prototype.ANCHOR_TOP:case CAAT.Actor.prototype.ANCHOR_BOTTOM:case CAAT.Actor.prototype.ANCHOR_LEFT:case CAAT.Actor.prototype.ANCHOR_RIGHT:f=Math.PI*(Math.random()<0.5?1:-1);break;case CAAT.Actor.prototype.ANCHOR_TOP_LEFT:case CAAT.Actor.prototype.ANCHOR_TOP_RIGHT:case CAAT.Actor.prototype.ANCHOR_BOTTOM_LEFT:case CAAT.Actor.prototype.ANCHOR_BOTTOM_RIGHT:f=Math.PI/2*(Math.random()<0.5?1:-1);break;default:alert("rot anchor ?? "+c)}if(false===d)var h=f,f=g,g=h;b&&this.createAlphaBehaviour(a,
d);b=this.getAnchorPercent(c);f=(new CAAT.RotateBehavior).setFrameTime(0,a).setValues(f,g,b.x,b.y);e&&f.setInterpolator(e);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},setEaseListener:function(a){this.easeContainerBehaviourListener=a},behaviorExpired:function(){this.easeContainerBehaviourListener.easeEnd(this,
this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a;this.style("display",a?"none":"block")},paint:function(){}};extend(CAAT.Scene,CAAT.ActorContainer,null)})();CAAT.modules=CAAT.modules||{};CAAT.modules.CircleManager=CAAT.modules.CircleManager||{};(function(){CAAT.modules.LayoutUtils={};CAAT.modules.LayoutUtils.row=function(a,b,c){for(var d=a.width,e=0,f=0,g=0,h=0,h=Number.MIN_VALUE,i=Number.MAX_VALUE,g=b.length-1;g;g-=1){if(i<b[g].width)i=b[g].width;if(h<b[g].height)h=b[g].height}if(c.padding_left)e=c.padding_left,d-=e;c.padding_right&&(d-=c.padding_right);if(c.top&&(f=parseInt(c.top,10),isNaN(f)))switch(c.top){case "center":f=(a.height-h)/2;break;case "top":f=0;break;case "bottom":f=a.height-h;break;default:f=0}a=d/b.length;for(g=0,h=b.length;g<
h;g++)b[g].setLocation(e+g*a+(a-b[g].width)/2,f)}})();(function(){CAAT.modules.CircleManager.PackedCircle=function(){this.boundsRule=CAAT.modules.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE;this.position=new CAAT.Point(0,0,0);this.offset=new CAAT.Point(0,0,0);this.targetPosition=new CAAT.Point(0,0,0);return this};CAAT.modules.CircleManager.PackedCircle.prototype={id:0,delegate:null,position:new CAAT.Point(0,0,0),offset:new CAAT.Point(0,0,0),targetPosition:null,targetChaseSpeed:0.02,isFixed:false,boundsRule:0,collisionMask:0,collisionGroup:0,BOUNDS_RULE_WRAP:1,
BOUNDS_RULE_CONSTRAINT:2,BOUNDS_RULE_DESTROY:4,BOUNDS_RULE_IGNORE:8,containsPoint:function(a){return this.position.getDistanceSquared(a)<this.radiusSquared},getDistanceSquaredFromPosition:function(a){return this.position.getDistanceSquared(a)<this.radiusSquared},intersects:function(a){var b=this.position.getDistanceSquared(a.position);return b<this.radiusSquared||b<a.radiusSquared},setPosition:function(a){this.position=a;return this},setDelegate:function(a){this.delegate=a;return this},setOffset:function(a){this.offset=
a;return this},setTargetPosition:function(a){this.targetPosition=a;return this},setTargetChaseSpeed:function(a){this.targetChaseSpeed=a;return this},setIsFixed:function(a){this.isFixed=a;return this},setCollisionMask:function(a){this.collisionMask=a;return this},setCollisionGroup:function(a){this.collisionGroup=a;return this},setRadius:function(a){this.radius=a;this.radiusSquared=this.radius*this.radius;return this},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this},dealloc:function(){this.targetPosition=
this.delegate=this.offset=this.position=null}}})();(function(){CAAT.modules.CircleManager.PackedCircleManager=function(){return this};CAAT.modules.CircleManager.PackedCircleManager.prototype={allCircles:[],numberOfCollisionPasses:1,numberOfTargetingPasses:0,bounds:new CAAT.Rectangle,addCircle:function(a){a.id=this.allCircles.length;this.allCircles.push(a);return this},removeCircle:function(a){var b=0,c=false,d=this.allCircles.length;if(d===0)throw"Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!";for(;d--;)if(this.allCircles[d]===
a){c=true;b=d;break}if(!c)throw"Could not locate circle in allCircles array!";this.allCircles[b].dealloc();this.allCircles[b]=null;return this},forceCirclesToMatchDelegatePositions:function(){for(var a=this.allCircles.length,b=0;b<a;b++){var c=this.allCircles[b];c&&c.delegate&&c.position.set(c.delegate.x+c.offset.x,c.delegate.y+c.offset.y)}},pushAllCirclesTowardTarget:function(){for(var a=new CAAT.Point(0,0,0),b=this.allCircles,c=b.length,d=0;d<this.numberOfTargetingPasses;d++)for(var e=0;e<c;e++){var f=
b[e];if(!f.isFixed)a.x=f.position.x-(f.targetPosition.x+f.offset.x),a.y=f.position.y-(f.targetPosition.y+f.offset.y),a.multiply(f.targetChaseSpeed),f.position.x-=a.x,f.position.y-=a.y}},handleCollisions:function(){this.removeExpiredElements();for(var a=new CAAT.Point(0,0,0),b=this.allCircles,c=b.length,d=0;d<this.numberOfCollisionPasses;d++)for(var e=0;e<c;e++)for(var f=b[e],g=e+1;g<c;g++){var h=b[g];if(this.circlesCanCollide(f,h)){var i=h.position.x-f.position.x,j=h.position.y-f.position.y,k=(f.radius+
h.radius)*1.08,m=f.position.getDistanceSquared(h.position);if(m<k*k-0.02)a.x=i,a.y=j,a.normalize(),i=(k-Math.sqrt(m))*0.5,a.multiply(i),h.isFixed||(f.isFixed&&a.multiply(2.2),h.position.translatePoint(a)),f.isFixed||(h.isFixed&&a.multiply(2.2),f.position.subtract(a))}}},handleBoundaryForCircle:function(a,b){var c=a.position.x,d=a.position.y,e=a.radius,f=e*2,b=12;if(b&1&&c-f>this.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+f<this.bounds.left)a.position.x=this.bounds.right-e;if(b&4&&
d-f>this.bounds.bottom)a.position.y=this.bounds.top-e;else if(b&4&&d+f<this.bounds.top)a.position.y=this.bounds.bottom+e;if(b&8&&c+e>=this.bounds.right)a.position.x=a.position.x=this.bounds.right-e;else if(b&8&&c-e<this.bounds.left)a.position.x=this.bounds.left+e;if(b&16&&d+e>this.bounds.bottom)a.position.y=this.bounds.bottom-e;else if(b&16&&d-e<this.bounds.top)a.position.y=this.bounds.top+e},getCircleAt:function(a,b,c){for(var d=this.allCircles,e=d.length,a=new CAAT.Point(a,b,0),b=null,f=Number.MAX_VALUE,
g=0;g<e;g++){var h=d[g];if(h){var i=h.position.getDistanceSquared(a);i<f&&i<h.radiusSquared+c&&(f=i,b=h)}}return b},circlesCanCollide:function(a,b){return!a||!b||a===b?false:true},setBounds:function(a,b,c,d){this.bounds.x=a;this.bounds.y=b;this.bounds.width=c;this.bounds.height=d},setNumberOfCollisionPasses:function(a){this.numberOfCollisionPasses=a;return this},setNumberOfTargetingPasses:function(a){this.numberOfTargetingPasses=a;return this},sortOnDistanceToTarget:function(a,b){var c=a.getDistanceSquaredFromPosition(a.targetPosition),
d=b.getDistanceSquaredFromPosition(a.targetPosition),e=0;c>d?e=-1:c<d&&(e=1);return e},removeExpiredElements:function(){for(var a=this.allCircles.length;a>=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}})();(function(){CAAT.modules.LocalStorage=function(){return this};CAAT.modules.LocalStorage.prototype={save:function(a,b){try{localStorage.setItem(a,JSON.stringify(b))}catch(c){}return this},load:function(a){try{return JSON.parse(localStorage.getItem(a))}catch(b){return null}},remove:function(a){try{localStorage.removeItem(a)}catch(b){}return this}}})();(function(){CAAT.modules.ImageUtil={};CAAT.modules.ImageUtil.createAlphaSpriteSheet=function(a,b,c,d,e){if(a<b)var f=a,a=b,b=f;f=document.createElement("canvas");f.width=d.width;f.height=d.height*c;var g=f.getContext("2d");g.fillStyle=e?e:"rgba(255,255,255,0)";g.fillRect(0,0,d.width,d.height*c);for(e=0;e<c;e++)g.globalAlpha=1-(a-b)/c*(e+1),g.drawImage(d,0,e*d.height);return f};CAAT.modules.ImageUtil.rotate=function(a,b){b=b||0;if(!b)return a;var c=document.createElement("canvas");c.width=a.height;
c.height=a.width;var d=c.getContext("2d");d.globalAlpha=1;d.fillStyle="rgba(0,0,0,0)";d.clearRect(0,0,c.width,c.height);var e=new CAAT.Matrix;e.multiply((new CAAT.Matrix).setTranslate(c.width/2,c.width/2));e.multiply((new CAAT.Matrix).setRotation(b*Math.PI/180));e.multiply((new CAAT.Matrix).setTranslate(-c.width/2,-c.width/2));e.transformRenderingContext(d);d.drawImage(a,0,0);return c};CAAT.modules.ImageUtil.optimize=function(a,b,c){b>>=0;var d=true,e=true,f=true,g=true;if(typeof c!=="undefined"){if(typeof c.top!==
"undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,n=c.width-1,l=false;if(d){for(d=0;d<c.height;d++){for(j=0;j<c.width;j++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}a=
d}if(e){l=false;for(d=c.height-1;d>=a;d--){for(j=0;j<c.width;j++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}k=d}if(f){l=false;for(j=0;j<c.width;j++){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}m=j}if(g){l=false;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}n=j}if(0===m&&0===a&&c.width-1===n&&c.height-1===k)return c;b=n-m+1;e=k-a+1;f=h.getImageData(m,a,b,e);c.width=b;c.height=e;h=c.getContext("2d");h.putImageData(f,0,0);
return c};CAAT.modules.ImageUtil.createThumb=function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}})();(function(){CAAT.Font=function(){return this};CAAT.Font.prototype={fontSize:10,fontSizeUnit:"px",font:"Sans-Serif",fontStyle:"",fillStyle:"#fff",strokeStyle:null,padding:0,image:null,charMap:null,height:0,setPadding:function(a){this.padding=a;return this},setFontStyle:function(a){this.fontStyle=a;return this},setFontSize:function(a){this.fontSize=a;this.fontSizeUnit="px";return this},setFont:function(a){this.font=a;return this},setFillStyle:function(a){this.fillStyle=a;return this},setStrokeStyle:function(a){this.strokeStyle=
a;return this},createDefault:function(a){for(var b="",c=32;c<128;c++)b+=String.fromCharCode(c);return this.create(b,a)},create:function(a,b){this.padding=b;var c=document.createElement("canvas");c.width=1;c.height=1;var d=c.getContext("2d");d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;var e=0,f=[],g,h;for(g=0;g<a.length;g++)h=Math.max(1,(d.measureText(a.charAt(g)).width>>0)+1)+2*b,f.push(h),e+=h;c.width=e;c.height=this.fontSize*1.5>>0;d=c.getContext("2d");
d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g<a.length;g++)h=a.charAt(g),d.fillText(h,e+b,0),this.strokeStyle&&(d.beginPath(),d.strokeText(h,e+b,0)),this.charMap[h]={x:e,width:f[g]},e+=f[g];this.image=CAAT.modules.ImageUtil.optimize(c,32,{top:true,bottom:true,left:false,right:false});this.height=this.image.height;return this},stringWidth:function(a){var b,c,d=0,e;
for(b=0,c=a.length;b<c;b++)e=this.charMap[a.charAt(b)],d+=e?e.width:10;return d},drawText:function(a,b,c,d){var e,f,g,h,i=this.image.height;for(e=0,f=a.length;e<f;e++)(g=this.charMap[a.charAt(e)])?(h=g.width,b.drawImage(this.image,g.x,0,h,i,c,d,h,i),c+=h):(b.strokeStyle="#f00",b.strokeRect(c,d,10,i),c+=10)},save:function(){var a=this.image.toDataURL("image/png");document.location.href=a.replace("image/png","image/octet-stream")}}})();(function(){CAAT.InterpolatorActor=function(){CAAT.InterpolatorActor.superclass.constructor.call(this);return this};CAAT.InterpolatorActor.prototype={interpolator:null,contour:null,S:50,gap:5,setGap:function(a){this.gap=a;return this},setInterpolator:function(a,b){this.interpolator=a;this.contour=a.getContour(b||this.S);return this},paint:function(a,b){CAAT.InterpolatorActor.superclass.paint.call(this,a,b);if(this.backgroundImage)return this;if(this.interpolator){var c=a.crc,d=this.width-2*this.gap,
e=this.height-2*this.gap;c.beginPath();c.moveTo(this.gap+d*this.contour[0].x,-this.gap+this.height-e*this.contour[0].y);for(var f=1;f<this.contour.length;f++)c.lineTo(this.gap+d*this.contour[f].x,-this.gap+this.height-e*this.contour[f].y);c.strokeStyle=this.strokeStyle;c.stroke()}},getInterpolator:function(){return this.interpolator}};extend(CAAT.InterpolatorActor,CAAT.ActorContainer,null)})();(function(){CAAT.PathSegment=function(){this.bbox=new CAAT.Rectangle;return this};CAAT.PathSegment.prototype={color:"black",length:0,bbox:null,parent:null,setParent:function(a){this.parent=a;return this},setColor:function(a){if(a)this.color=a;return this},endCurvePosition:function(){},startCurvePosition:function(){},setPoints:function(){},setPoint:function(){},getPosition:function(){},getLength:function(){return this.length},getBoundingBox:function(){return this.bbox},numControlPoints:function(){},
getControlPoint:function(){},endPath:function(){},getContour:function(){},updatePath:function(){},applyAsPath:function(){},transform:function(){}}})();
(function(){CAAT.LinearPath=function(){CAAT.LinearPath.superclass.constructor.call(this);this.points=[];this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.newPosition=new CAAT.Point(0,0,0);return this};CAAT.LinearPath.prototype={points:null,newPosition:null,applyAsPath:function(a){a.ctx.lineTo(this.points[0].x,this.points[1].y)},setPoint:function(a,b){b===0?this.points[0]=a:b===1&&(this.points[1]=a)},updatePath:function(){var a=this.points[1].x-this.points[0].x,b=this.points[1].y-
this.points[0].y;this.length=Math.sqrt(a*a+b*b);this.bbox.setEmpty();this.bbox.union(this.points[0].x,this.points[0].y);this.bbox.union(this.points[1].x,this.points[1].y);return this},setPoints:function(a){this.points[0]=a[0];this.points[1]=a[1];this.updatePath();return this},setInitialPosition:function(a,b){this.points[0].x=a;this.points[0].y=b;this.newPosition.set(a,b);return this},setFinalPosition:function(a,b){this.points[1].x=a;this.points[1].y=b;return this},endCurvePosition:function(){return this.points[1]},
startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.crc;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,
this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),c.arc(this.points[0].x,this.points[0].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.arc(this.points[1].x,this.points[1].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.fill();c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0];else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());
return a}};extend(CAAT.LinearPath,CAAT.PathSegment)})();
(function(){CAAT.CurvePath=function(){CAAT.CurvePath.superclass.constructor.call(this);this.newPosition=new CAAT.Point(0,0,0);return this};CAAT.CurvePath.prototype={curve:null,newPosition:null,applyAsPath:function(a){this.curve.applyAsPath(a);return this},setPoint:function(a,b){this.curve&&this.curve.setPoint(a,b)},setPoints:function(a){var b=new CAAT.Bezier;b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.Bezier;g.setQuadric(a,b,c,d,e,f);this.curve=g;this.updatePath();
return this},setCubic:function(a,b,c,d,e,f,g,h){var i=new CAAT.Bezier;i.setCubic(a,b,c,d,e,f,g,h);this.curve=i;this.updatePath();return this},updatePath:function(){this.curve.update();this.length=this.curve.getLength();this.curve.getBoundingBox(this.bbox);return this},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition,a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x},
finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]},endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/
a,y:this.getPosition(c/a).y});return b}};extend(CAAT.CurvePath,CAAT.PathSegment,null)})();
(function(){CAAT.ShapePath=function(){CAAT.ShapePath.superclass.constructor.call(this);this.points=[];this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.newPosition=new CAAT.Point;return this};CAAT.ShapePath.prototype={points:null,length:-1,cw:true,bbox:null,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x,
this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x,this.points[0].y));return this},setPoint:function(a,b){b>=0&&b<this.points.length&&(this.points[b]=a)},setPoints:function(a){this.points=[];this.points.push(a[0]);
this.points.push((new CAAT.Point).set(a[1].x,a[0].y));this.points.push(a[1]);this.points.push((new CAAT.Point).set(a[0].x,a[1].y));this.points.push(a[0].clone());this.updatePath();return this},setClockWise:function(a){this.cw=a!==void 0?a:true;return this},isClockWise:function(){return this.cw},setInitialPosition:function(a,b){for(var c=0,d=this.points.length;c<d;c++)this.points[c].x=a,this.points[c].y=b;return this},setFinalPosition:function(a,b){this.points[2].x=a;this.points[2].y=b;this.points[1].x=
a;this.points[1].y=this.points[0].y;this.points[3].x=this.points[0].x;this.points[3].y=b;this.points[4].x=this.points[0].x;this.points[4].y=this.points[0].y;this.updatePath();return this},endCurvePosition:function(){return this.points[4]},startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c,
b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;f<b.length;)if(d+b[f]<a)d+=b[f],f++;else break;a-=d;d=e[f];e=e[f+1];this.newPosition.set(this.points[d].x+(this.points[e].x-this.points[d].x)*a/b[f],this.points[d].y+(this.points[e].y-this.points[d].y)*a/b[f])}return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[2].x},paint:function(a,b){var c=a.crc;c.save();c.strokeStyle=this.color;c.beginPath();c.strokeRect(this.bbox.x,this.bbox.y,this.bbox.width,
this.bbox.height);if(b){c.globalAlpha=0.5;c.fillStyle="#7f7f00";for(var d=0;d<this.points.length;d++)c.beginPath(),c.arc(this.points[d].x,this.points[d].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.fill()}c.restore()},numControlPoints:function(){return this.points.length},getControlPoint:function(a){return this.points[a]},getContour:function(){for(var a=[],b=0;b<this.points.length;b++)a.push(this.points[b]);return a},updatePath:function(a){if(a){if(a===this.points[0])this.points[1].y=
a.y,this.points[3].x=a.x;else if(a===this.points[1])this.points[0].y=a.y,this.points[2].x=a.x;else if(a===this.points[2])this.points[3].y=a.y,this.points[1].x=a.x;else if(a===this.points[3])this.points[0].x=a.x,this.points[2].y=a.y;this.points[4].x=this.points[0].x;this.points[4].y=this.points[0].y}this.bbox.setEmpty();for(a=0;a<4;a++)this.bbox.union(this.points[a].x,this.points[a].y);this.length=2*this.bbox.width+2*this.bbox.height;this.points[0].x=this.bbox.x;this.points[0].y=this.bbox.y;this.points[1].x=
this.bbox.x+this.bbox.width;this.points[1].y=this.bbox.y;this.points[2].x=this.bbox.x+this.bbox.width;this.points[2].y=this.bbox.y+this.bbox.height;this.points[3].x=this.bbox.x;this.points[3].y=this.bbox.y+this.bbox.height;this.points[4].x=this.bbox.x;this.points[4].y=this.bbox.y;return this}};extend(CAAT.ShapePath,CAAT.PathSegment)})();
(function(){CAAT.Path=function(){CAAT.Path.superclass.constructor.call(this);this.newPosition=new CAAT.Point(0,0,0);this.pathSegments=[];this.behaviorList=[];this.matrix=new CAAT.Matrix;this.tmpMatrix=new CAAT.Matrix;return this};CAAT.Path.prototype={pathSegments:null,pathSegmentDurationTime:null,pathSegmentStartTime:null,newPosition:null,pathLength:-1,beginPathX:-1,beginPathY:-1,trackPathX:-1,trackPathY:-1,ax:-1,ay:-1,point:[],interactive:true,behaviorList:null,rb_angle:0,rb_rotateAnchorX:0.5,rb_rotateAnchorY:0.5,
sb_scaleX:1,sb_scaleY:1,sb_scaleAnchorX:0.5,sb_scaleAnchorY:0.5,tb_x:0,tb_y:0,matrix:null,tmpMatrix:null,pathPoints:null,width:0,height:0,clipOffsetX:0,clipOffsetY:0,applyAsPath:function(a){var b=a.ctx;a.modelViewMatrix.transformRenderingContext(b);b.beginPath();b.globalCompositeOperation="source-out";b.moveTo(this.getFirstPathSegment().startCurvePosition().x,this.getFirstPathSegment().startCurvePosition().y);for(var c=0;c<this.pathSegments.length;c++)this.pathSegments[c].applyAsPath(a);b.globalCompositeOperation=
"source-over";return this},setInteractive:function(a){this.interactive=a;return this},getFirstPathSegment:function(){return this.pathSegments.length?this.pathSegments[0]:null},getLastPathSegment:function(){return this.pathSegments.length?this.pathSegments[this.pathSegments.length-1]:null},endCurvePosition:function(){return this.pathSegments.length?this.pathSegments[this.pathSegments.length-1].endCurvePosition():(new CAAT.Point).set(this.beginPathX,this.beginPathY)},startCurvePosition:function(){return this.pathSegments[0].startCurvePosition()},
getCurrentPathSegment:function(){return this.pathSegments[this.pathSegments.length-1]},setLinear:function(a,b,c,d){this.beginPath(a,b);this.addLineTo(c,d);this.endPath();return this},setQuadric:function(a,b,c,d,e,f){this.beginPath(a,b);this.addQuadricTo(c,d,e,f);this.endPath();return this},setCubic:function(a,b,c,d,e,f,g,h){this.beginPath(a,b);this.addCubicTo(c,d,e,f,g,h);this.endPath();return this},setRectangle:function(a,b,c,d){this.beginPath(a,b);this.addRectangleTo(c,d);this.endPath();return this},
addSegment:function(a){a.setParent(this);this.pathSegments.push(a);return this},addRectangleTo:function(a,b,c,d){var e=new CAAT.ShapePath;e.setPoints([this.endCurvePosition(),(new CAAT.Point).set(a,b)]);e.setClockWise(c);e.setColor(d);e.setParent(this);this.pathSegments.push(e);return this},addQuadricTo:function(a,b,c,d,e){var f=new CAAT.Bezier;f.setPoints([this.endCurvePosition(),(new CAAT.Point).set(a,b),(new CAAT.Point).set(c,d)]);this.trackPathX=c;this.trackPathY=d;a=(new CAAT.CurvePath).setColor(e).setParent(this);
a.curve=f;this.pathSegments.push(a);return this},addCubicTo:function(a,b,c,d,e,f,g){var h=new CAAT.Bezier;h.setPoints([this.endCurvePosition(),(new CAAT.Point).set(a,b),(new CAAT.Point).set(c,d),(new CAAT.Point).set(e,f)]);this.trackPathX=e;this.trackPathY=f;a=(new CAAT.CurvePath).setColor(g).setParent(this);a.curve=h;this.pathSegments.push(a);return this},addCatmullTo:function(a,b,c,d,e,f,g){g=(new CAAT.CatmullRom).setColor(g);g.setCurve(this.trackPathX,this.trackPathY,a,b,c,d,e,f);this.trackPathX=
e;this.trackPathY=f;a=(new CAAT.CurvePath).setParent(this);a.curve=g;this.pathSegments.push(a);return this},addLineTo:function(a,b,c){c=(new CAAT.LinearPath).setColor(c);c.setPoints([this.endCurvePosition(),(new CAAT.Point).set(a,b)]);c.setParent(this);this.trackPathX=a;this.trackPathY=b;this.pathSegments.push(c);return this},beginPath:function(a,b){this.trackPathX=a;this.trackPathY=b;this.beginPathX=a;this.beginPathY=b;return this},closePath:function(){this.getLastPathSegment().setPoint(this.getFirstPathSegment().startCurvePosition(),
this.getLastPathSegment().numControlPoints()-1);this.trackPathX=this.beginPathX;this.trackPathY=this.beginPathY;this.endPath();return this},endPath:function(){this.pathSegmentStartTime=[];this.pathSegmentDurationTime=[];this.updatePath();return this},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);for(var b=0;b<this.pathSegments.length;b++)if(this.pathSegmentStartTime[b]<=a&&a<=this.pathSegmentStartTime[b]+this.pathSegmentDurationTime[b]){a=this.pathSegmentDurationTime[b]?(a-this.pathSegmentStartTime[b])/
this.pathSegmentDurationTime[b]:0;a=this.pathSegments[b].getPosition(a);this.newPosition.x=a.x;this.newPosition.y=a.y;break}return this.newPosition},getPositionFromLength:function(a){a%=this.getLength();a<0&&(a+=this.getLength());for(var b=0,c=0;c<this.pathSegments.length;c++){if(b<=a&&a<=this.pathSegments[c].getLength()+b){a-=b;a=this.pathSegments[c].getPositionFromLength(a);this.newPosition.x=a.x;this.newPosition.y=a.y;break}b+=this.pathSegments[c].getLength()}return this.newPosition},paint:function(a){for(var b=
0;b<this.pathSegments.length;b++)this.pathSegments[b].paint(a,this.interactive)},release:function(){this.ay=this.ax=-1},getNumSegments:function(){return this.pathSegments.length},getSegment:function(a){return this.pathSegments[a]},numControlPoints:function(){return this.points.length},getControlPoint:function(a){return this.points[a]},updatePath:function(a){var b,c;this.length=0;this.bbox.setEmpty();this.points=[];var d=Number.MAX_VALUE,e=Number.MAX_VALUE;for(b=0;b<this.pathSegments.length;b++){this.pathSegments[b].updatePath(a);
this.length+=this.pathSegments[b].getLength();this.bbox.unionRectangle(this.pathSegments[b].bbox);for(c=0;c<this.pathSegments[b].numControlPoints();c++){var f=this.pathSegments[b].getControlPoint(c);this.points.push(f);if(f.x<d)d=f.x;if(f.y<e)e=f.y}}this.clipOffsetX=-d;this.clipOffsetY=-e;this.width=this.bbox.width;this.height=this.bbox.height;this.setLocation(this.bbox.x,this.bbox.y);this.bbox.x=0;this.bbox.y=0;this.bbox.x1=this.width;this.bbox.y1=this.height;this.pathSegmentStartTime=[];this.pathSegmentDurationTime=
[];for(b=0;b<this.pathSegments.length;b++)this.pathSegmentStartTime.push(0),this.pathSegmentDurationTime.push(0);for(b=0;b<this.pathSegments.length;b++)this.pathSegmentDurationTime[b]=this.getLength()?this.pathSegments[b].getLength()/this.getLength():0,b>0?this.pathSegmentStartTime[b]=this.pathSegmentStartTime[b-1]+this.pathSegmentDurationTime[b-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[b].endPath();this.extractPathPoints();return this},press:function(a,b){if(this.interactive){for(var c=
CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d<this.pathSegments.length;d++)for(var e=0;e<this.pathSegments[d].numControlPoints();e++){var f=this.pathSegments[d].getControlPoint(e);if(a>=f.x-c&&b>=f.y-c&&a<f.x+c&&b<f.y+c){this.point=f;return}}this.point=null}},drag:function(a,b){if(this.interactive&&null!==this.point){if(-1===this.ax||-1===this.ay)this.ax=a,this.ay=b;this.point.x+=a-this.ax;this.point.y+=b-this.ay;this.ax=a;this.ay=b;this.updatePath(this.point)}},getContour:function(a){for(var b=[],c=0;c<=
a;c++)b.push((new CAAT.Point).set(c/a,this.getPosition(c/a).y,0));return b},setPoints:function(a){if(this.points.length===a.length)for(var b=0;b<a.length;b++)this.points[b].x=a[b].x,this.points[b].y=a[b].y;return this},setPoint:function(a,b){if(b>=0&&b<this.points.length)this.points[b].x=a.x,this.points[b].y=a.y;return this},emptyBehaviorList:function(){this.behaviorList=[];return this},extractPathPoints:function(){if(!this.pathPoints){var a;this.pathPoints=[];for(a=0;a<this.numControlPoints();a++)this.pathPoints.push(this.getControlPoint(a).clone())}return this},
addBehavior:function(a){this.behaviorList.push(a);return this},removeBehaviour:function(a){for(var b=this.behaviorList.length-1;b;)if(this.behaviorList[b]===a){this.behaviorList.splice(b,1);break}return this},removeBehaviorById:function(a){for(var b=0;b<this.behaviorList.length;b++)this.behaviorList[b].id===a&&this.behaviorList.splice(b,1);return this},applyBehaviors:function(a){for(var b=0;b<this.behaviorList.length;b++)this.behaviorList[b].apply(a,this);this.setATMatrix();for(b=0;b<this.numControlPoints();b++)this.setPoint(this.matrix.transformCoord(this.pathPoints[b].clone().translate(this.clipOffsetX,
this.clipOffsetY)),b);return this},setATMatrix:function(){this.matrix.identity();this.tmpMatrix.identity();var a=this.matrix.matrix,b,c,d,e,f,g,h,i,j,k;h=this.bbox;var m=h.width,n=h.height,l=h.x,o=h.y;h=1;j=e=0;g=1;i=this.tb_x-l;k=this.tb_y-o;if(this.rb_angle){var p=this.rb_rotateAnchorX*m+l,q=this.rb_rotateAnchorY*n+o;i+=h*p+e*q;k+=j*p+g*q;b=Math.cos(this.rb_angle);c=Math.sin(this.rb_angle);d=h;f=j;h=d*b+e*c;e=-d*c+e*b;j=f*b+g*c;g=-f*c+g*b;i+=-h*p-e*q;k+=-j*p-g*q}if(this.sb_scaleX!=1||this.sb_scaleY!=
1)m=this.sb_scaleAnchorX*m+l,n=this.sb_scaleAnchorY*n+o,i+=h*m+e*n,k+=j*m+g*n,h*=this.sb_scaleX,e*=this.sb_scaleY,j*=this.sb_scaleX,g*=this.sb_scaleY,i+=-h*m-e*n,k+=-j*m-g*n;a[0]=h;a[1]=e;a[2]=i;a[3]=j;a[4]=g;a[5]=k;return this},setRotationAnchored:function(a,b,c){this.rb_angle=a;this.rb_rotateAnchorX=b;this.rb_rotateAnchorY=c;return this},setScaleAnchored:function(a,b,c,d){this.sb_scaleX=a;this.sb_scaleAnchorX=c;this.sb_scaleY=b;this.sb_scaleAnchorY=d;return this},setLocation:function(a,b){this.tb_x=
a;this.tb_y=b;return this}};extend(CAAT.Path,CAAT.PathSegment,null)})();(function(){CAAT.PathActor=function(){CAAT.PathActor.superclass.constructor.call(this);return this};CAAT.PathActor.prototype={path:null,pathBoundingRectangle:null,bOutline:false,outlineColor:"black",getPath:function(){return this.path},setPath:function(a){this.path=a;this.pathBoundingRectangle=a.getBoundingBox();return this},paint:function(a,b){CAAT.PathActor.superclass.paint.call(this,a,b);var c=a.crc;c.strokeStyle="black";this.path.paint(a);if(this.bOutline)c.strokeStyle=this.outlineColor,c.strokeRect(0,
0,this.width,this.height)},showBoundingBox:function(a,b){if((this.bOutline=a)&&b)this.outlineColor=b},setInteractive:function(a){this.path&&this.path.setInteractive(a);return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}};extend(CAAT.PathActor,CAAT.ActorContainer,null)})();