<!--

// Define constants.
var INDEX_ATTRIBUTE_IMG_SRC = 0;
var INDEX_ATTRIBUTE_IMG_ALT = 1;
var INDEX_ATTRIBUTE_IMG_CLASS = 2;
var INDEX_ATTRIBUTE_IMG_STYLE = 3;
var INDEX_ATTRIBUTE_SPAN_CAPTION = 4;
var INDEX_ATTRIBUTE_SPAN_CLASS = 5;
var INDEX_ATTRIBUTE_SPAN_STYLE = 6;
var INDEX_ATTRIBUTE_SPAN_CODE = 7;

var USED_ELEMENT_INDICES = new Array();


// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Function:  randomImage
// Purpose:   Selects attributes for an image placeholder and a caption placeholder
//			  from a source element array of values.
// Arguments:
//			  imageElementID -- The ID of the <img> placeholder element
//			  captionElementID -- The ID of the <span> placeholder element
//								  for the image caption
//			  descElementID -- The ID of the <div> placeholder element for the
//							   image desc.
//			  sourceElementArray -- The array containing the source element
//									attributes
// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
function randomImage(imageElementID, captionElementID, descElementID, sourceElementArray)
{
	// The <img> element within the current DOM to display the image.
	var imageElement = document.getElementById(imageElementID);
	
	// The <span> element within the current DOM to display the image caption.
	var captionElement = document.getElementById(captionElementID);
	
	// The <div> element within the current DOM to display the image desc.
	var urlElement = document.getElementById(descElementID);
	
	// Calculate a random element index.	
	var randomIndex = Math.floor(Math.random() * sourceElementArray.length);
	
	// Ensure that the same index has not been used on this page.
	while (USED_ELEMENT_INDICES[randomIndex] != null)
	{
		randomIndex = Math.floor(Math.random() * sourceElementArray.length);
	}

	// Store the used index value.
	USED_ELEMENT_INDICES[randomIndex] = randomIndex;
	
	if (imageElement != null)
	{
	
		// Set the image element attributes.
		imageElement.src = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_IMG_SRC];
		imageElement.alt = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_IMG_ALT];
		imageElement.className = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_IMG_CLASS];
		imageElement.cssText = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_IMG_STYLE];
	}
	
	if (captionElement != null)
	{
		// Set the caption element attributes.
		captionElement.innerHTML = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_SPAN_CAPTION];
		captionElement.className = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_SPAN_CLASS];
		captionElement.cssText = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_SPAN_STYLE];
	}
	
	if (urlElement != null)
	{
		urlElement.innerHTML = sourceElementArray[randomIndex][INDEX_ATTRIBUTE_SPAN_CODE];
	}
}

-->