/*	Inline Expanding Menus for Indexhibit
 *		uses jquery
 *
 *	Created by Yuhei Nakata
*/


function customMenu() {
	
    var ACTIVE_COLOR = "#CCC";
    var STD_COLOR = "#695A64";
	
    var titleItems = $("#tree li.section-title");
        
    var subtitleDiv = $("#subtitle-menu");
        
    var showSubtitle = function(subtitle){
            
        if(subtitle){
                
            subtitleDiv.html('');
            subtitle.removeClass('hidden');
            subtitle.children().eq(0).css({
                border:"none", 
                paddingLeft:"0"
            });
            subtitleDiv.append(subtitle);
                
        }
    };

    /* add click functions + pointer to title */
        
    titleItems.css({
        cursor:"pointer"
    }).click(function () {
         
        $("#tree li").parent().parent().children().eq(0).css({
            color:STD_COLOR
        }); 
        
        $(this).css({
            color:ACTIVE_COLOR
        });
        showSubtitle($(this).children('ul.section').clone());
        
    });
        
    /* fix style of first child element */
    titleItems.eq(0).css({
        border:"none", 
        paddingLeft:"0"
    });
          
    /* init menu with current page */
    showSubtitle($("#tree li.active").parent().clone());
   
    $("#tree li.active").parent().parent().children().eq(0).css({
        color:ACTIVE_COLOR
    });
}
