Java script to position the tiles in the Gallery