var lCurrentNav = null;

$(document).ready(function() {

    $(".btn-about a").attr("href", "javascript:");
    $(".btn-admission a").attr("href", "javascript:");
    $(".btn-academics a").attr("href", "javascript:");
    $(".btn-student a").attr("href", "javascript:");
    $(".btn-alumni a").attr("href", "javascript:");
    $(".btn-news a").attr("href", "javascript:");
    $(".btn-giving a").attr("href", "javascript:");
    $(".btn-connect a").attr("href", "javascript:");

    $(".btn-about").click(function() { toggleTopLevelNav("#about", $(this)); });
    $(".btn-admission").click(function() { toggleTopLevelNav("#admission", $(this)); });
    $(".btn-academics").click(function() { toggleTopLevelNav("#academics", $(this)); });
    $(".btn-student").click(function() { toggleTopLevelNav("#student", $(this)); });
    //$(".btn-athletics").click(function() { toggleTopLevelNav("#athletics", $(this)); });
    $(".btn-alumni").click(function() { toggleTopLevelNav("#alumni", $(this)); });
    $(".btn-news").click(function() { toggleTopLevelNav("#news", $(this)); });
    $(".btn-giving").click(function() { toggleTopLevelNav("#giving", $(this)); });
    $(".btn-connect").click(function() { toggleTopLevelNav("#connect", $(this)); });

});


function toggleTopLevelNav(pvThisNav, pvjQNav) {   
    if (lCurrentNav == pvThisNav) {
        $(lCurrentNav).stop().hide().css("height", "");
        lCurrentNav = null; 
    }
    else {
        $(lCurrentNav).stop().hide().css("height", "");
        lCurrentNav = pvThisNav;

        /*Get height and width of the menu*/
        var h = $(pvThisNav).height();
        var w = $(pvThisNav).width();

        $(pvThisNav).slideToggle("fast");
        $(pvThisNav).css("top", (pvjQNav.innerHeight() - 17) + "px");
    }

    return;
}

function toggleOff(pvThisNav, pvjQNav) {
    $(pvThisNav).stop().hide().css("height", "");
    lCurrentNav = null;    
    return;
}

function closeTopLevelNav() {
   if (lCurrentNav != null) { $(lCurrentNav).stop().hide().css("height", ""); }
   lCurrentNav = null;
}
