$(document).ready(function(){
    var navHeight = $('.classiera--nav').outerHeight(true) + 10;
    var slHeight = $('#imgSlider').outerHeight(true) + 10;
    var totH = navHeight+slHeight;
    /* activate sidebar */
    $('#sidebar').affix({
        offset: {
            top: $('#sidebar').offset().top
        }
    });

    $('body').scrollspy({ target: '.scrollspy', offset:100});

    //back to top
    var backtotop = '#back-to-top';
    if (jQuery(backtotop).length) {
        var scrollTrigger = 100, // px
            backToTop = function () {
                var scrollTop = jQuery(window).scrollTop();
                if (scrollTop > scrollTrigger) {
                    jQuery(backtotop).addClass('show');
                } else {
                    jQuery(backtotop).removeClass('show');
                }
            };
        backToTop();
        jQuery(window).on('scroll', function () {
            backToTop();
        });
        jQuery('#back-to-top').on('click', function (e) {
            e.preventDefault();
            jQuery('html,body').animate({
                scrollTop: 0
            }, 700);
        });
    }
});