Try google, there is Javascript code to allow you to have an image change after a certain time, or theres one that will display a random images, or ad each time the page is refreshed.
I'm not a fan of using Javascript unless it's absolutely necessary. When possible, I prefer to do these things server-side. Search engines like me better for it.