
/* ===== Start Navigation ===== */

var onID = "";
var hiID = "";
var globalNav;
var globalNavItems;

function hideSubNavs() {
    // Turn off all subnavs
    $("sHome").style.display="none";
    $("sTan").style.display="none";
    $("sBlue").style.display="none";
    $("sOrange").style.display="none";
    $("sRose").style.display="none";
    $("sYellow").style.display="none";
    $("sGreen").style.display="none";
    $("sLav").style.display="none";

}

function showSubNav(id) {

	hideSubNavs();

    thisSubNav = id.substring(1);
    hiID = 'g'+thisSubNav;
    // Turn off all global nav states, except current on state. Ensures current top level item always stays "lit"
    var globalNav = $('globalNavItems');
    var globalNavItems = globalNav.childElements();
    globalNavItems.each(function(item) {
        thisID = item.identify();
        if(thisID != onID) {
            item.removeClassName('hi');
            }
        });

    // Turn highlighted nav and subnav on
    $(hiID).addClassName('hi');
    thisSubNav = thisSubNav.toLowerCase();
    $(id).style.display="block";
    }


function defaultNavState() {
    // Reverts to page's default global nav and subnav state
    globalNavItems.each(function(item) {
        if(item.hasClassName('on')) {
            onID = item.identify();
            subNavID = "s"+ onID.substring(1);
            showSubNav(subNavID);
            }
        });
        
	if(onID == "") {
		// No top level navigation is "on" so mimic nav state of home page
		showSubNav("sHome");
		}
    }

function initGlobalNav() {
	if($('globalAnnounce')) {  // Check to see if there IS a global announcement
		cookieGA = getCookie('hideELCAGA'); // Check for hideELCAGA cookie. If true, don't display globalAnnounce div.
		if(cookieGA != "1") {
			$('globalAnnounce').style.display="block";
			}
		}
		
    globalNavItems = $('globalNavItems').childElements();
    defaultNavState();
    
    
    globalNavItems.each(function(item) {
		
		navText = item.down();
        // mouseover event to trigger the call to showSubNav()
        Event.observe(navText,'mouseover',function() {
            thisID = item.identify();
            thisSubNav = thisID.substring(1);
            thisSubNav = thisSubNav.toLowerCase();
            subNavID = "s"+ thisID.substring(1);
            showSubNav(subNavID);
            }.bind(item));
    
        // mouseout event to remove highlight state from top nav if item is not current on-state
        
        Event.observe(navText,'mouseout',function() {
            thisID = item.identify();
            if(onID != thisID && hiID != thisID) {
                $(thisID).removeClassName('hi');
                }
            }.bind(item));
        });

    // Reset global and subnav to default page state when user mouses over other areas
    resetZone = new Array();
    resetZone[0] = "globalSiteHeader";
    resetZone[1] = "globalContent";
    resetZone[2] = "logo";
    resetZone[3] = "sectionIntro";
    resetZone[4] = "rightside";	
    resetZone[5] = "contentwide2";
	
    resetZone.each(function(zone) {
        if($(zone)) {
            Event.observe($(zone),'mouseover',function() {
                defaultNavState();
                });
            }
        });
    }

Event.observe(window,'load',initGlobalNav);

/* ===== End Navigation ===== */



