<!--

// Preloads all images passed in as arguments (filenames).
function preloadImages() {
	// Check if there are images in the document.
	if (document.images) {
		// Check if there was an array created already.
		if (document.g_preImages == null) {
			document.g_preImages = new Array();
		}
		var lArrayLength = document.g_preImages.length;
		var i, strArgs = preloadImages.arguments;
		// Loop through all the args and create a new image for each.
		for (i = 0; i < strArgs.length; i++) {
			document.g_preImages[i + lArrayLength] = new Image;
			document.g_preImages[i + lArrayLength].src = strArgs[i];
		}
	}
}

// Tries to find the HTML object with the name passed in.
function getObjectReference(Name) {
	// Try getting the object straight from the document. 
	var i, objReference = document[Name];
	// If not found yet, try getting from the all collections.
	if (objReference == null) {
		if (document.all) {
			objReference = document.all[Name];
		}
	}
	// If not found yet, try getting from the forms collection.
	if (objReference == null) {
		for (i = 0; i < document.forms.length; i++) {
			objReference = document.forms[i][Name];
		}
	}
	// If not found yet, try finding by ID.
	if (objReference == null) {
		if (document.getElementById) {
			objReference = document.getElementById(Name);
		}
	}
	// If not found yet, try finding by NAME.
	if (objReference == null) {
		if (document.getElementByName) {
			objReference = document.getElementByName(Name);
		}
	}
	return objReference;
}

// Takes in pairs of arguments, the HTML image object name and a filename,
// and replaces the image in the object with the new file.
function swapImage() {
	var i, imgObject, lImageIndex = 0, strArgs = swapImage.arguments;
	// Create a new array for the current image swaps.
	document.g_currentSwaps = new Array();
	// Loop through all the pairs of arguments.
	for (i = 0; i < (strArgs.length - 1); i += 2) {
		// Get the image object reference.
		imgObject = getObjectReference(strArgs[i]);
		// Check if the reference is valid.
		if (imgObject != null) {
			// Check if there isn't already an original image set.
			if (imgObject.origSrc == null) {
				imgObject.origSrc = imgObject.src;
			}
			// Set the new source for the image.
			imgObject.src = strArgs[i + 1];
			// Save the image object in the global array for swapping back. 
			document.g_currentSwaps[lImageIndex] = imgObject;
			lImageIndex++;
			
		}
	}
}

// Restores all images in the current global array.
function restoreImage() {
	var i, imgObjects = document.g_currentSwaps;
	// Check if the array is valid.
	if (imgObjects != null) {
		// Loop through all the objects in the array.
		for (i = 0; i < imgObjects.length; i++) {
			// Check if the object has an original source and swap back.
			if (imgObjects[i].origSrc != null) {
				imgObjects[i].src = imgObjects[i].origSrc;
			}
		}
	}
}

// Returns a string with a link tag to an email.
// Used to reduce spam and other internet threats.
function createEmailTag(Front, Domain, Extension, Display) {
	if (Display) {
		emailTag = "<A HREF='mailto:" + Front + "@" + Domain + "." + Extension + "'>" + Display + "</A>";
	}
	else {
		emailTag = "<A HREF='mailto:" + Front + "@" + Domain + "." + Extension + "'>" + Front + "@" + Domain + "." + Extension + "</A>";
	}
	return emailTag;
}

//-->
