(function ($) {

    function majSelectedFacet(){
        $('.block-facetapi').removeClass('active');
        $('.block-facetapi').each(function(index, element){
            if($(element).find('.facetapi-active').length){
                $(element).addClass('active');
            }
        });
    }

    if($('#facets').length){
        $('.toggle-facets').on('click', function(){
            $(this).parents('.block-facetapi').find('.facetapi-facetapi-links').slideToggle();
            majSelectedFacet();
        });
    }
    $(document).ready(function(){
        majSelectedFacet();
        $('body').on('click', function(e){
            
        })
    });

}(jQuery));
 