pageLoaded = 0;				// Prevent access to layers until they're loaded

delayedPreloadImages = new Array();
onloadFunctions = new Array();

// Set the pageLoaded variable to denote that the layers are ready to be used 
function doLoadProc() {
	pageLoaded = 1;
	
	for (i in delayedPreloadImages) {
		if (typeof delayedPreloadImages[i] != "function") {
			eval(i + " = preload('" + delayedPreloadImages[i] + "')");
		}
	}
	
	for (i in onloadFunctions) {
		if (i != "getIndex") {
			onloadFunctions[i]();
		}
	}
}

// swapImg - swaps an image for another that has already been preloaded.
function swapImg(imgName, preloadedImg) {
	if (document[imgName]) {
		document[imgName].src = preloadedImg.src;
	}
}

function preload(imgSrc) {
	img = new Image();
	img.src = imgSrc;
	return img;
}

function delayedPreload(imgName, imgSrc) {
	if (!pageLoaded) {
		eval(imgName + " = new Image()");
		delayedPreloadImages[imgName] = imgSrc;
	} else {
		eval(imgName + " = preload('" + imgSrc + "')");
	}
}

function addOnLoad(func) {
	onloadFunctions[onloadFunctions.length] = func;
}

eWepCustomWindowObj = null;
function eWEPCustomWindow(url, width, height) {
	eWepCustomWindowObj = window.open(url, "eWEPCustomWin", "width=" + width + ",height=" + height + ",scrollbars=1,resizable=1");
	return false;
}

showNutrition = function() {
	showLayer("hideDhtml");
	showLayer("nutritionLabel");
}
hideNutrition = function() {
	hideLayer("nutritionLabel");
}
