When closing the image overlay with the X, clean up the semantic block.

This includes a minor change to take advantage of our recent upgrade to
jquery 1.8.