/* 
========================================================================================================= CREDITS
Copyright 	: Copyright (c) 2008 JPL & HARSCO. All Rights Reserved.
Author(s) 	: Larry Daughenbaugh - ldaugh@jplcreative.com 
Date    	: 12/2/2008 
Notes     	: JavaScript file for handling various events ... onLoad, onClick, etc
========================================================================================================= CHANGE LOG
Date		Name			Desc
---			---				---
========================================================================================================= BEGIN JAVASCRIPT
*/
/* ====================================================================================================== MULTIPLE ONLOAD HANDLER */
var onLoadFunctions = new Array();
var iloadFunction = 0;

// Pass each function that needs to load
function addOnLoad(func) {
    onLoadFunctions[iloadFunction] = func;
    iloadFunction++;
}
// Loops through all of the functions that were added
function loadAllFunctions() {
    for(i=0; i < onLoadFunctions.length; i++) {
        eval(onLoadFunctions[i]+"()");
    }
}
// Load all of the functions that you've set
window.onload = loadAllFunctions;

/* ====================================================================================================== LOAD MODALS */
function loadModals() {
	/* 
	* AUTOMATED
	* init_modal() SEARCHES FOR ALL MODALS AND ATTACHES EVENT LISTENERS 
	*/
	init_modal();

	/* 
	* MANUAL
	* USE THE EXAMPLE BELOW TO ATTACH EVENT LISTENERS MANUALLY, INCREMENT THE COUNTER FOR EACH ADDITION
	* THE SECOND PARAMETER SHOULD BE SET TO TRUE ONLY IF YOU NEED TO DYNAMICALLY DETERMINE THE HEIGHT/WIDTH
	*/
	modal_manual0 = document.getElementById('modal0_manual_open');
	if (modal_manual0 != null) {
		modal_manual0.onclick = function() {
			new_modal_manual0 = new modal('modal0_manual',true);
			new_modal_manual0.activate();
			return false;
		}
	}
}

/* ====================================================================================================== LOAD FLASH FILES */
function loadFlash() {
	// GLOBAL PROFILE
	if (document.getElementById('flash0') != null) {
        var flashvars = {};
        var params = { wmode: "opaque" };
        var attributes = {};

		swfobject.embedSWF("lib/swf/flash0.swf", "flash0", "800", "200", "9.0.0", "lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash0-alt') != null) {
			document.getElementById('flash0-alt').style.visibility = "visible";
		}
	}
	if (document.getElementById('flash1') != null) {
        var flashvars = {};
        var params = { wmode: "opaque" };
        var attributes = {};

		swfobject.embedSWF("lib/swf/flash1.swf", "flash1", "500", "500", "9.0.0", "lib/swf/expressInstall.swf", flashvars, params, attributes);
	}
	// HERSHEY BRAND FOOTER
	if (document.getElementById('brand-footer') != null) {
        var flashvars = { bgColor: "0xFFFFFF", xmlPath: "/general/xml/brandbar.xml", logoPath: "/general/swf/logos/" };
        var params = { wmode: "transparent" };
        var attributes = {};

		swfobject.embedSWF("/general/swf/brandbar.swf", "brand-footer", "920", "75", "9.0.0", "/latino/kitchen-with-kisses/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('brand-footer-alt') != null) {
			document.getElementById('brand-footer-alt').style.visibility = "visible";
		}
	}

}

/* ====================================================================================================== CALL FUNCTIONS TO BE LOADED */
addOnLoad("loadModals");
addOnLoad("loadFlash");

