var numPics = 0;					// Declare number of images to be zero

/*
Function to preload images so there is not a delay in changing image on mouse events.
2D array, each entry has a name, two images and a boolean initial display condition.
True == on, false == off
*/

function preload(picName,pic1,pic2,initial)
{
	if (browserOK)
	{
		picsArray[numPics] = new Array(4);
		picsArray[numPics][0] = new Image();
		picsArray[numPics][0].src = pic1;
		picsArray[numPics][1] = new Image();
		picsArray[numPics][1].src = pic2;
		picsArray[numPics][2] = picName;
		picsArray[numPics][3] = initial;
		numPics++;
	}
}

/*
Function to set the given object to the on image.  Sets this objects display condition to true
*/

function highlight(name)
{
	if (browserOK)
	{
		for (i = 0; i < numPics; i++)
		{
			document.images[picsArray[i][2]].src = picsArray[i][0].src;  		// Set all object to off
			picsArray[i][3] = false;  						// Set display conditions to false

			if (picsArray[i][2] == name)
			{
				document.images[picsArray[i][2]].src = picsArray[i][1].src;	// Set parameterised object to on
				picsArray[i][3] = true;   					// Set display condition to true
			}
		}
	}
}

/*
Function to set the given object to the on image.   Retains objects display condition
*/

function on(name)
{
	if (browserOK)
	{
		for (i = 0; i < numPics; i++)
		{
			if (picsArray[i][2] == name)
			{
				document.images[picsArray[i][2]].src = picsArray[i][1].src;
			}
		}
	}
}

/*
Function to set the objects to the off image.   Sets the object whose display condition is true to the on image.
*/

function off(name)
{
	if (browserOK)
	{
		for (i = 0; i < numPics; i++)
		{
			document.images[picsArray[i][2]].src = picsArray[i][0].src;
			if (picsArray[i][3])
			{
				document.images[picsArray[i][2]].src = picsArray[i][1].src;
			}
		}
	}
}

/*
Function to set all images with a display condition of true to on.
*/

function seton()
{
	if (browserOK)
	{
		for (i = 0; i < numPics; i++)
		{
			if (picsArray[i][3])
			{
				document.images[picsArray[i][2]].src = picsArray[i][1].src;
			}
		}
	}
}
