Added a helper method to deal with javascript closure craziness. Use the makeGalleryImageOnloadCallback method as your image's onload event listener.