I have tried to get this to work in Firefox, but for some reason it only works in Opera. So I suggest you download Opera 9 if you want to give it a try. I suspect the reason might that Firefox does not let you add or remove event listeners from within another event listener. Not sure though.
You are allowed to freely reuse the code for both personal and commercial use. Attribution would be appreciated, but is not required. For any questions please contact Anne van Kesteren.