let sidenav = $("#menuSidenav");
let baguette = $("#baguette");
let backButton = $("#back-button");

let openedSidenavClass = 'sidenav-open';
let activeBackgroundClass = 'active-background';

/*
 * Open navigation menu, change Baguette icon to selected state
 * and display the back button overlay over the page
 */

function openNav() {
    sidenav.addClass(openedSidenavClass);
    backButton.addClass(activeBackgroundClass);
    enableBaguette();
}


/*
 * Close navigation menu, change Baguette icon back to default state
 * and hide the back button overlay
 */
function closeNav() {
    sidenav.removeClass(openedSidenavClass);
    backButton.removeClass(activeBackgroundClass);
    disableBaguette();
}


/*
 * Toggle the navigation bar
 */
function toggleNav() {
    if (sidenav.hasClass(openedSidenavClass)) {
        closeNav();
    } else {
        openNav();
    }
}

function disableBaguette() {
    baguette.removeClass("change-clic");
}

function enableBaguette() {
    baguette.addClass("change-clic");
}

// Animate baguette on hover
baguette.hover(function(){
    baguette.addClass("change-hover");
}, function(){
    baguette.removeClass("change-hover");
});