$(document).ready(function() {
    // Mobile toggle submenu
    $('header nav > ul > li').on('click', function(e) {
        if ( !$(this).hasClass('active') )
            $('#site-navigation .active').removeClass('active');
        
        $(this).toggleClass('active');
    });

    // Button to toggle visibility for mobile menu
    var menuToggle = $( '#menu-toggle' );
    menuToggle.on('click', function() {
        if ( menuToggle.hasClass( 'opened' ) ) {
            menuToggle.removeClass( 'opened' );
            $('#site-navigation').removeClass( 'opened' );
            menuToggle.attr( 'aria-expanded', 'false' );
        } else {
            menuToggle.addClass( 'opened' );
            $('#site-navigation').addClass( 'opened' );
            menuToggle.attr( 'aria-expanded', 'true' );
        }
    });
});