Take a look at this.
Feel free to explore the JsFiddle link
$(document).ready(function() {
function updateBar(e) {
var number = $(e).data('id');
total = $("#content .post").length, $("#navigation .p").text("Post:" + number);
$(".processreading").width(Math.ceil(number / total * 100) + "%");
}
$('#navigation .p').hide();
$('div.post').hover(function() {
$(this).css("background", "#DDD");
updateBar(this);
}, function() {
$(this).css("background", "#FFF");
});
var page1OffsetTop = $('#post-1').offset().top - 40;
var page2OffsetTop = $('#post-2').offset().top - 40;
var page3OffsetTop = $('#post-3').offset().top - 40;
var page4OffsetTop = $('#post-4').offset().top - 40;
var page5OffsetTop = $('#post-5').offset().top - 40;
var page6OffsetTop = $('#post-6').offset().top - 40;
$(window).scroll(function() {
var yValue = $(this).scrollTop();
if (yValue >= page6OffsetTop) {
$('#post-1').css("background", "#FFF");
$('#post-2').css("background", "#FFF");
$('#post-3').css("background", "#FFF");
$('#post-4').css("background", "#FFF");
$('#post-5').css("background", "#FFF");
$('#post-6').css("background", "#DDD");
updateBar($('#post-6'));
} else if (yValue >= page5OffsetTop) {
$('#post-1').css("background", "#FFF");
$('#post-2').css("background", "#FFF");
$('#post-3').css("background", "#FFF");
$('#post-4').css("background", "#FFF");
$('#post-5').css("background", "#DDD");
$('#post-6').css("background", "#FFF");
updateBar($('#post-5'));
} else if (yValue >= page4OffsetTop) {
$('#post-1').css("background", "#FFF");
$('#post-2').css("background", "#FFF");
$('#post-3').css("background", "#FFF");
$('#post-4').css("background", "#DDD");
$('#post-5').css("background", "#FFF");
$('#post-6').css("background", "#FFF");
updateBar($('#post-4'));
} else if (yValue >= page3OffsetTop) {
$('#post-1').css("background", "#FFF");
$('#post-2').css("background", "#FFF");
$('#post-3').css("background", "#DDD");
$('#post-4').css("background", "#FFF");
$('#post-5').css("background", "#FFF");
$('#post-6').css("background", "#FFF");
updateBar($('#post-3'));
} else if (yValue >= page2OffsetTop) {
$('#post-1').css("background", "#FFF");
$('#post-2').css("background", "#DDD");
$('#post-3').css("background", "#FFF");
$('#post-4').css("background", "#FFF");
$('#post-5').css("background", "#FFF");
$('#post-6').css("background", "#FFF");
updateBar($('#post-2'));
} else if (yValue >= page1OffsetTop) {
$('#post-1').css("background", "#DDD");
$('#post-2').css("background", "#FFF");
$('#post-3').css("background", "#FFF");
$('#post-4').css("background", "#FFF");
$('#post-5').css("background", "#FFF");
$('#post-6').css("background", "#FFF");
updateBar($('#post-1'));
}
if (yValue > 50) {
var num = $('div.post').data('id');
$('.bar-container').show();
$('#main').hide();
$('#navigation .p').show();
} else {
$('.bar-container').hide();
$("#main").show();
$('#navigation .p').hide();
}
});
});
I hope you find this information useful.