var selectedPrimary = '';
var selectedSecondaryContainer = '';

var hoverPrimary = '';
var hoverSecondaryContainer = '';

var menuTimer;

function showmenu(element) {
    
    var element = String(element.id);
    //alert(typeof(element));
    // move to hidemenu when appropriate
    selectedPrimary = element;
    selectedSecondaryContainer = element + "_secondary";
    
    if (hoverPrimary != '') {
        off_assignment(document.getElementById(hoverPrimary));
        off_assignment(document.getElementById(selectedPrimary));
        
        document.getElementById(hoverSecondaryContainer).style.display = "none";
        document.getElementById(selectedSecondaryContainer).style.display = "block";
    }
    hoverPrimary = element;
    hoverSecondaryContainer = element+"_secondary";
    flip_assignment(document.getElementById(selectedPrimary));
    //element.className = element.className.replace("_on", "");

    var previous = document.getElementById(selectedSecondaryContainer);
    previous.style.display = "none";

    document.getElementById(hoverSecondaryContainer).style.display = "block";
    if (hoverSecondaryContainer != selectedSecondaryContainer)
        document.getElementById(selectedSecondaryContainer).style.display = "none";
}

function start_menu_timeout() {
    if ((hoverPrimary != selectedPrimary) && (menuTimer == null))
        menuTimer = setTimeout("reset_menu()", 1000);
}

function cancel_menu_timeout() {
    if ((hoverPrimary != selectedPrimary) && (menuTimer != null)) {
        clearTimeout(menuTimer);
        menuTimer = null;
    }
}

function reset_menu() {
    if (hoverPrimary != selectedPrimary) {
        document.getElementById(hoverSecondaryContainer).style.display = "none";
        document.getElementById(selectedSecondaryContainer).style.display = "block";

        flip_assignment(document.getElementById(selectedPrimary));
        flip_assignment(document.getElementById(hoverPrimary));
    }
}

function flip_assignment(element) {
    if (element.className.indexOf('MeNMon') !=-1) {
        //element.className = element.className.replace("_on", "");
        element.className = "";
    } else {
        //element.className = element.className + "_on";
        element.className = "MeNMon";
    }
}

function off_assignment(element) {
    //element.className = element.className.replace("_on", "");
    element.className = "";
}

var MeNma=new Array();
var MeNmt=new Array();
var inOutCount = 0;
var defaultTab;

function init_nav()
{
//define over and down image suffix
var Iv = "_f2";
var Id = "_f3";
var i,j,x,k,d,nV,tB,tbs,iM,im,ts,tA,sA,sL,nA=new Array();

//Get the active tab/submenu item
var urlParts = window.location.href.split(/\/+/);
var urlTabName, tabId, tabUrlParts, tabName;
if ((urlParts.length > 2) && (urlParts[2] != '')) {
    urlTabName = urlParts[2];
}
document.MeNmsw=new Array();
MeNma=arguments;
if(!document.getElementById||document.MeNmf){return;}
tb=document.getElementById('MeNM');
if(!tb){return;}
//tb.onmouseout=P7_TBMclose;	//*
tB=document.getElementById('MeNM');
nV=document.getElementById('MeNMroot');
if(!nV||!tB){return;}
tA=nV.getElementsByTagName('A');
j=0;


//If the current page does not match a tab then show home
defaultTab = 'nav_home';

//var navContainer = document.getElementById('navcontainer');
//navContainer.onmouseout=P7_TBMallout
//Select the current tab
showmenu(document.getElementById(defaultTab));
//P7_TBMovr(defaultTab);
}
