/* 
================================================================================================================================ CREDITS
Copyright 	: Copyright (c) 2009 JPL & The Hershey Company. All Rights Reserved.
Author(s) 	: Larry Daughenbaugh - ldaugh@jplcreative.com
Date      	: 10/2/2009
Notes     	: JavaScript file for handling various events ... onLoad, onClick, etc
================================================================================================================================ CHANGE LOG
Date		Name			Desc
---			---				---
================================================================================================================================ BEGIN JAVASCRIPT
*/
if (window.jQuery){
	$(document).ready(function(){
		// jquery.innerfade
		$('.innerfade').innerfade({
		//	runningclass: 'innerfade',	// class applied to conatiner: innerfade
			animationtype: 'fade',		// fade, slide
			type: 'sequence',			// sequence, random, random_start
			speed: 1500,				// fade speed: slow, normal, fast
			timeout: 5000,				// time between fades in miliseconds
			containerheight: ''			// auto
		});
	});
}

/* ============================================================================================================================= 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;

/* ============================================================================================================================= DROPDOWN JUMP MENU */

function jumpMenu(targ,selObj,restore){
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
}

/* ============================================================================================================================= CALL FUNCTIONS TO BE LOADED */

addOnLoad("preload_images");
addOnLoad("dropdown_controller");
addOnLoad("load_flash");

/* ============================================================================================================================= IMAGE PRELOADER */

function preload_images() {
    // Array of any images you want to preload 
    var ImagesToPreload = new Array();
        ImagesToPreload[0] = "/lib/img/logos/muana-loa.png";

	var graphics = new Array();
    for (iLoad=0; iLoad < ImagesToPreload.length; iLoad++) {
        graphics[iLoad] = new Image();
        graphics[iLoad].src = ImagesToPreload[iLoad];
    }
}

/* ====================================================================================================== SHOW/HIDE SUB-NAV ITEMS */

function dropdown_controller() {
	var i = 0;
	// FOR IE6: UPDATE LI CLASS NAME SO THAT THE SUB-LISTS ARE DISPLAYED
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i < navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() { this.className += " iehover"; }
				node.onmouseout = function() { this.className = this.className.replace(" iehover", ""); }
			}
		}
	}
}

/* ============================================================================================================================= LOAD FLASH FILES */

function load_flash() {
	if (document.getElementById('flash-callout') != null) {
        var flashvars = {};
        var params = { wmode: "transparent", base: "." };
        var attributes = {  };

		swfobject.embedSWF("/lib/swf/MaunaLoaSlideShow.swf", "flash-callout", "571", "424", "9.0.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash-callout-alt') != null) document.getElementById('flash-callout-alt').style.visibility = "visible";
	}
	if (document.getElementById('flash-footer') != null) {
        var flashvars = {};
        var params = { base: "." };
        var attributes = { };

		swfobject.embedSWF("/lib/swf/footer_preloader.swf", "flash-footer", "861", "98", "9.0.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash-footer-alt') != null) document.getElementById('flash-footer-alt').style.visibility = "visible";
	}
	if (document.getElementById('flash-video-visitor') != null) {
        var flashvars = { video: "VisitorCenter" };
        var params = { base: "." };
        var attributes = { };

		swfobject.embedSWF("/lib/swf/video.swf", "flash-video-visitor", "324", "206", "9.0.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash-video-alt') != null) document.getElementById('flash-video-alt').style.visibility = "visible";
	}
	if (document.getElementById('flash-video-environment') != null) {
        var flashvars = { video: "AboutUs_Environment" };
        var params = { base: "." };
        var attributes = { };

		swfobject.embedSWF("/lib/swf/video.swf", "flash-video-environment", "324", "206", "9.0.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash-video-alt') != null) document.getElementById('flash-video-alt').style.visibility = "visible";
	}
	if (document.getElementById('flash-video-health') != null) {
        var flashvars = { video: "AboutUs_Health" };
        var params = { base: "." };
        var attributes = { };

		swfobject.embedSWF("/lib/swf/video.swf", "flash-video-health", "324", "206", "9.0.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash-video-alt') != null) document.getElementById('flash-video-alt').style.visibility = "visible";
	}
}


