Since the page has PHP, it may also be easier to add some PHP tags there, but I think JS would be the easiest way to go. If you want to see how Hotmail script works, look at the source in their login page.
Any working solution or workaround would help.
Since I have seen JS scripts implement similar to this with as little as 5 lines, I don't think this will be a majot effort. A similar sample is at http://www.mybannertaxi.com/scripts/echo.html