
Preloader=function(){this.callbacks=[];this.images=[];this.loadedImages=[];this.imagesLoaded=0;}
Preloader.prototype={add:function(image){if(typeof image=='string')this.images.push(image);if(typeof image=='array'||typeof image=='object'){for(var i=0;i<image.length;i++){this.images.push(image[i]);}}},onFinish:function(func){if(typeof func=='function')this.callbacks.push(func);if(typeof func=='array'||typeof func=='object'){for(var i=0;i<func.length;i++){this.callbacks.push(func[i]);}}},load:function(){for(var i=0;i<this.images.length;i++){var el=this;this.loadedImages[i]=new Image();this.loadedImages[i].onload=function(){el.checkFinished.apply(el)}
this.loadedImages[i].src=this.images[i];}},checkFinished:function(){this.imagesLoaded++;if(this.imagesLoaded==this.images.length)this.fireFinish();},fireFinish:function(){for(var i=0;i<this.callbacks.length;i++){alert(this.callbacks[i]);this.callbacks[i]();}
this.images=[];this.loadedImages=[];this.imagesLoaded=0;this.callbacks=[];}}
