I'm trying to get a simple script to run where it cycles thru a few images with corresponding links and displays them on a page.

I get the script to run 2 times then it breaks on the third with a runtime error saying "object expected Line 0".

Here's the code, it's totally "body" code.

<script language="Javascript">
<!--

function rotator() {
var currentdate = 0;
var core = 0;
var Rtime = 2000

function initArray() {

this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}

link = new initArray(
"http://www.yahoo.com",
"http://www.nike.com",
"http://www.sitepoint.com/"
);

image = new initArray(
"pic1.gif",
"pic2.gif",
"pic3.gif"
);

text = new initArray(
"Picture 1",
"Picture 2",
"Picture 3"
);

var currentdate = new Date();
var core = currentdate.getSeconds() % image.length;
var ranlink = link[core];
var ranimage = image[core];
var rantext = text[core];


document.write('<a href=\"' +ranlink+ '\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"><br>'+rantext+'</a>');
setTimeout("rotator()", Rtime)
}
rotator();

//-->
</SCRIPT>