var mess = new Array('code0','code1','code2');
var max = mess.length;
var num = Math.floor((Math.random() * max));
What the code that gets inserted can be is just about anything, all you do is to assign whatever code that you want to the entries in the array. Just separate the entries that you want with commas.
In my case I used straight text with hyperlinks but you can use images just as easily by including the <img> tag with the appropriate parameters directly within the array. In the case of my code, I don't assign the text in the array definition (leaving the Array() empty) and assign the values in separate statements following the array definition so that I can assign the content of one array entry to another and manipulate the frequency at which the different messages appear (I have one entry that appears three times out of the eight alternatives).
This article written by Stephen Chapman, Felgall Pty Ltd.