var GblTop;
 
function GetVertOffset (srchStr){
    GblTop = $(srchStr).offset().top - parseFloat($(srchStr).css('marginTop').replace(/auto/, 0));
}
 
$(document).ready(function (){
 
    GetVertOffset ('#navigation');     //-- Sets GblTop
 
    $(window).scroll (function (){
		
        // what is the y position of the scroll?
        var y = $(window).scrollTop();
        // whether that's below the start of article?
        if (y >= GblTop){
            // if so, add the fixed class
            $('#navigation').addClass('fixed');
			$('#sideBar').removeClass('sb_top');
			$('#sideBar').addClass('fixed');
        }
        else{
            // otherwise, remove it
            $('#navigation').removeClass('fixed');
			$('#sideBar').removeClass('fixed');
			$('#sideBar').addClass('sb_top');
        }
    });
 
});
