/* 
================================================================================================================================ CREDITS
Copyright 	: Copyright (c) 2010 SOS. All Rights Reserved.
Author(s) 	: Larry Daughenbaugh - ldaughenbaugh@systemsynapse.com
Date      	: 04/08/2010
Notes     	: JavaScript file for handling various events ... onLoad, onClick, etc
================================================================================================================================ CHANGE LOG
Date		Name			Desc
---			---				---
================================================================================================================================ BEGIN JAVASCRIPT
*/

/* ============================================================================================================================= MULTIPLE ONLOAD HANDLER */

var arr_functions = new Array();
var iload = 0;

// Pass each function that needs to load
function add_on_load(func) {
    arr_functions[iload] = func;
    iload++;
}
// Loops through all of the functions that were added
function loadAllFunctions() {
    for(var i = 0; i < arr_functions.length; i++) {
        eval(arr_functions[i]+"()");
    }
}
// Load all of the functions that you've set
window.onload = loadAllFunctions;

/* ============================================================================================================================= CALL FUNCTIONS TO BE LOADED */

add_on_load("dropdown_controller");
add_on_load("load_modals");

/* ============================================================================================================================= SHOW/HIDE SUB-NAV ITEMS */

function dropdown_controller() {
	// FOR IE6: UPDATE LI CLASS NAME SO THAT THE SUB-LISTS ARE DISPLAYED
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("nav");
		for (var 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", ""); }
			 }
		}
	}

	// KEEP HOVER STATE OF THE LINK ACTIVE AS USER LOOKS AT SUB-NAVIGATION
	function showDropDown() {
		document.getElementById(this.id.replace("_sub","")).className = "active";
	}
	function hideDropDown() {
		document.getElementById(this.id.replace("_sub","")).className = "";
	}
	
	var i = 0;
	var ddBase = "nav";
	var ddSuffix = "_sub";
	
	if (document.getElementById(ddBase+i) != null) {
		while(document.getElementById(ddBase + i + ddSuffix)) {
			document.getElementById(ddBase + i + ddSuffix).onmouseover = showDropDown;
			if (document.getElementById(ddBase+i).className != 'active') {
				document.getElementById(ddBase + i + ddSuffix).onmouseout = hideDropDown;
			}
			i++;
		}
	}
}

/* ============================================================================================================================= LOAD MODALS */

function load_modals() {
	if (typeof init_modal == 'function') init_modal();
}

