I want to create a table of content similar to [JavaScript Gardens](http://bonsaiden.github.com/JavaScript-Garden/). How do they determine which section is currently active and do you have any recommended JavaScript libraries that imlpement this behavior?

Edit: So the thing I am asking for is how to know which section currently is active on the screen while the user is scrolling so that I can highlight that section in the table of content.