if(typeof kapit=="undefined"){var kapit={}}if(typeof kapit.lang=="undefined"){kapit.lang={}}if(typeof kapit.lang.event=="undefined"){kapit.lang.event={}}if(typeof kapit.lang.pool=="undefined"){kapit.lang.pool={}}kapit.lang.createDelegate=function(a,b){return function(){return b.apply(a,arguments)}};kapit.lang.event.defineEventClass=function(c,a){var b=function(e,d){this.type=e;this.target=d;for(strProp in c){this[strProp]=c[strProp]}};for(strConst in a){b[strConst]=a[strConst]}return b};kapit.lang.event.mixinEventDispatcher=function(a){a.__bootEventDispatcher=function(){if(typeof this.__mapHandlers!="undefined"){return}this.__mapHandlers={};this.__aEventQueue=[];this.__objTimerId=null};a.hasEventListener=function(b){this.__bootEventDispatcher();if(typeof this.__mapHandlers[b]=="undefined"){return false}return 0<this.__mapHandlers[b].length};a.addEventListener=function(d,c,b){this.__bootEventDispatcher();if(typeof this.__mapHandlers[d]=="undefined"){this.__mapHandlers[d]=[]}if(!b||(typeof b=="undefined")){b=null}this.__addHandler(d,c,b)};a.removeEventListener=function(c,b){this.__bootEventDispatcher();if(!this.hasEventListener(c)){return}this.__removeHandler(c,b)};a.dispatchEvent=function(b){this.__bootEventDispatcher();if(!this.hasEventListener(b.type)){return}this.__aEventQueue.push(b);this.__runTimer()};a.__addHandler=function(d,c,b){var e={delegate:null,signature:null};e.signature=c;if(!b){e.delegate=c}else{e.delegate=kapit.lang.createDelegate(b,c)}this.__mapHandlers[d].push(e)};a.__removeHandler=function(d,c){var e=null;for(var b=this.__mapHandlers[d].length;b-->0;){e=this.__mapHandlers[d][b];if(c==e.signature){this.__mapHandlers[d].splice(b,1)}}};a.__execHandlers=function(d,b){var e=null;for(var c=0;c<this.__mapHandlers[d].length;c++){e=this.__mapHandlers[d][c];e.delegate(b)}};a.__dispatchNextEvent=function(){this.__clearTimer();if(0==this.__aEventQueue.length){return}var b=this.__aEventQueue.shift();this.__execHandlers(b.type,b);if(0<this.__aEventQueue.length){this.__runTimer()}};a.__runTimer=function(){if(null!=this.__objTimerId){return}this.__objTimerId=setTimeout(kapit.lang.createDelegate(this,this.__dispatchNextEvent),80)};a.__clearTimer=function(){if(null!=this.__objTimerId){clearTimeout(this.__objTimerId)}this.__objTimerId=null};return a};kapit.lang.pool.mixinObjectPool=function(a){a.__bootObjectPool=function(){if(typeof this.__mapObjects!="undefined"){return}this.__mapObjects={};this.__aStorageKeys=[]};a.isKeyPresent=function(b){this.__bootObjectPool();return(typeof this.__mapObjects[b]!="undefined")};a.isItemPresent=function(c,b){if(!this.isKeyPresent(c)){return false}return(this.getByKey(c)==b)};a.getByKey=function(b){this.__bootObjectPool();return this.__mapObjects[b]};a.add=function(c,b){if(this.isItemPresent(c,b)){return}if(this.isKeyPresent(c)){this.remove(c)}this.__doAdd(c,b)};a.remove=function(b){if(!this.isKeyPresent(b)){return null}return this.__doRemove(b)};a.clear=function(){this.__bootObjectPool();for(var b in this.__mapObjects){this.__doRemove(b)}};a.isEmpty=function(){return 0==this.getItemCount()};a.__doAdd=function(c,b){this.__mapObjects[c]=b;this.__aStorageKeys.push(c)};a.__doRemove=function(d){var c=this.__mapObjects[d];delete this.__mapObjects[d];for(var b=this.__aStorageKeys.length;b-->0;){if(d==this.__aStorageKeys[b]){this.__aStorageKeys.splice(b,1)}}return c};a.getItemCount=function(){this.__bootObjectPool();return this.__aStorageKeys.length};a.getStorageKeys=function(){this.__bootObjectPool();return this.__aStorageKeys};return a};
