As you can see style.com has a click counter and the image number which are passed as a get parameter through the url :
&iphoto=7&cnt=15
You can do this in the same way, pass them as a view parameter and show your add every 5 images...
There is also a shuffle template operator from xrow within the contributions which you will need to show a random image: http://ez.no/community/contribs/template_plugins/extension_shuffle
I do not have ready-to-use solution, but you can check this: http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/mathematics/rand