Need help with XML gallery thumbs positioning

Hello, everyone!
Here’s my problem:

I have an xml gallery, which contains full images and thumbs. What i need is positioning thumbs raw by raw within a movieclip. For example the main movieclip has it’s length xMax and I want thumbs, when they reach xMax, to begin a new raw. All thumbs have same width and height.

I would appreciate any help gladly.

P.S. it’s a MX2004AS