JS

fix div on scrolling at a certain point

jQuery

$(window).scroll(function(){
    $("#fixed").css("top", Math.max(0, 100 - $(this).scrollTop()));
});

CSS

#fixed {
    position: fixed;
    top: 100px;
    right: 0;
    z-index: 9999;
}