jQuery(document).ready(function($) {

$('.nav-toggle').on( 'click', function() {
	$( this ).toggleClass( 'active' );
});
	
var headerHeight = $('.navbar').height();
$(window).on('scroll', { previousTop: 0 },
function() {
    var currentTop = $(window).scrollTop();
    if (currentTop < this.previousTop) {
        if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
            $('.navbar').addClass('visible');
        } else {
            $('.navbar').removeClass('visible fixed');
        }
    } else {
        $('.navbar').removeClass('visible');
        if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
    }
    this.previousTop = currentTop;
});

var commentsDiv = $('#comments');
	if (commentsDiv.length) {
		$(commentsDiv).hide();
		$('.toggle-comments').on('click', function(e) {
			e.preventDefault();
			$(commentsDiv).toggle('slow', function() {
				var anchor = $('.toggle-comments');
				var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
				$(anchor).text(anchorText);
			});
		});
	}

});