Jquery DIV collision
===

I've found this little script to make my menu have a smooth scroll following the screen. (Like the CSS fixed position). However, it pushes my footer further down, so the page gets longer with no content. How do i make it stop scrolling when it collides with the footer?

    $(function() {

    var $sidebar   = $("#indhold_right"), 
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 0;

    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            }, "fast");
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });
        }
    });
    
    });


