One potential problem is that you are not specifying a unit (px, em, % etc.) for the top property. But in general though, the solution looks pretty dated. :) Take a look at this code, I cleaned it up a bit for you. It is by no means perfect but it could serve as a starting point perhaps.
You could also use something like Velocity.js.