
//NOTE:
//The functions PreloadMainNavigation() and PreloadSecondaryNavigation() should
//be in this file, but due the details of WebObjects and image locations
//the functions were moved into the HTML file that contains the inline images.

//this is the constructor for the rollover image class
function RolloverImage(off_image_source, on_image_source) {
	//create and load the off image
	this.offImage = new Image();
	this.offImage.src = off_image_source;
	
	//create and load the on image
	this.onImage = new Image();
	this.onImage.src = on_image_source;		
}

//this creates a handle to a rollover image object
function CreateRolloverImage(rollover_name, off_image_source, on_image_source) {
	window["rollover_" + rollover_name] = new RolloverImage(off_image_source, on_image_source);
}

//this rolls an image on
function ImageOver(rollover_name) {
	if (window["rollover_" + rollover_name])
	{	
		var image = GetImageObject(rollover_name);
		
		if (image)
			image.src = window["rollover_" + rollover_name].onImage.src;
	}
}

//this rolls an image off
function ImageOut(rollover_name) {
	if (window["rollover_" + rollover_name])
	{
		var image = GetImageObject(rollover_name);
		
		if (image)
			image.src = window["rollover_" + rollover_name].offImage.src;
	}
}

//this gets a reference to the image with the given name
function GetImageObject(imageName)
{
	var image;
	
	//if the image is found in the document.images collection, reutrn the image
	//if it is not, and this is NN4, look in the first level of layers for the image
	if (document.images[imageName])
	{
		image = document.images[imageName];
	}
	else if (document.layers)
	{
		for (var i = 0; i < document.layers.length; i++)
		{
			if (document.layers[i].document.images[imageName])
			{
				image = document.layers[i].document.images[imageName];
				break;
			}
		}
	}
	
	return image;
}


//this sets an image to be "always on"
function SetImageAlwaysOn(rollover_name) {
	//set the off source to the on source
	if (window["rollover_" + rollover_name]) {
		window["rollover_" + rollover_name].offImage.src = window["rollover_" + rollover_name].onImage.src;
	}
	
	//roll the section
	ImageOver(rollover_name);
}
