/* 
========================================================================================================= CREDITS
Copyright 	: Copyright (c) 2009 JPL & Berlitz International, Inc. All Rights Reserved.
Author(s) 	: Larry Daughenbaugh - ldaugh@jplcreative.com
Date      	: 4/2/2009
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;

/* ====================================================================================================== 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("loadFlash");
addOnLoad("loadToolTips");

/* ====================================================================================================== IMAGE PRELOADER */
function preloadImages() {
    // Array of any images you want to preload 
    var ImagesToPreload = new Array();
        ImagesToPreload[0] = "";

	var graphics = new Array();
    for (iLoad=0; iLoad < ImagesToPreload.length; iLoad++) {
        graphics[iLoad] = new Image();
        graphics[iLoad].src = ImagesToPreload[iLoad];
    }
}

/* ====================================================================================================== LOAD FLASH FILES */
function loadFlash() {
	// HOME PAGE
	if (document.getElementById('flash-test') != null) {
        var flashvars = {};
        var params = { wmode: "transparent" };
        var attributes = {};

		//swfobject.embedSWF("/lib/swf/needflashfile.swf", "flash-test", "735", "301", "9.0.0", "/lib/swf/expressInstall.swf", flashvars, params, attributes);
		if (document.getElementById('flash-test-alt') != null) {
			document.getElementById('flash-test-alt').style.visibility = "visible";
		}
	}
}

/* ====================================================================================================== SHOW TOOLTIPS */
function loadToolTips() {
	var tipObj = document.getElementById("tooltip");
	
	function evalToolTip(divId) {
		var helpText = eval(divId.replace("help","helpText"));
		showTip(tipObj, helpText);
	}

	function countContainers(helpText) {                                    
        i = 0;
        while(document.getElementById(helpText + i)) { i++; }
        return i;
    }
    var ContainerListeners = countContainers("help");
	if (ContainerListeners > 0) {
        var i = 0;
        var arrContainerListners = new Array();

        while(i < ContainerListeners) {
			var temp = document.getElementById('help'+i);
			temp.onmouseover = function() {
				enabletip = true;
				evalToolTip(this.id);
    	    }
			temp.onmouseout = function() {
				enabletip = false;
				tipObj.style.visibility = "hidden";
				tipObj.style.left = "-9999px";
    	    }
        	i++;
		}
	}
}

