var rslt;
var loaded = false; // Declares that images have not been loaded.

function newImg(img_src){ // Creates new image objects and loads the urls imto the browser's memory cache. Called by the loadImg function.
	if (document.images){ // Checks for the existence of the images[] array (JavaScript 1.1 and higher).
		rslt = new Image(); // Creates the image object.
		rslt.src = img_src; // Assigns the image source url to the new image object.
		return rslt; // Returns the result to the loadImg funtion.
	}
}

function loadImg(){ // Passes the urls to the newImg function. Called from the <BODY> tag: <BODY ONLOAD="loadImg();">
	if (document.images){ // Checks for the existence of the images[] array (JavaScript 1.1 and higher).

		// Begin Images Sources
		var img1 = newImg("/images/mnav_home_o.gif");
		var img2 = newImg("/images/mnav_careers_o.gif");
		var img3 = newImg("/images/mnav_company_o.gif");
		var img4 = newImg("/images/mnav_industries_o.gif");
		var img5 = newImg("/images/mnav_news_o.gif");
		var img6 = newImg("/images/mnav_ourclients_o.gif");
		var img7 = newImg("/images/mnav_resources_o.gif");
		var img8 = newImg("/images/mnav_services_o.gif");
		// End Images Sources

		loaded = true; // Lets the swapImg funtion know the images are loaded.
	}
}

// Swap images
var swapped = false; // Declares that no images are currently swapped.
var active_extension = "_o"; // Sets the filename extension for image active states.
var restore_info = new Array(); // Holds the image object names and urls for swapped images.
function swapImg(){ // Swaps and restores single or multiple images. Called by any event handler, usually onMouseOver.
	if (document.images && loaded == true && swapped == false){ // Performs if the images[] array (JavaScript 1.1 and higher) exists and if the loadImg function has completed.
		for (var i = 0; i < swapImg.arguments.length; i++){ // Loops for each set of two arguments (image name and url) passed by the event handler.
			restore_info[i * 2] = swapImg.arguments[i]; // Assigns the image name to the restore_info[] array.
			restore_info[i * 2 + 1] = document[swapImg.arguments[i]].src; // Assigns the original url to the restore_info[] array.
			document[swapImg.arguments[i]].src = document[swapImg.arguments[i]].src.substring(0, document[swapImg.arguments[i]].src.lastIndexOf('\.')) + active_extension + document[swapImg.arguments[i]].src.substring(document[swapImg.arguments[i]].src.lastIndexOf('\.')); // Assigns the new url to the image object.
		}
	} else if (document.images && loaded == true && swapped == true){ // Restores all swapped but non-locked images to their original urls. Called by any event handler, usually onMouseOut.
		for (var i = 0; i < restore_info.length; i += 2) document[restore_info[i]].src = restore_info[i + 1]; // Assigns the original url to the image object.
		restore_info = new Array(); // Resets the saved restore information.
	}
	swapped = !swapped; // Flips the swapped flag between swap and restore functionality.
}

// Open new window with event-specified parameters
function newWindow(filePath,winName,winProperties){
	var newWin = window.open(filePath,winName,winProperties);
	newWin.focus();
}

function openPopup(strURL) {
	var winName = "sh_popup";
	var winProps = "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');"
	newWindow(strURL, winName, winProps);
}
