Finally I have ended up with this. But there is a minor issue not getting how to resolved it. Here is the link with what I tried so far
Am having a number of images in my Xml so based on that the little yellow square shapes will be shown.
If my XML holds only one image at that time little yellow square shapes should not be shown and the fadeIn, fadeOut effect for the image and to the text also have to disable.
If I understood you correctly, you just have to use your
maximagesvariable to build conditions for building yellow square and beforefadeInandfadeOuteffects.Check this: http://jsfiddle.net/xDfDv/