JavaScript running before page fully loaded
Drupal attach behaviors get called from a jQuery ready() callback upon initial page load (it is a little more complicated than that, though).  This means that the DOM is ready, but replaced elements may not be done loading.  Images are considered replaced elements, so your have a loading bug.

I get around these by using something like imageloaded, or manually attaching via $(window).bind('load', ...);, which will run when the whole page is done loading (including images).