$(document).ready(function () {

     $('body .header .h-bottom .navbar .close, .menu-shad').click(function(){
       $('body .header .h-bottom .navbar .navbar-collapse').removeClass('active');
        $('.menu-shad').removeClass('active');
    });
    
    $('.navbar-toggler').click(function(){
        $('body .header .h-bottom .navbar .navbar-collapse').addClass('active');
        $('.menu-shad').addClass('active');
    });
    
    //выпадающее меню бутстрап
    if (jQuery(window).width() > '767') {
        $('.dropdown > a').hover(
            function () {
                //show its submenu
                $(this).parent().children('.dropdown-menu').stop().fadeIn(300);
                $(this).parent().addClass('open');
            }
        );
        $('.dropdown').hover(null,
            function (e) {
                //hide its submenu
                $(this).children('.dropdown-menu').stop().fadeOut(100);
                $(this).removeClass('open');
            }
        );

    }


    jQuery(".go-to-block").click(function (e) {
        e.preventDefault();
        var target = jQuery(this).data('target');

        jQuery('html, body').animate({
            scrollTop: jQuery(target).offset().top - 30
        }, 400);
    });

    menuFixed('.header .h-bottom', 0);
    
});

function menuFixed (menu, offseting) {
    
    var height = $(menu).outerHeight(),
        offsetParametr = offseting,
        offsetTop = $(menu).offset().top + offsetParametr,
        wrapper = 'wrapper-' + $(menu).attr('class');

    $(menu).wrap('<div class="' + wrapper +'"></div>');
    $('.' + wrapper).css({minHeight: height});

    $(window).scroll(function(){
        if($(window).scrollTop() >= offsetTop) {
            $(menu).addClass('active');
        }
        else {
            $(menu).removeClass('active');
        }
    });

}

$(window).on('load', function(){
    if($(window).width() > 575) {
        setHeight('section', '.t-block .text-block');
    }
});

function setHeight (parent, block) {

    $(parent).each(function(){
        
        var height = 0,
            blockk = $(this).find(block);
        
        blockk.each(function(){
            
            var blockHeight = $(this).outerHeight();
            
           if(height < blockHeight) {
                height = blockHeight;
            } 
            
        });
        
        blockk.css({height: height});
        
        
    });
}