I'm also no guru in JS, but I no that you can create a backbutton for each page, kinda tedious work though :/
Mayb it would be better if you made the pictures appear in the flash page, then people click the image and the popup window appears with just the image (then you just exit the window)