function ImageLoader(arrImages, barParent){ this.imgs = arrImages; this.objImgs = []; this.barParent = barParent ? barParent : false; this.pBar = new ProgressBar(this.imgs.length, this.barParent); this.onload = DOMEvent.cloneEvent(this.pBar.oncomplete); } ImageLoader.prototype.start = function(){ this.imgs.each( function(src){ var img = new Image(); img.src = src; this.objImgs.push(img); if(img.height != 0){ this.pBar.nextStep(); }else{ img.onload = function(){ this.pBar.nextStep(); }.bind(this); } Style.setElementStyle(img, ImageLoader.imgStyling, null, true); document.body.appendChild(img); }.bind(this) );//each } ImageLoader.imgStyling = { position: "absolute", left: -1000, top: -1000 }