// $Id: imgPreload.js,v 1.2 2005/06/19 05:15:45 stefanos Exp $

function imgPreloadStatus(msg)
{
	window.status = msg
	return true
}


function imgPreload(name) 
{
	if ( jsDebug ) {
		alert("imgPreload new called");
	}
	this.name     = name ;
	this.called   = 0 ;
	this.imgObj  = [];
}

imgPreload.prototype.loadImg = function ()
{
	var n = arguments.length;

	if ( jsDebug ) {
		alert("imgPreload loadImg called");
	}
	if ( this.called == 0 ) {

		called = 1;

		for ( var i = 0 ; i < n ; i++ ) {
			this.imgObj[i]  = new Image();
			this.imgObj[i].src = arguments[i];
			if ( jsDebug ) {
				imgPreloadStatus("preloading: " + arguments[i]);
				alert("loadImg: " +  arguments[i]);
			}
		}
		imgPreloadStatus("Preloading images..\n");

	}
}

imgPreload.prototype.progress = function () {
	
	var i = 0 ;
	var n = 0 ;

	for ( var i = 0 ; i < this.imgObj.length ; i++ ) {
		if ( this.imgObj[i].complete ) {
			n++;
		}
	}
	return n;
}
