I have a page with thumbnails of pics. When the user clicks on the preview pic a browser window pops up showing the pic on a seperate html file containing the pic in a larger size. Of course when the user doesn't close the popup but goes back to the thumbnails page and clicks a different thumbnail another popup window will appear and in the end the whole screen will be full of popup windows messing up the desktop.

Now I thought of maybe the popup appears only once and if by mistake the user clicks on a different thumbnail without closing the popup first the content of the other pic page is loaded in to the one and only popup that shows up. In this case I would only have one popup showing the content there.

Indeed this must be the window that will be focussed on automatically so that the popup is always coming back to the foreground of the user.

Sorry, bur my knowledge of Javascript is pretty low. Any suggestions how I can achieve that?
Thanks for your assistance!

kind regards