/* 
	Script: image_load.js
	Copyright: Fishnet NewMedia (c) 2007
	Create: 11.14.07
	Description:  

		This script requires the configuration script: image_conf.js

		This script creates a new object (associative array) 
		called "preloads" and creates new properties in the
		preloads object based on each name in the "names"
		array located in the "image_conf.js" file. Each new
		properties' value is set to another property/value
		pair whose property name is set to either "over" or
		"out", and whose value is an image object, created
		by the LoadIMG() function, used to store the preloaded
		image. To preload mouse action images:

		   o create two images who filenames are:

			 - "NAME-over.gif" or "NAME-over.jpg" (over)
			 - "NAME.gif" or "NAME.jpg" (out)

			 where "NAME" is to be replaced with any name you want.

		   o add the "NAME" value you chose to the "names" array

		The preloaded application will load both images into the 
		browser's cache.

		To reference the image object, use: image_cache[name][action].src

			For example:

			image_cache["NAME"]["over"].src
			
		If the images are not in the same folder as this script,
		set the variable "image_path" in the "image_conf.js" file.

*/

// Create an object literal to be used as an associative 
// array for storing image name/action image objects
var image_cache = {};

// Create nested object literals to be used as associative
// arrays for each name defined in the "img_names" array
for (i in image_preloads){
	image_cache[image_preloads[i][0]] = { 
		over: LoadIMG(image_preloads[i][0] + "-over" + image_preloads[i][1]), 
		out: LoadIMG(image_preloads[i][0] + image_preloads[i][1])
	};
}

// Function creates a new image object and returns object to caller
function LoadIMG(name) {
    var new_image = new Image();
    new_image.src = image_path + name;
    return new_image;
}
