text: window.gamecore={hasOwn:Object.prototype.hasOwnProperty,isFunction:function(a){return !!(a&&a.constructor&&a.call&&a.apply)},isWindow:function(a){return !!(a&&a.setInterval)},isArray:Array.isArray||function(a){return(a.constructor===Array)},isString:function(a){return(typeof a=="string")},isObject:function(a){return a===Object(a)},isPlainObject:function(c){if(!c||this.isObject(c)||c.nodeType||this.isWindow(c)){return false}try{if(c.constructor&&!this.hasOwn.call(c,"constructor")&&!this.hasOwn.call(c.constructor.prototype,"isPrototypeOf")){return false}}catch(b){return false}var a;for(a in c){}return a===undefined||this.hasOwn.call(c,a)},extend:function(){var k,c,a,b,g,h,f=arguments[0]||{},e=1,d=arguments.length,j=false;if(typeof f==="boolean"){j=f;f=arguments[1]||{};e=2}if(typeof f!=="object"&&!gamecore.isFunction(f)){f={}}if(d===e){f=this;--e}for(;e<d;e++){if((k=arguments[e])!=null){for(c in k){a=f[c];b=k[c];if(f===b){continue}if(j&&b&&(this.isPlainObject(b)||(g=this.isArray(b)))){if(g){g=false;h=a&&this.isArray(a)?a:[]}else{h=a&&this.isPlainObject(a)?a:{}}f[c]=this.extend(j,h,b)}else{if(b!==undefined){f[c]=b}}}}}return f}};gamecore.push=Array.prototype.push;gamecore.merge=function(e,c){var d=e.length,b=0;if(typeof c.length==="number"){for(var a=c.length;b<a;b++){e[d++]=c[b]}}else{while(c[b]!==undefined){e[d++]=c[b++]}}e.length=d;return e};gamecore.makeArray=function(c,b){var a=b||[];if(c!=null){if(c.length==null||gamecore.isString(c)||gamecore.isFunction(c)||gamecore.isWindow(c)){gamecore.push.call(a,c)}else{gamecore.merge(a,c)}}return a};gamecore.each=function(d,g,c){var b,e=0,f=d.length,a=f===undefined||gamecore.isFunction(d);if(c){if(a){for(b in d){if(g.apply(d[b],c)===false){break}}}else{for(;e<f;){if(g.apply(d[e++],c)===false){break}}}}else{if(a){for(b in d){if(g.call(d[b],b,d[b])===false){break}}}else{for(;e<f;){if(g.call(d[e],e,d[e++])===false){break}}}}return d};gamecore._flagsCache={};gamecore.createFlags=function(a){var b=gamecore._flagsCache[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++){b[a[c]]=true}return b};gamecore.Callbacks=function(c){c=c?(gamecore._flagsCache[c]||gamecore.createFlags(c)):{};var h=[],i=[],d,e,b,f,g,k=function(l){var m,o,n,p;for(m=0,o=l.length;m<o;m++){n=l[m];if(gamecore.isArray(n)){k(n)}else{if(gamecore.isFunction(n)){if(!c.unique||!j.has(n)){h.push(n)}}}}},a=function(m,l){l=l||[];d=!c.memory||[m,l];e=true;g=b||0;b=0;f=h.length;for(;h&&g<f;g++){if(h[g].apply(m,l)===false&&c.stopOnFalse){d=true;break}}e=false;if(h){if(!c.once){if(i&&i.length){d=i.shift();j.fireWith(d[0],d[1])}}else{if(d===true){j.disable()}else{h=[]}}}},j={add:function(){if(h){var l=h.length;k(arguments);if(e){f=h.length}else{if(d&&d!==true){b=l;a(d[0],d[1])}}}return this},remove:function(){if(h){var l=arguments,n=0,o=l.length;for(;n<o;n++){for(var m=0;m<h.length;m++){if(l[n]===h[m]){if(e){if(m<=f){f--;if(m<=g){g--}}}h.splice(m--,1);if(c.unique){break}}}}}return this},has:function(m){if(h){var l=0,n=h.length;for(;l<n;l++){if(m===h[l]){return true}}}return false},empty:function(){h=[];return this},disable:function(){h=i=d=undefined;return this},disabled:function(){return !h},lock:function(){i=undefined;if(!d||d===true){j.disable()}return this},locked:function(){return !i},fireWith:function(m,l){if(i){if(e){if(!c.once){i.push([m,l])}}else{if(!(c.once&&d)){a(m,l)}}}return this},fire:function(){j.fireWith(this,arguments);return this},fired:function(){return !!d}};return j};gamecore.extend({Deferred:function(e){var d=gamecore.Callbacks("once memory"),c=gamecore.Callbacks("once memory"),b=gamecore.Callbacks("memory"),a="pending",g={resolve:d,reject:c,notify:b},i={done:d.add,fail:c.add,progress:b.add,state:function(){return a},isResolved:d.fired,isRejected:c.fired,then:function(k,j,l){h.done(k).fail(j).progress(l);return this},always:function(){h.done.apply(h,arguments).fail.apply(h,arguments);return this},pipe:function(l,k,j){return gamecore.Deferred(function(m){gamecore.each({done:[l,"resolve"],fail:[k,"reject"],progress:[j,"notify"]},function(o,r){var n=r[0],q=r[1],p;if(gamecore.isFunction(n)){h[o](function(){p=n.apply(this,arguments);if(p&&gamecore.isFunction(p.promise)){p.promise().then(m.resolve,m.reject,m.notify)}else{m[q+"With"](this===h?m:this,[p])}})}else{h[o](m[q])}})}).promise()},promise:function(k){if(k==null){k=i}else{for(var j in i){k[j]=i[j]}}return k}},h=i.promise({}),f;for(f in g){h[f]=g[f].fire;h[f+"With"]=g[f].fireWith}h.done(function(){a="resolved"},c.disable,b.lock).fail(function(){a="rejected"},d.disable,b.lock);if(e){e.call(h,h)}return h},when:function(h){var a=[].slice;var e=a.call(arguments,0),c=0,b=e.length,j=new Array(b),d=b,f=b,k=b<=1&&h&&gamecore.isFunction(h.promise)?h:gamecore.Deferred(),m=k.promise();function l(n){return function(i){e[n]=arguments.length>1?a.call(arguments,0):i;if(!(--d)){k.resolveWith(k,e)}}}function g(n){return function(i){j[n]=arguments.length>1?a.call(arguments,0):i;k.notifyWith(m,j)}}if(b>1){for(;c<b;c++){if(e[c]&&e[c].promise&&gamecore.isFunction(e[c].promise)){e[c].promise().then(l(c),k.reject,g(c))}else{--d}}if(!d){k.resolveWith(k,e)}}else{if(k!==h){k.resolveWith(k,b?[h]:[])}}return m}});(function(d){var b={undHash:/_|-/,colons:/::/,words:/([A-Z]+)([A-Z][a-z])/g,lowUp:/([a-z\d])([A-Z])/g,dash:/([a-z\d])([A-Z])/g,replacer:/\{([^\}]+)\}/g,dot:/\./},f=function(i,h,g){return i[h]||(g&&(i[h]={}))},c=function(h){var g=typeof h;return g&&(g=="function"||g=="object")},a=function(l,q,r){var j=l?l.split(b.dot):[],h=j.length,g=d.isArray(q)?q:[q||window],m,n,k,p=0,o;if(h==0){return g[0]}while(m=g[p++]){for(k=0;k<h-1&&c(m);k++){m=f(m,j[k],r)}if(c(m)){n=f(m,j[k],r);if(n!==undefined){if(r===false){delete m[j[k]]}return n}}}},e=d.String={getObject:a,capitalize:function(h,g){return h.charAt(0).toUpperCase()+h.substr(1)},camelize:function(g){g=e.classize(g);return g.charAt(0).toLowerCase()+g.substr(1)},classize:function(h,k){var j=h.split(b.undHash),g=0;for(;g<j.length;g++){j[g]=e.capitalize(j[g])}return j.join(k||"")},niceName:function(g){return e.classize(g," ")},underscore:function(g){return g.replace(b.colons,"/").replace(b.words,"$1_$2").replace(b.lowUp,"$1_$2").replace(b.dash,"_").toLowerCase()},sub:function(h,i,g){var j=[];j.push(h.replace(b.replacer,function(n,k){var l=a(k,i,typeof g=="boolean"?!g:g),m=typeof l;if((m==="object"||m==="function")&&m!==null){j.push(l);return""}else{return""+l}}));return j.length<=1?j[0]:j}}})(gamecore);(function(j){var e=false,a=j.makeArray,b=j.isFunction,f=j.isArray,h=j.extend,k=function(m){if(!m||typeof(m)!="object"){return m}if(m instanceof Array){var p=[];for(var o=0;o<m.length;o++){p[o]=k(m[o])}return p}else{var l={};for(var n in m){l[n]=k(m[n])}return l}},d=function(l,m){return l.concat(a(m))},i=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,c=function(o,l,n){n=n||o;for(var m in o){n[m]=b(o[m])&&b(l[m])&&i.test(o[m])?(function(p,q){return function(){var s=this._super,r;this._super=l[p];r=q.apply(this,arguments);this._super=s;return r}})(m,o[m]):o[m]}},g=j.Class=function(){if(arguments.length){return g.extend.apply(g,arguments)}};h(g,{callback:function(m){var n=a(arguments),l;m=n.shift();if(!f(m)){m=[m]}l=this;return function o(){var t=d(n,arguments),p,r=m.length,s=0,q;for(;s<r;s++){q=m[s];if(!q){continue}p=typeof q=="string";if(p&&l._set_called){l.called=q}t=(p?l[q]:q).apply(l,t||[]);if(s<r-1){t=!f(t)||t._use_call?[t]:t}}return t}},getObject:j.String.getObject,newInstance:function(){var m=this.rawInstance();var l;if(m.setup){l=m.setup.apply(m,arguments)}for(var n in m.__proto__){m[n]=k(m[n])}if(m.init){m.init.apply(m,f(l)?l:arguments)}return m},setup:function(l,m){this.defaults=h(true,{},l.defaults,this.defaults);if(this._types==undefined){this._types=[]}this._types.push(this.fullName);if(this._fullTypeName==undefined){this._fullTypeName="|"}this._fullTypeName+=this.fullName+"|";return arguments},rawInstance:function(){e=true;var l=new this();e=false;return l},extend:function(n,s,q){if(typeof n!="string"){q=s;s=n;n=null}if(!q){q=s;s=null}q=q||{};var r=this,w=this.prototype,m,u,o,v;this.isA=function(x){return this._fullTypeName.indexOf("|"+x+"|")!=-1};e=true;v=new this();e=false;c(q,w,v);function l(){if(e){return}if(this.constructor!==l&&arguments.length){return arguments.callee.extend.apply(arguments.callee,arguments)}else{return this.Class.newInstance.apply(this.Class,arguments)}}for(m in this){if(this.hasOwnProperty(m)){l[m]=k(this[m])}}c(s,this,l);if(n){var p=n.split(/\./);var u=p.pop();if(p.length>0){current=g.getObject(p.join("."),window,true),o=current}current[u]=l}h(l,{prototype:v,namespace:o,shortName:u,constructor:l,fullName:n});l.prototype.Class=l.prototype.constructor=l;var t=l.setup.apply(l,d([r],arguments));if(l.init){l.init.apply(l,t||[])}return l}});g.prototype.callback=g.callback})(gamecore);gamecore.Base=gamecore.Class("gamecore.Base",{totalObjects:0,WARN:"WARN",DEBUG:"DEBUG",ERROR:"ERROR",INFO:"INFO",log:function(d,c,b){var a="";if(d){a=":"+d}console.log.apply(console,[this.fullName+a+" ["+c+"] "].concat(Array.prototype.slice.call(b)))},warn:function(a){this.log(null,this.WARN,a)},debug:function(a){this.log(null,this.DEBUG,a)},error:function(a){this.log(null,this.ERROR,a)},info:function(a){this.log(null,this.INFO,a)},assert:function(a,b){if(!b){throw a}}},{objectId:0,uniqueId:null,init:function(){},setup:function(){this.objectId=this.Class.totalObjects++;this.uniqueId=this.Class.fullName+":"+this.objectId},getUniqueId:function(){return this.uniqueId},hashCode:function(){return this.getUniqueId()},warn:function(a){this.Class.log(this.objectId,this.Class.WARN,arguments)},debug:function(a){this.Class.log(this.objectId,this.Class.DEBUG,arguments)},error:function(a){this.Class.log(this.objectId,this.Class.ERROR,arguments)},info:function(a){this.Class.log(this.objectId,this.Class.INFO,arguments)},toString:function(){return this.Class.fullName+" [id: "+this.objectId+"]"}});gamecore.Device=gamecore.Base.extend("gamecore.Device",{pixelRatio:0,isiPhone:false,isiPhone4:false,isiPad:false,isiPod:false,isAndroid:false,isTouch:false,isFirefox:false,isChrome:false,isOpera:false,isIE:false,ieVersion:0,requestAnimFrame:null,hasMemoryProfiling:false,canPlayOgg:false,canPlayMP3:false,canPlayWav:false,init:function(){this.pixelRatio=window.devicePixelRatio||1;this.isiPhone=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1;this.isiPod=navigator.userAgent.toLowerCase().indexOf("ipod")!=-1;this.isiPhone4=(this.pixelRatio==2&&this.isiPhone);this.isiPad=navigator.userAgent.toLowerCase().indexOf("ipad")!=-1;this.isAndroid=navigator.userAgent.toLowerCase().indexOf("android")!=-1;this.isFirefox=navigator.userAgent.toLowerCase().indexOf("firefox")!=-1;this.isChrome=navigator.userAgent.toLowerCase().indexOf("chrome")!=-1;this.isOpera=navigator.userAgent.toLowerCase().indexOf("opera")!=-1;this.isTouch=window.ontouchstart!=="undefined";this.isiOS=(this.isiPhone||this.iPad||this.isiPod);if(window.performance!=undefined){this.hasMemoryProfiling=(window.performance.memory)}if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){this.ieVersion=new Number(RegExp.$1);this.isIE=true}try{var a=new Audio();if(a.canPlayType("audio/ogg")){this.canPlayOgg=true}if(a.canPlayType("audio/mpeg")){this.canPlayMP3=true}if(a.canPlayType("audio/x-wav")){this.canPlayWav=true}}catch(b){}this.requestAnimFrame=(function(){var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e,d){window.setTimeout(e,16,Date.now())};return function(e,d){c.apply(window,[e,d])}})()},canPlay:function(a){if(a.toLowerCase()==="mp3"&&this.canPlayMP3){return true}if(a.toLowerCase()==="ogg"&&this.canPlayOgg){return true}if(a.toLowerCase()==="wav"&&this.canPlayWav){return true}return false},getUsedHeap:function(){return this.hasMemoryProfiling?window.performance.memory.usedJSHeapSize:0},getTotalHeap:function(){return this.hasMemoryProfiling?window.performance.memory.totalJSHeapSize:0}},{});gamecore.HashList=gamecore.Base.extend("gamecore.HashList",{},{hashtable:null,init:function(){this.hashtable=new gamecore.Hashtable()},add:function(b,a){var c=this.hashtable.get(b);if(c==null){c=new pc.LinkedList();this.hashtable.put(b,c)}c.add(a)},remove:function(b,a){var c=this.hashtable.get(b);if(c==null){throw"No list for a key in hashlist when removing"}c.remove(a)},get:function(a){return this.hashtable.get(a)}});gamecore.Hashtable=(function(){var p="function";var n=(typeof Array.prototype.splice==p)?function(s,r){s.splice(r,1)}:function(u,t){var s,v,r;if(t===u.length-1){u.length=t}else{s=u.slice(t+1);u.length=t;for(v=0,r=s.length;v<r;++v){u[t+v]=s[v]}}};function a(t){var r;if(typeof t=="string"){return t}else{if(typeof t.hashCode==p){r=t.hashCode();return(typeof r=="string")?r:a(r)}else{if(typeof t.toString==p){return t.toString()}else{try{return String(t)}catch(s){return Object.prototype.toString.call(t)}}}}}function g(r,s){return r.equals(s)}function e(r,s){return(typeof s.equals==p)?s.equals(r):(r===s)}function c(r){return function(s){if(s===null){throw new Error("null is not a valid "+r)}else{if(typeof s=="undefined"){throw new Error(r+" must not be undefined")}}}}var q=c("key"),l=c("value");function d(u,s,t,r){this[0]=u;this.entries=[];this.addEntry(s,t);if(r!==null){this.getEqualityFunction=function(){return r}}}var h=0,j=1,f=2;function o(r){return function(t){var s=this.entries.length,v,u=this.getEqualityFunction(t);while(s--){v=this.entries[s];if(u(t,v[0])){switch(r){case h:return true;case j:return v;case f:return[s,v[1]]}}}return false}}function k(r){return function(u){var v=u.length;for(var t=0,s=this.entries.length;t<s;++t){u[v+t]=this.entries[t][r]}}}d.prototype={getEqualityFunction:function(r){return(typeof r.equals==p)?g:e},getEntryForKey:o(j),getEntryAndIndexForKey:o(f),removeEntryForKey:function(s){var r=this.getEntryAndIndexForKey(s);if(r){n(this.entries,r[0]);return r[1]}return null},addEntry:function(r,s){this.entries[this.entries.length]=[r,s]},keys:k(0),values:k(1),getEntries:function(s){var u=s.length;for(var t=0,r=this.entries.length;t<r;++t){s[u+t]=this.entries[t].slice(0)}},containsKey:o(h),containsValue:function(s){var r=this.entries.length;while(r--){if(s===this.entries[r][1]){return true}}return false}};function m(s,t){var r=s.length,u;while(r--){u=s[r];if(t===u[0]){return r}}return null}function i(r,s){var t=r[s];return(t&&(t instanceof d))?t:null}function b(t,r){var w=this;var v=[];var u={};var x=(typeof t==p)?t:a;var s=(typeof r==p)?r:null;this.put=function(B,C){q(B);l(C);var D=x(B),E,A,z=null;E=i(u,D);if(E){A=E.getEntryForKey(B);if(A){z=A[1];A[1]=C}else{E.addEntry(B,C)}}else{E=new d(D,B,C,s);v[v.length]=E;u[D]=E}return z};this.get=function(A){q(A);var B=x(A);var C=i(u,B);if(C){var z=C.getEntryForKey(A);if(z){return z[1]}}return null};this.containsKey=function(A){q(A);var z=x(A);var B=i(u,z);return B?B.containsKey(A):false};this.containsValue=function(A){l(A);var z=v.length;while(z--){if(v[z].containsValue(A)){return true}}return false};this.clear=function(){v.length=0;u={}};this.isEmpty=function(){return !v.length};var y=function(z){return function(){var A=[],B=v.length;while(B--){v[B][z](A)}return A}};this.keys=y("keys");this.values=y("values");this.entries=y("getEntries");this.remove=function(B){q(B);var C=x(B),z,A=null;var D=i(u,C);if(D){A=D.removeEntryForKey(B);if(A!==null){if(!D.entries.length){z=m(v,C);n(v,z);delete u[C]}}}return A};this.size=function(){var A=0,z=v.length;while(z--){A+=v[z].entries.length}return A};this.each=function(C){var z=w.entries(),A=z.length,B;while(A--){B=z[A];C(B[0],B[1])}};this.putAll=function(H,C){var B=H.entries();var E,F,D,z,A=B.length;var G=(typeof C==p);while(A--){E=B[A];F=E[0];D=E[1];if(G&&(z=w.get(F))){D=C(F,z,D)}w.put(F,D)}};this.clone=function(){var z=new b(t,r);z.putAll(w);return z};this.toString=function(){var z="";var B=this.keys();for(var A=0;A<B.length;A++){var C=this.get(B[A]);z+=B[A].toString()+" = "+C.toString()+"\n"}return z}}return b})();gamecore.LinkedListNode=gamecore.Base("gamecore.LinkedNode",{},{obj:null,nextLinked:null,prevLinked:null,free:true,next:function(){return this.nextLinked},object:function(){return this.obj},prev:function(){return this.prevLinked}});gamecore.LinkedList=gamecore.Base("gamecore.LinkedList",{},{first:null,last:null,count:0,objToNodeMap:null,init:function(){this._super();this.objToNodeMap=new gamecore.Hashtable()},getNode:function(a){return this.objToNodeMap.get(a.getUniqueId())},addNode:function(b){var a=new gamecore.LinkedNode();a.obj=b;a.prevLinked=null;a.nextLinked=null;a.free=false;this.objToNodeMap.put(b.getUniqueId(),a);return a},add:function(b){var a=this.getNode(b);if(a==null){a=this.addNode(b)}else{if(a.free==false){throw"Attempting to add object: "+b.getUniqueId()+" twice to list "+this.getUniqueId()}a.obj=b;a.free=false;a.nextLinked=null;a.prevLinked=null}if(this.first==null){this.first=a;this.last=a;a.nextLinked=null;a.prevLinked=null}else{if(this.last==null){throw"Hmm, no last in the list -- that shouldn't happen here"}this.last.nextLinked=a;a.prevLinked=this.last;this.last=a;a.nextLinked=null}this.count++;if(this.showDebug){this.dump("after add")}},has:function(b){var a=this.getNode(b);return !(a==null||a.free==true)},moveUp:function(f){this.dump("before move up");var h=this.getNode(f);if(!h){throw"Oops, trying to move an object that isn't in the list"}if(h.prevLinked==null){return}var d=h.prevLinked;var e=d.prevLinked;if(h==this.last){this.last=d}var g=h.nextLinked;if(e){e.nextLinked=h}h.nextLinked=d;h.prevLinked=d.prevLinked;d.nextLinked=g;d.prevLinked=h;if(this.first==d){this.first=h}},moveDown:function(d){var a=this.getNode(d);if(!a){throw"Oops, trying to move an object that isn't in the list"}if(a.nextLinked==null){return}var e=a.nextLinked;this.moveUp(e.obj);if(this.last==e){this.last=a}},sort:function(d){var b=[];var c=this.first;while(c){b.push(c.object());c=c.next()}this.clear();b.sort(d);for(var a=0;a<b.length;a++){this.add(b[a])}},remove:function(b){if(this.showDebug){this.dump("before remove of "+b)}var a=this.getNode(b);if(a==null||a.free==true){return false}if(a.prevLinked!=null){a.prevLinked.nextLinked=a.nextLinked}if(a.nextLinked!=null){a.nextLinked.prevLinked=a.prevLinked}if(a.prevLinked==null){this.first=a.nextLinked}if(a.nextLinked==null){this.last=a.prevLinked}a.free=true;a.prevLinked=null;a.nextLinked=null;this.count--;if(this.showDebug){this.dump("after remove")}return true},clear:function(){var a=this.first;while(a!=null){a.free=true;a=a.nextLinked}this.first=null;this.count=0},length:function(){return this.count},dump:function(c){this.debug("===================="+c+"=====================");var b=this.first;while(b!=null){this.debug("{"+b.obj.toString()+"} previous="+(b.prevLinked?b.prevLinked.obj:"NULL"));b=b.next()}this.debug("===================================");this.debug("Last: {"+(this.last?this.last.obj:"NULL")+"} First: {"+(this.first?this.first.obj:"NULL")+"}")}});gamecore.PerformanceMeasure=gamecore.Base.extend("gamecore.PerformanceMeasure",{history:[],clearHistory:function(){history.length=0}},{timeStart:0,timeEnd:0,timeDelat:0,memStart:0,memEnd:0,memDelta:0,description:null,init:function(a){this.description=a;this.start();this.Class.history.push(this)},start:function(){this.timeStart=Date.now();this.memStart=gamecore.Device.getUsedHeap()},end:function(){this.timeEnd=Date.now();this.timeDelta=this.timeEnd-this.timeStart;this.memEnd=gamecore.Device.getUsedHeap();if(this.memEnd<this.memStart){this.memDelta=0}else{this.memDelta=this.memEnd-this.memStart}return this.toString()},toString:function(){return this.description+" took "+this.timeDelta+"ms, "+(this.memDelta==0?"unknown":this.memDelta)+" byte(s)"}});gamecore.Pool=gamecore.Base.extend("gamecore.Pool",{INITIAL_POOL_SIZE:1,pools:new gamecore.Hashtable(),totalPooled:0,totalUsed:0,acquire:function(b){var a=this.getPool(b);if(a==undefined||a==null){a=new gamecore.Pool(b,this.INITIAL_POOL_SIZE);this.pools.put(b.fullName,a)}return a.acquire()},release:function(b){var a=this.pools.get(b.Class.fullName);if(a==undefined){throw"Oops, trying to release an object of type "+b.Class.fullName+" but no pool exists. Did you new an object instead of using create."}a.release(b)},getPool:function(a){return this.pools.get(a.fullName)},getStats:function(){var d="";var e=this.pools.keys();for(var c=0;c<e.length;c++){var b=e[c];var a=this.pools.get(b);d+=b+": "+a.getStats()+"\n"}return d}},{freeList:null,expansion:1,traces:null,init:function(b,a){this._super();this.classType=b;this.freeList=[];this.expand(a)},startTracing:function(){if(this.tracing){return}this.tracing=true;if(this.traces){this.traces.clear()}else{this.traces=new gamecore.Hashtable()}},stopTracing:function(){this.tracing=false},expand:function(b){gamecore.Pool.totalPooled+=b;for(var a=0;a<b;a++){this.freeList.push(new this.classType())}},getFreeCount:function(){return this.freeList.length},acquire:function(){if(this.freeList.length<=0){this.expansion=Math.round(this.expansion*1.2)+1;this.expand(this.expansion)}if(this.tracing){var a=printStackTrace();var c=a.length-1;while(a[c].indexOf("Class.addTo")==0&&c>0){c--}var b=this.traces.get(a[c]);if(b==null){this.traces.put(a[c],{value:1})}else{b.value++}}return this.freeList.pop()},release:function(a){this.freeList.push(a)},getStats:function(){var c=this.Class.fullName+" stats: "+this.freeList.length+" free.";if(this.tracing){c+="TRACING\n";var b=this.traces.keys();for(var a in b){c+=b[a]+" ("+this.traces.get(b[a]).value+")\n"}}return c},dump:function(a){this.info("================== "+a+" ===================");this.info("FREE");this.freeList.dump()},size:function(){return this.freeList.length},getFreeList:function(){return this.freeList}});gamecore.DualPool=gamecore.Pool.extend("gamecore.DualPool",{acquire:function(b){var a=this.getPool(b);if(a==undefined||a==null){a=new gamecore.DualPool(b,this.INITIAL_POOL_SIZE);this.pools.put(b.fullName,a)}return a.acquire()},getStats:function(){var d="";var e=this.pools.keys();for(var c=0;c<e.length;c++){var b=e[c];var a=this.pools.get(b);d+=b+" (free: "+a.freeList.length()+" used: "+a.usedList.length()+")\n"}return d}},{freeList:null,usedList:null,init:function(b,a){this.classType=b;this.usedList=new gamecore.LinkedList();this.freeList=new gamecore.LinkedList();this.expand(a)},expand:function(b){gamecore.Pool.totalPooled+=b;for(var a=0;a<b;a++){this.freeList.add(new this.classType())}},returnObj:null,acquire:function(){if(this.freeList.first==null){this.expand(Math.round(this.size()/5)+1)}this.returnObj=this.freeList.first.obj;this.freeList.remove(this.returnObj);this.returnObj.destroyed=false;this.usedList.add(this.returnObj);if(this.tracing){var a=printStackTrace();var c=a.length-1;while(a[c].indexOf("Class.addTo")==0&&c>0){c--}var b=this.traces.get(a[c]);if(b==null){this.traces.put(a[c],{value:1})}else{b.value++}}return this.returnObj},release:function(a){this.freeList.add(a);this.usedList.remove(a)},dump:function(a){this.info("================== "+a+" ===================");this.info("FREE");this.freeList.dump();this.info("USED");this.usedList.dump()},size:function(){return this.freeList.count+this.usedList.count},getUsedList:function(){return this.usedList}});gamecore.Pooled=gamecore.Base("gamecore.Pooled",{create:function(){return gamecore.Pool.acquire(this)},getPool:function(){return gamecore.Pool.getPool(this)}},{destroyed:false,init:function(){this._super()},release:function(){this.onRelease();gamecore.Pool.release(this)},onRelease:function(){}});gamecore.DualPooled=gamecore.Base("gamecore.DualPooled",{create:function(){return gamecore.DualPool.acquire(this)},getPool:function(){return gamecore.DualPool.getPool(this)}},{destroyed:false,init:function(){this._super()},release:function(){this.onRelease();gamecore.DualPool.release(this)},onRelease:function(){}});function printStackTrace(b){b=b||{guess:true};var c=b.e||null,e=!!b.guess;var d=new printStackTrace.implementation(),a=d.run(c);return(e)?d.guessAnonymousFunctions(a):a}printStackTrace.implementation=function(){};printStackTrace.implementation.prototype={run:function(a,b){a=a||this.createException();b=b||this.mode(a);if(b==="other"){return this.other(arguments.callee)}else{return this[b](a)}},createException:function(){try{this.undef()}catch(a){return a}},mode:function(a){if(a["arguments"]&&a.stack){return"chrome"}else{if(typeof a.message==="string"&&typeof window!=="undefined"&&window.opera){if(!a.stacktrace){return"opera9"}if(a.message.indexOf("\n")>-1&&a.message.split("\n").length>a.stacktrace.split("\n").length){return"opera9"}if(!a.stack){return"opera10a"}if(a.stacktrace.indexOf("called from line")<0){return"opera10b"}return"opera11"}else{if(a.stack){return"firefox"}}}return"other"},instrumentFunction:function(b,d,e){b=b||window;var a=b[d];b[d]=function c(){e.call(this,printStackTrace().slice(4));return b[d]._instrumented.apply(this,arguments)};b[d]._instrumented=a},deinstrumentFunction:function(a,b){if(a[b].constructor===Function&&a[b]._instrumented&&a[b]._instrumented.constructor===Function){a[b]=a[b]._instrumented}},chrome:function(b){var a=(b.stack+"\n").replace(/^\S[^\(]+?[\n$]/gm,"").replace(/^\s+(at eval )?at\s+/gm,"").replace(/^([^\(]+?)([\n$])/gm,"{anonymous}()@$1$2").replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm,"{anonymous}()@$1").split("\n");a.pop();return a},firefox:function(a){return a.stack.replace(/(?:\n@:0)?\s+$/m,"").replace(/^\(/gm,"{anonymous}(").split("\n")},opera11:function(g){var a="{anonymous}",h=/^.*line (\d+), column (\d+)(?: in (.+))? in (\S+):$/;var k=g.stacktrace.split("\n"),l=[];for(var c=0,f=k.length;c<f;c+=2){var d=h.exec(k[c]);if(d){var j=d[4]+":"+d[1]+":"+d[2];var b=d[3]||"global code";b=b.replace(/<anonymous function: (\S+)>/,"$1").replace(/<anonymous function>/,a);l.push(b+"@"+j+" -- "+k[c+1].replace(/^\s+/,""))}}return l},opera10b:function(h){var g=/^(.*)@(.+):(\d+)$/;var c=h.stacktrace.split("\n"),b=[];for(var f=0,a=c.length;f<a;f++){var d=g.exec(c[f]);if(d){var j=d[1]?(d[1]+"()"):"global code";b.push(j+"@"+d[2]+":"+d[3])}}return b},opera10a:function(g){var a="{anonymous}",h=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;var j=g.stacktrace.split("\n"),k=[];for(var c=0,f=j.length;c<f;c+=2){var d=h.exec(j[c]);if(d){var b=d[3]||a;k.push(b+"()@"+d[2]+":"+d[1]+" -- "+j[c+1].replace(/^\s+/,""))}}return k},opera9:function(j){var d="{anonymous}",h=/Line (\d+).*script (?:in )?(\S+)/i;var c=j.message.split("\n"),b=[];for(var g=2,a=c.length;g<a;g+=2){var f=h.exec(c[g]);if(f){b.push(d+"()@"+f[2]+":"+f[1]+" -- "+c[g+1].replace(/^\s+/,""))}}return b},other:function(g){var b="{anonymous}",f=/function\s*([\w\-$]+)?\s*\(/i,a=[],d,c,e=10;while(g&&g["arguments"]&&a.length<e){d=f.test(g.toString())?RegExp.$1||b:b;c=Array.prototype.slice.call(g["arguments"]||[]);a[a.length]=d+"("+this.stringifyArguments(c)+")";g=g.caller}return a},stringifyArguments:function(c){var b=[];var e=Array.prototype.slice;for(var d=0;d<c.length;++d){var a=c[d];if(a===undefined){b[d]="undefined"}else{if(a===null){b[d]="null"}else{if(a.constructor){if(a.constructor===Array){if(a.length<3){b[d]="["+this.stringifyArguments(a)+"]"}else{b[d]="["+this.stringifyArguments(e.call(a,0,1))+"..."+this.stringifyArguments(e.call(a,-1))+"]"}}else{if(a.constructor===Object){b[d]="#object"}else{if(a.constructor===Function){b[d]="#function"}else{if(a.constructor===String){b[d]='"'+a+'"'}else{if(a.constructor===Number){b[d]=a}}}}}}}}}return b.join(",")},sourceCache:{},ajax:function(a){var b=this.createXMLHTTPObject();if(b){try{b.open("GET",a,false);b.send(null);return b.responseText}catch(c){}}return""},createXMLHTTPObject:function(){var c,a=[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var b=0;b<a.length;b++){try{c=a[b]();this.createXMLHTTPObject=a[b];return c}catch(d){}}},isSameDomain:function(a){return typeof location!=="undefined"&&a.indexOf(location.hostname)!==-1},getSource:function(a){if(!(a in this.sourceCache)){this.sourceCache[a]=this.ajax(a).split("\n")}return this.sourceCache[a]},guessAnonymousFunctions:function(k){for(var g=0;g<k.length;++g){var f=/\{anonymous\}\(.*\)@(.*)/,l=/^(.*?)(?::(\d+))(?::(\d+))?(?: -- .+)?$/,b=k[g],c=f.exec(b);if(c){var e=l.exec(c[1]);if(e){var d=e[1],a=e[2],j=e[3]||0;if(d&&this.isSameDomain(d)&&a){var h=this.guessAnonymousFunction(d,a,j);k[g]=b.replace("{anonymous}",h)}}}}return k},guessAnonymousFunction:function(c,f,a){var b;try{b=this.findFunctionName(this.getSource(c),f)}catch(d){b="getSource failed with url: "+c+", exception: "+d.toString()}return b},findFunctionName:function(a,e){var g=/function\s+([^(]*?)\s*\(([^)]*)\)/;var k=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*function\b/;var h=/['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(?:eval|new Function)\b/;var b="",l,j=Math.min(e,20),d,c;for(var f=0;f<j;++f){l=a[e-f-1];c=l.indexOf("//");if(c>=0){l=l.substr(0,c)}if(l){b=l+b;d=k.exec(b);if(d&&d[1]){return d[1]}d=g.exec(b);if(d&&d[1]){return d[1]}d=h.exec(b);if(d&&d[1]){return d[1]}}}return"(?)"}};