It should appear in the middle of the page, plus scrolling.
I wonder if the issue is related to the size of the images. I suspect it might not be using the defined max sizes when positioning the images. Lemme take a look.
Ok, I've uploaded a test version that will output some information to the JavaScript console. In Chrome you can see this by pressing Ctrl+Shift+j (I think). Just click an image and tell me what it reports. It will list image height, scroll pos and window height. Do any of the numbers look wrong?
I've added a new thing: a 'dimmer' option, to darken the rest of the page when you open a popup. If you use it you'll need to add some CSS to make it actually visible, something like this:
WTF sort of stuff were you doing before that then?
Whilst I'm generally not opposed to people re-inventing wheels for learning purposes, I'd probably still say it's better to learn from and extend an existing solution.
If more people (both new and experienced) spend more time on improving current stuff, there'd be more half-decent software around, instead of not only everything being crap, but it being even harder to find the slightly less crap stuff amongst all the unfinished experiments. :(
WTF sort of stuff were you doing before that then?
Working in Blockbuster then Jessops, then doing data-entry, then fixing HMRC computers, then attempting to work out what I was supposed to be doing in an understaffed and underexplained repair team fixing Tesco hardware (and by 'hardware' I mean everything from receipt printers to IBM RS/6000s to those 'pay at pump' things they have in petrol stations).