As much as I'd prefer to run php over JS, here's a few examples. These are all cgi-based, which is probably the best way to run them, but you could probably rip out some of the code and use it as a header:
http://www.autoinstaller.de/banner-rotator.html
http://www.geocities.com/jsmaster/banrot.html
http://www.geocities.com/SiliconValley/7116/banner2.zip
http://javascript.internet.com/messages/banner-ads.html
http://www.bloke.com/javascript/AdRotation/
PM know if you need help,
-scheides