Rotating Flash banners with javascript?

They have: 5,633 posts

Joined: Jan 1970

I tried to write a javascript code, which would show one Flash banner in one place for few seconds and the change it with another Flash banner and so on. I wrote this document, but it doesn't work (it doesn't change banners, but it only shows the one that is specified originally in the src property).

<script type="text/javascript">
if (document.embed)
{ adImages0 = new Array("coolsnake.swf", "coolspot.swf");
adUrl0 = new Array("http://www.linux.org", "http://dot.kde.org");
thisAd0 = Math.floor(Math.random() * 2);
}

function cycleAds()
{ if (document.embed)
{
if (count == 0)
{ if (++thisAd0 >= adImages0.length) thisAd0 = 0;
if (adImages0.length > 0) document.adBanner0.src = adImages0[thisAd0];
}
}

setTimeout("cycleAds()", 1000);
++count;
if (count >= 6) count = 0;

}

</script>

Does anyone has any idea why it doesn't work or how it should be written to work? Any help would be greatly appreciated. Thanks in advance.