function Preload(images) {
	// initial settings

	this.images = images;			// store the array
	this.nLoaded = 0 ;			// number loaded
	this.loadedImages = new Object() ;	// booleans for images
	this.firstImage = "" ;			// the first image to load
	this.currentImage = "" ;		// the current image being loaded
	this.nextImage = new Object() ;		// array containing pointers to next image
	this.interrupt = false ;		// whether user has interrupted or not
	this.interruptImageID = 0 ;		// the ID of the interrupted image click

	// getting count (we have to iterate since jscript assoc. arrays aren't true Arrays)
	var count = 0;
	var lastKey = false ;
	for ( i in images ) {
		if ( count == 0 ) {
			this.firstImage = i ;
		}
		count++ ;
		this.loadedImages[i] = false ;
		if ( lastKey != false ) {
			this.nextImage[lastKey] = i ;
		}
		lastKey = i ;
	}
	// set count
	this.nImages = count ;

	// preload the first image
	this.preloadImage( this.firstImage ) ;
}
Preload.prototype.preloadImage = function( imageID ) {
	if ( this.interrupt == false ) {
		this.currentImage = imageID ;
		oImage = new Image() ;
		oImage.onload = Preload.prototype.onload ;
		// set a reference back to parent object
		// oImage.parent = this ;
		oImage.src = this.images[imageID] ;
	}
}
Preload.prototype.onload = function() {
	// for Safari compatibility, we use absolute references in this function
	if ( !ip || ip == undefined ) return ;
	ip.nLoaded++ ;
	ip.loadedImages[ip.currentImage] = true ;
	if ( ip.interrupt == false ) {
		// see if there's another image
		var next = ip.nextImage[ip.currentImage] ;
		if ( next ) {
			// ip.preloadImage(next) ;
			setTimeout("ip.preloadImage(ip.nextImage[ip.currentImage])", 0) ;
		}
	}
	/*
	// when Safari treats the `this` reference normally,
	// this code should be implemented to reduce dependency
	// on global variables (which might be reassigned by bad developers)
	this.parent.nLoaded++ ;
	this.parent.loadedImages[this.parent.currentImage] = true ;
	div = document.getElementById('imageOutput' + this.parent.currentImage) ;
	div.innerHTML = "loaded!" ;
	if ( this.parent.interrupt == false ) {
		// see if there's another image
		var next = this.parent.nextImage[this.parent.currentImage] ;
		if ( next ) {
			this.parent.preloadImage(next) ;
		}
	}
	*/
}
Preload.prototype.resume = function() {
	if ( this.nLoaded != this.nImages ) {
		this.preloadImage(this.currentImage) ;
	}
}
function ImagePreload( imageID, loaded ) {
	// load the intervening image
	var tempImage = new Image();
	tempImage.onload = ImagePreload.prototype.onload ;
	tempImage.display = ImagePreload.prototype.display ;
	// Safari compatibility: store imageID in a global object
	ip.interruptImageID = imageID ;

	if ( loaded ) {
		this.display() ;
	} else {
		tempImage.src = PreloadList[imageID] ;
	}
}
ImagePreload.prototype.onload = function() {
	ip.loadedImages[ip.interruptImageID] = true ;
	// Safari compatibility: call global function
	// instead of `this` method
	displayImage(ip.interruptImageID) ;
}
ImagePreload.prototype.display = function() {
	ip.interrupt = false ;
	ip.resume() ;
	PreloadSwap(ip.interruptImageID) ;
	return ;
}
function PreloadSwap( imageID ) {
	if ( PreloadImg != "" ) {
		var thisImage = document.images[PreloadImg] ;
		thisImage.src = PreloadList[imageID] ;
	} else if ( PreloadDiv ) {
		var thisDiv = document.getElementById(PreloadDiv) ;
		thisDiv.innerHTML = "<img alt=\"\" src=\"" + PreloadList[imageID] + "\" alt=\"\" />" ;
	}
	return;
}
function displayImage( imageID ) {
	// make sure page & script have been initialized
	if ( typeof(ip) == "undefined" ) {
		//ie 6.0 core error stops page from loading?
		//alert('Please wait until the thumbnails are all loaded.') ;
		//window.location.reload() ;
		return ;
	}

	// we're good to go
	ip.interrupt = true ;
	if ( ip.nImages == ip.nLoaded ) {
		PreloadSwap(imageID) ;
		return ;
	} 
	var temp = new ImagePreload( imageID, ip.loadedImages[imageID] ) ;
	return ;
}
