$(function() {
    //console.log("toto");
    $('#side-menu').metisMenu();

});

//Loads the correct sidebar on window load,
//collapses the sidebar on window resize.
// Sets the min-height of #page-wrapper to window size
$(function() {
    $(window).bind("load resize", function() {
        var heightbody = $('html').height();
        var heightheader = $('.header').height();
        var heightpagewrapper = heightbody-heightheader;
        
        $("#page-wrapper").css("min-height", (heightpagewrapper) + "px");
    });

    var url = window.location;
    var element = $('ul.nav a').filter(function () {
        return this.href == url;
    });

    if(element.length==0) {
        
        var element = $('ul.nav a').filter(function () {
            if(String(url).indexOf(this.href)==0)
                return true;
            else
                return false;
        });
    }
    
    if (element) {
        element.addClass('active').parents('#side-menu ul').addClass('in');
        element.parents('#side-menu li').addClass('active');
    }  
});
