Have a look at this article - it uses the offsetParent property to recursively figure out the offset.
I would always recommend jquery over rolling your own methods for browser-varying stuff like this. The jquery CSS functions seem to have the methods you need!