You can just give the large image's location to the javascript that opens the popup window.
That will automatically open the large image in the new window.
Ofcourse it would be lot nicer to use some PHP script that takes the image-name as an argument, works out the size of the image, and opens a new window that fits the image exactly.