$(document).ready(function() {
    var $memdoc = $(".memdoc");
    
    // Add a "Home" Link to the nav bar.
    var $tabs = $(".tabs:first ul");
    $tabs.html('<li><a href="../../index.php"><span>Home</span></a></li>' + $tabs.html());

    // Hide all the Details.
    $memdoc.each(function() {
        $(this).html('<div>' + $(this).html() + '</div> <a class="showDetails" href="#" alt="Click Me!">Show Details</a>');
        if ( $("p:first", this).html().indexOf("Definition at line") < 0 )
            $("p:first", this).addClass("methodDescription");
    });

    $("dl:last ~ p", $memdoc).hide();
    $("p", ".memdoc:not(:has(dl))").hide();
    $(".dynsection, .dynheader",".memdoc").hide();
    $(".methodDescription", $memdoc).show();

    $(".showDetails", $memdoc).click(function() {  
        if ($(this).html() == "Show Details")
            $(this).html("Hide Details");
        else
            $(this).html("Show Details");
            
        if (typeof $(this).data("saved") == "undefined") {
            var $saved = $("dl:last ~ p, .dynsection, .dynheader, p:hidden", $(this).parents(".memdoc"));
            $(this).data("saved", $saved);
        }

        $(this).data("saved").toggle();
        return false;
    });
});