/**
* Initialization that wires up the
* main resource menu to slide sub categories
* in and out allowing users to pick a specific
* category/sub category combination.
*/

$active_menu_button = '';

$(document).ready(function(){
    //iterate over the list items in the menu
    $("#sidebar_categories").children("div:not(.selected_category)").each(function() {
        //get the anchor tag (the link) out of the list item, note
        //this returns an array, we just need the first element.
        var li = $(this).children("h3").children("a")[0];
        //get the category slug.  The anchor tag is pre-pended with sidebar_btn_, so remove that.
        var cat_slug = li.id.substring(12);
        //now add the necessary slider effects both to the button and to the slide in menu
        //so the user can toggle back and forth.
        $("#sidebar_btn_" + cat_slug).click(function(){
            $("#sidebar_sub_" + cat_slug).slideToggle("slow");
            return false;
        });
    });
});

/**
* Function when a specific resource in a list of resources
* is selected.  The resource data slides in and the list of
* resources slides out.
*/
function slide_resource(resource_url){
    //make the mouse busy
    //fill the resource contents with the correct one.
    $("#embedded_resource_details").load(resource_url);
    //hide search results
    $("div.resource_search_results").slideToggle("fast");
    //show returned results
    $("#embedded_resource_details").slideToggle("fast");
}

