Improve meesage and image display, speed and usability.

No, it doesn't work here.  Extracting the function is a good idea, because we are using this code twice on the page.  However, it won't fix the fact it doesn't work.