I had wanted to make something like this for a long time, so that when the page is scrolled some block would scroll together with the page up to a certain point and then stick. Today I found a plugin called jQuery Sticky Scroller
You can download it here.
It is connected quite simply:
var scroller = new StickyScroller("#menu",
{
start: 270,
end: 50800,
interval: 200,
range: 100,
margin: 0
});
As the parameter name suggests, when scrolling goes more than 270 pixels past the top edge of the page, the #menu element is fixed on the page, that is, it gets the CSS property position: fixed;. The end parameter is responsible for the lower bound of scroll tracking, in case the fixed element should not stay fixed all the time. The margin parameter defines how far from the top edge of the browser window the element will be positioned.
The plugin also has several public methods; I do not see much point in describing them here, the description is available on the plugin page.