I'm going to assume that you're taking the offset of body from the top when window is the actual scrolling element. In this case, you may want to get the scroll position of the window by calling a function like the following:
function getWindowScrollPos() {
return (window.pageYOffset !== undefined) ? window.pageYOffset :
(document.documentElement ||
document.body.parentNode ||
document.body).scrollTop;
}
If you're trying to make a element or several elements sticky (stick to the top), you can easily use this library I created to handle just that without you having to worry what's going on under the hood:
https://github.com/vhiremath4/Balloon
EDIT:
Just in case it wasn't clear, you're going to want to call that getWindowScrollPos function and assign it to top_offset instead of using jQuery's offset method.