It's not my script.
I've got it on one popular forum, and I've used it for my forum.
All works perfectly. I can open an image, scroll images in the popup window, close popup, and open another image.
Sorry, if in your case something works wrong.
But you can modify this script yourself, if you...