
function ImagePreloader(imagePath, params, callback)
{

	this.callback = callback; 

	this.nLoaded = 0;
	this.image = new Image;

	this.params = new Array();
	this.params = params;

	this.preload(imagePath);

}

ImagePreloader.prototype.preload = function(imagePath)
{

	this.image.onload = ImagePreloader.prototype.onload;
	this.image.onerror = ImagePreloader.prototype.onerror;
	this.image.onabort = ImagePreloader.prototype.onabort;

	this.image.oImagePreloader = this;

	this.image.src = imagePath;
	this.image.name = imagePath;

}

ImagePreloader.prototype.onComplete = function()
{

	this.callback(this.image, this.params);

}

ImagePreloader.prototype.onload = function()
{

	this.oImagePreloader.onComplete();

}

ImagePreloader.prototype.onerror = function()
{

	this.bError = true;
	this.oImagePreloader.onComplete();

}

ImagePreloader.prototype.onabort = function()
{

	this.bAbort = true;
	this.oImagePreloader.onComplete();

}
