sergiocharm,
попробуйте так
$(function() {
var offset = $("#fixed").offset();
var topPadding = 20,
bottomPadding = 210;
$(window).scroll(function() {
var max = $(document).height() - ($(window).height() - bottomPadding),
scroll = $(window).scrollTop();
if (scroll > offset.top && scroll < max) {
if ($(document).height() - bottomPadding > scroll + $("#fixed").height()) $("#fixed").stop().animate({
marginTop: scroll - offset.top + topPadding
})
} else $("#fixed").stop().animate({
marginTop: 0
})
})
});