﻿$(document).ready(function() { 

    // we need to select the open link
    // select the correct link and open 
    var path = location.href.substring(1);
    var FileName = path.split("/");
    path = FileName[FileName.length-1].toLowerCase(); 
    
    var GroupID = 0;
    
    if (path!="")
    {          
        var elmt = $(".SubHeadings a[href$='" + path + "']");
        
        if (elmt.length==1)
        {
            GroupID = elmt.parent().attr("gid");
            if (elmt.attr("class")=="lastSubHeading")
            {
                elmt.attr("class","lastSubHeadingSelected");
            }
            else if (elmt.attr("class")=="last")
            {
                elmt.attr("class","lastSelected");
            }
            else
            {
                elmt.attr("class","Selected");
            }
        }
        else if (elmt.length>1)
        {
            var thisElmt = elmt[1];
            GroupID = $(thisElmt).parent().attr("gid");
            $(thisElmt).attr("class","Selected");            
        }
        else
        {
            $("#members" + $(".NavGroup:last").attr("id").substring(2)).show();
        }
        
        $("#members" + GroupID).show();     
        // we also need to change the select image of the heading
        //var SwapImg = $("div[id='ng" + GroupID + "'] a img");
        //var NewImg = SwapImg.attr("changeImage");
        //SwapImg.attr("src",NewImg);        
        $("div[id='ng" + GroupID + "'] a").addClass("MouseOver");
        
    }   
    else
    {
        // find the last group id and open it
        $("#members" + $(".NavGroup:last").attr("id").substring(2)).show();
    
    } 

    $(".NavGroup").mouseover(function(){
        var elmt = $(this);
        var ThisGroupID=elmt.attr("id").substring(2);
        $("div.Members[id!='members" + ThisGroupID + "']").slideUp(375);
        $("div.Members[id='members" + ThisGroupID + "']").slideDown(375);
    });
});
