preloading images

Image preloading helper function added and used to preload the loader
image if needed.