var ImageLoader_Obj	= new Array();
function ImageLoader(sources,oncomplete) {
	
	this.sources			= sources;
	
	// image objects
	this.images				= new Array();
	
	// num of images to load
	this.imagesTotal		= 0;
	
	// total loaded
	this.imagesLoaded		= 0;
	
	// function to run on load completion
	this.oncomplete = oncomplete;
	
	// object reference index
	this.id = ImageLoader_Obj.length;
	
	// add reference to array
	ImageLoader_Obj[this.id] = (this);
}

ImageLoader.prototype.load = function() {
	this.imagesTotal		= this.sources.length;
	// send each source for preloading
	for(var i=0;i<this.sources.length;i++) {
		this.images[i] = new Image();
		this.images[i].src = this.sources[i];
		this.images[i].onload = function() {
			ImageLoader_Obj[ImageLoader_Obj.length-1].imagesLoaded++;
			ImageLoader_Obj[ImageLoader_Obj.length-1].hasLoaded();
		}
	}
}

ImageLoader.prototype.hasLoaded = function() {
	if(this.imagesTotal == this.imagesLoaded	) {
		if(typeof(this.oncomplete) == 'function') {
			this.oncomplete();
		}
	}
}