<!--

function ImagePreload(p_aImages, p_pfnPercent, p_pfnFinished) {  
	// Call-back functions
	this.m_pfnPercent 		= p_pfnPercent;
  this.m_pfnFinished 		=	p_pfnFinished;

	// Class Member Vars
  this.m_nLoaded 				= 0;
  this.m_nProcessed 		= 0;
  this.m_aImages 				= new Array;
  this.m_nICount 				=	p_aImages.length;

	// Preload Array of Images
  for (i=0 ; i<p_aImages.length ; i++)
  	this.Preload (p_aImages[i]);
}

ImagePreload.prototype.Preload	=	function (p_oImage) {  
	var oImage 						=	new Image;
  this.m_aImages.push (oImage);

  oImage.onload 				=	ImagePreload.prototype.OnLoad;
  oImage.oImagePreload 	=	this;  			// Give the Image Object a Reference to our Class..
  oImage.bLoaded 				=	false;      // Custom value added to track state
  oImage.source 				=	p_oImage;  	// Original Source Path to Image (for later use)
  oImage.src 						=	p_oImage;  	// Image Object Source Path
}

ImagePreload.prototype.OnComplete	=	function() {  
	this.m_nProcessed++;
  
  if (this.m_nProcessed == this.m_nICount)
		this.m_pfnFinished();
	else
		this.m_pfnPercent (Math.round((this.m_nProcessed / this.m_nICount) * 10 ));
}

ImagePreload.prototype.OnLoad 		=	function() {  
   // 'this' pointer points to oImage Object because this function was previously assigned
   // as an event-handler for the oImage Object.
   this.bLoaded		=	true;
   this.oImagePreload.m_nLoaded++; // Access our Class with the Reference assigned previously..
   this.oImagePreload.OnComplete();
}

//-->
