
$(document).ready(function () {
    'use strict';

     // var active_link,
     //    active_parents;

    // if basic sidebar exists
    if ($('.js_triggerBasicProductFilter').length ) {
        showHideMenus('.js_triggerBasicProductFilter', window.breakpoints.medium);
    }

    // if footer accordion exists
    if ($('.js_basicSidebarAccordion').length) {


        $('.js_basicSidebarAccordion li.parent ul').hide();

        var active_link;
        var active_parents;
        // find active link
        active_link = $('.js_basicSidebarAccordion li.active');


        if (active_link.length) {

            //make active link open
            active_link.addClass('open');

            active_link.find('> ul').show();

            // make all parents open
            active_parents = active_link.parents('.parent').addClass('open');
            active_parents.find('> ul').show();

        }

        $('.js_basicSidebarAccordion li.parent > a').on('click', function (e) {
            e.preventDefault();
            $(this).siblings('ul').stop(true, true).slideFadeToggle();
            $(this).parent().toggleClass('open');
        });
    }
});

$(window).on('resize', debouncer(function (e) {
    'use strict';

    // if basic sidebar exists
    if ($('.js_triggerBasicProductFilter').length ) {
        showHideMenus('.js_triggerBasicProductFilter', window.breakpoints.medium);
    }

})); // debounced resize
