So I've got the following code:
window.onload = function () {
function getScrollTop() {
    if (typeof window.pageYOffset !== 'undefined') {
        // Most browsers
        return window.pageYOffset;
    }
    var d = document.documentElement;
    if (d.clientHeight) {
        // IE in standards mode
        return d.scrollTop;
    }
    // IE in quirks mode
    return document.body.scrollTop;
}
window.onscroll = function () {
    var reviewbasket = document.getElementById('reviewbasket'),
    scroll = getScrollTop();
    if (scroll > 950) {
        $("#global").stop;
    }
    else {
        reviewbasket.style.top = (scroll + 0) + "px";
    }
};
};
Currently the scroll ends at 950 px however I wish for the div to scroll right up until the max height of either the content area (#content) or the page is reached. I also don't want the div to overlap the footer. The main problem I face is that this page is viewed in two different states: Logged in and Logged out, Logged out comes with an extra content area which pushes the basket down further and stops me being able to set a fixed height for the scroll to end.
Any tips or direction is welcome!
Thanks, Dan