$(document).ready(function() {



    var headerHeight;

    $('.search span.search-top').on('click', function() {
        event.stopPropagation();
        $('#search-block').animate({
            width: "toggle"
        });
    });

    $('#search-block').submit(function() {
        if ($.trim($("#search-block #search").val()) === "") {
            $(this).animate({
                width: "toggle"
            });
            return false;
        }
    });

    headerHeight = $('header').outerHeight();

    $('body').css({
        'paddingTop': headerHeight
    });

    $('.to-next').on('click', function() {
        var nextDiv = $(this).parent().next();
        $('html,body').animate({
            scrollTop: $(nextDiv).offset().top - headerHeight
        }, 500)
    });

    $('.navigation ').css({
        marginTop: headerHeight,
        transition: 'all 0.5s ease'
    });

    $('.overview-column ').hoverdir({
        speed: 500,
    });

    function mobileMenuAdj() {
        $(window).scroll(function() {
            var scroll = $(window).scrollTop();
            if (scroll >= 300) {
                $("header").addClass("small");

                $('.navigation ').css({
                    marginTop: headerHeight - 44
                });

            } else {
                $("header").removeClass("small");
                $('.navigation ').css({
                    marginTop: headerHeight
                });

            }
        });
    }

    $(window).on('changed.zf.mediaquery', function(event, newSize, oldSize) {
        if (Foundation.MediaQuery.atLeast('medium')) {
            mobileMenuAdj()
        }
    });

    if (Foundation.MediaQuery.atLeast('medium')) {
        mobileMenuAdj();
    }
    $('.count').countUp({
        delay: 10,
        time: 2000
    });
});