
function initFreestyle()
{
    var liCount = 0;
    var subnav, subnavVisible;
    var nav = document.getElementById("nav");
    for (var i=0; i<nav.childNodes.length; i++)
    {
        nav.childNodes[i].onmouseover = showNav;
    }
    // highlight the initial Level 1 tab
    var navUL = document.getElementById("nav");
    var navLI = navUL.childNodes;
    for( i=0; i < navLI.length; i++ )
    {
        if( navLI[i].nodeName == "LI" )
        {
            liCount++;
            if( liCount == level1Selected + 1 )
            {
                navLI[i].className = "active";
                subnavVisible = navLI[i].getElementsByTagName("ul");
                subnavVisible[0].className = "visible";
            }
            else
            {
                subnav = navLI[i].getElementsByTagName("ul");
                subnav[0].className = "";
            }
        }
    }
    if( level2Selected != 9 )
    {
        // highlight the initial Level 2 tab
        var lvl2LI = subnavVisible[0].getElementsByTagName("li");
        lvl2LI[level2Selected].childNodes[0].id = lvl2LI[level2Selected].childNodes[0].id + "-on";
    }
}
function showNav()
{
    var navUL = this.parentNode;
    var subUL = navUL.getElementsByTagName("ul");
    var navLI = navUL.getElementsByTagName("li");
    
    for( var i=0; i<navLI.length; i++ )
    {
        if( navLI[i].className == "active" )
        {
            navLI[i].className = "";
        }
    }
    for( var i=0; i<subUL.length; i++ )
    {
        if( subUL[i].className == "visible" )
        {
            subUL[i].className = "";
        }
    }
   
    var subnav = this.getElementsByTagName("ul");
    subnav[0].className = "visible";
    this.className = "active";
}
window.onload = initFreestyle;
