my java script

N = new Image()
N.src ="imagename.jpg"


how can I detect when this image is done downloading?
I want to download all the images for a page before opening the page.

Thanks