
/*  takes an array of image names, caches them locally, and returns an object
    of them.  Note, you MUST get something back from this function for the
    images to actually cache in the browser, ie:

    var tmp = cache_images(image_array);

    in your code.  */

function cache_images(image_array)
{
	// create an object for the images
	var cache_images = {};

	for (i = 0; i < image_array.length; i++)
	{
		// get the image name
		image_name = new String(image_array[i]);
		name_array = image_name.split("/");
		image_name = new String(name_array[name_array.length - 1]);
		image_name = image_name.substr(0, image_name.lastIndexOf("."));

		// add it to the cache_images object
		cache_images[image_name] = new Image();
		cache_images[image_name].src = image_array[i];
	}

	return cache_images;
}

// swap out the background image of an element
function change_element_bg(filename, element)
{
	document.getElementById(element).style.backgroundImage = "URL(" +filename +")";
}

function swap_src(element, image)
{
	document.getElementById(element).src = image;
}
