// Rollover Manager
//
// Copyright (c) 2003 by Nationwide Planning Associates, Inc. All rights reserved.




// Rollover
//
// Contains a master list of rollovers and functions for operating on them.
// All images are preloaded when the object is created.

// State "Constants"
var normalState 	= 0;
var overState 		= 1;
var clickedState 	= 2;

function Rollover()
{
	var i;
	var a;
	var p;
	var arg;

	this.imageList = new Array();
	
	// Initialize loop variables
	i = 0;
	a = 0;
	for (p = 0; p < Rollover.arguments.length; p++) // Move through each argument in the constructor
	{
		arg = Rollover.arguments[p];		
		if (i == 0)
		{
			this.imageList[a] = new rm_rollover(); // Create a new image set
		}

		if (arg) // If this is not a dummy argument
		{
			switch (i) 
			{
				case 0:	// First Argument
					this.imageList[a].buttonName = arg;
				break;
				case 1:	// Second Argument
					this.imageList[a].normal = new Image(); // Set the normal image
					this.imageList[a].normal.src = arg;
				break;
				case 2:	// Third Argument
					this.imageList[a].over = new Image(); // Set the hover image
					this.imageList[a].over.src = arg;
				break;
				case 3:	// Fourth Argument
					this.imageList[a].click = new Image(); // Set the clicked image
					this.imageList[a].click.src = arg;
				break;
			}
		}		
		

		// Increment and adjust loop variables
		i++;
		if (i > 3)
		{
			i = 0;
			a++;
		}
	}
	
	return true;
}

// rm_rollover
//
// Rollover object, containing "normal", "over", and "clicked" images.

function rm_rollover()
{
	// Initialize and null out instance variables
	this.buttonName = "";
	this.normal = 0;
	this.click = 0;
	this.over = 0;
}

// Changes image state

function changeState(button, state)
{
	for (i = 0; i < button.imageList.length; i++)
	{
		with (button.imageList[i])
		{
			switch (state)
			{
				case normalState:
					document[buttonName].src = normal.src;
				break;
				case overState:
					document[buttonName].src = over.src;
				break;
				case clickedState:
					document[buttonName].src = click.src;
				break;
			}
		}
	}
	
	return true;
}