Handle XHTML footnotes and pop them up

A friend of mine says she wants footnotes to pop-up rather than to be treated as internal-links.
At first I didn't agree with her, but after implementing it, I found it intuitive.
With the current implementation, you cannot see both body and footnote text at once.
After applying this patch, you'll see body text behind footnote simultaneously.

I feel sorry for the dirty code but I don't know how to improve it. I'm not a good programmer.