jQuery('.blog-inner a[href*="#"]:not([href="#"])').click(function() {
	var offset = -100; // <-- change the value here 
	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
		var target = jQuery(this.hash);
		target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
		if (target.length) { 
			jQuery('html, body').animate({
				scrollTop: target.offset().top + offset
			}, 100); 
			return false; 
		}
	}
}); 

var mq = window.matchMedia( "(min-width: 768px)" );
if (mq.matches) {
	var	wrapper = document.getElementById("catalog"), main = document.getElementById("main-n"), sidebar = document.getElementById("sc");
	window.onscroll = function() {
		document.getElementById("sc").setAttribute("style","display:block;width:" + document.getElementById("sidebar-mix").offsetWidth+"px");
		document.getElementById("sc").style.width = document.getElementById("sidebar-mix").offsetWidth;	
		//if sidebar smaller than main
		if (sidebar.offsetHeight < main.offsetHeight) {
			//if sidebar smaller than screen - stick to top rather than bottom
			if (sidebar.offsetHeight < window.innerHeight) {
				if ((wrapper.getBoundingClientRect().bottom < (window.innerHeight)) && ((wrapper.getBoundingClientRect().bottom < sidebar.offsetHeight))) {
					wrapper.classList.remove("fix-top-VP");
					wrapper.classList.add("flex-bottom");
				}
				else if (wrapper.getBoundingClientRect().top < 0 ) {
					wrapper.classList.add("fix-top-VP");
					wrapper.classList.remove("flex-bottom");
				}
				else {
					wrapper.classList.remove("fix-top-VP");
					wrapper.classList.remove("flex-bottom");
					wrapper.classList.remove("fix-bottom-VP");
				}
			}
			//if wrapper taller than sidebar - stick to bottom
			else if (sidebar.offsetHeight < wrapper.offsetHeight) {
				if (wrapper.getBoundingClientRect().bottom < (window.innerHeight)) {
					wrapper.classList.remove("fix-bottom-VP");
					wrapper.classList.add("flex-bottom");
				}
				else if (wrapper.getBoundingClientRect().bottom > (sidebar.offsetHeight + window.innerHeight)) {
					wrapper.classList.remove("fix-bottom-VP");
					wrapper.classList.remove("flex-bottom");
				}
				else {
					wrapper.classList.add("fix-bottom-VP");
					wrapper.classList.remove("flex-bottom");
				}
			}
		}
	}
}

const anchors = $('body').find('.post-content-info');
jQuery(window).scroll(function(){
    var scrollTop = jQuery(document).scrollTop(); 
    for (var i = 0; i < anchors.length; i++){ // highlight the last scrolled-to: set everything inactive first
    		jQuery('.blog-listing-info ul li a[href="#' + jQuery(anchors[i]).attr('id') + '"]').removeClass('highlight');
    } 
    for (var i = anchors.length-1; i >= 0; i--){ // then iterate backwards, on the first match highlight it and break
        if (scrollTop > $(anchors[i]).offset().top - 500) {
            jQuery('.blog-listing-info ul li a[href="#' + jQuery(anchors[i]).attr('id') + '"]').addClass('highlight');
            break;
        }
    }
});