It will be easier if you give your img an id, then use JS to change the src:
document.getElementById('imgid').src = "whatever.jpg";
Use JS's version of a random number, something like
If the value of URL_THEME is not available to JS somewhere
then you'll need to extract it from the existing img's src using indexOf(), substr() (or substring()).
If this describes what you are after then you could report back and I (or someone else
) might help you assemble the code you need.