function CCacheImage(){this.image=null;this.image_locked=0;this.image_unusedCount=0}function CCacheManager(){var a=this;a.arrayImages=[];a.arrayCount=0;a.countValidImage=5;a.CheckImagesForNeed=function(){var a=this;for(var b=0;b<a.arrayCount;++b)if(a.arrayImages[b].image_locked==0&&a.arrayImages[b].image_unusedCount>=a.countValidImage){delete a.arrayImages[b].image;a.arrayImages.splice(b,1);--b;--a.arrayCount}};a.UnLock=function(a){if(null==a)return;a.image_locked=0;a.image_unusedCount=0};a.Lock=function(e,d){var a=this;for(var c=0;c<a.arrayCount;++c){if(a.arrayImages[c].image_locked)continue;var g=a.arrayImages[c].image.width,f=a.arrayImages[c].image.height;if(g==e&&f==d){a.arrayImages[c].image_locked=1;a.arrayImages[c].image_unusedCount=0;a.arrayImages[c].image.ctx.fillStyle="#ffffff";a.arrayImages[c].image.ctx.fillRect(0,0,e,d);return a.arrayImages[c]}a.arrayImages[c].image_unusedCount++}a.CheckImagesForNeed();var b=a.arrayCount;a.arrayCount++;a.arrayImages[b]=new CCacheImage;a.arrayImages[b].image=document.createElement("canvas");a.arrayImages[b].image.width=e;a.arrayImages[b].image.height=d;a.arrayImages[b].image.ctx=a.arrayImages[b].image.getContext("2d");a.arrayImages[b].image.ctx.fillStyle="#ffffff";a.arrayImages[b].image.ctx.fillRect(0,0,e,d);a.arrayImages[b].image_locked=1;a.arrayImages[b].image_unusedCount=0;return a.arrayImages[b]}}