ImagePreloader = function() {

	var imgList;
	
	this.imgList = new Array();
}

ImagePreloader.prototype =
{

// Preloads images from a list of image file names
preloadImageList:function(ilist) {
	for(var n = 0; n < ilist.length; n++) {
	  this.preloadImage(ilist[n]);
	}
},

// Preloads an image
preloadImage:function(sname) {
	if(this.getImageIndex(sname) >= 0) {  // Image already preloaded
	  return;
	}
	  
	var img = new Image();
	var ss = sname;
	if(ss[0] != '/')
	  ss = GetRootPath() + ss;
	img.src = ss;
	
	this.imgList.push([sname, img]);
},

// Return the index of an image in the preloaded list
getImageIndex:function(sname) {
	for(var n = 0; n < this.imgList.length; n++) {
	  if(this.imgList[n][0] == sname)
	    return(n);
	}
	// Not found
	return -1;
}

}
