imageArray[i] = imageItem is incompatible
<p>I have been struggling with trying to implement the the answer from TheNoble-Coder for <a href="http://stackoverflow.com/questions/8299954/difficulty-in-understanding-slideshow-script">Difficulty in Understanding Slideshow script</a>.
His "Well if you want..." solution sounds like a very elegant solution for folders containing a varying number of images.
However I have have not been able to get it to work. Using Free JavaScript Editor by Yaldex to debug I get 'Error: Incompatible types' for the line indicated:</p>

<pre><code>var place; //For convenience this is best as a global
function imageItem(url) 
{
    var img = new Image();
    img.src = url;
    return url;
}
for(var i=0; i&lt;5; i++)
{
    imageArray[i] = imageItem(imageDir + i + ".jpg");   &lt;-----Incompatible 
}
</code></pre>

<p>I would really appreciate any assistance.</p>

<p>The entire script is:</p>

<pre><code>     &lt;script language="JavaScript"&gt;
var interval = 4000;
var random_display = 0;
var imageDir = "images/";
var imageNum = - 1;
var place; //For convenience this is best as a global
function imageItem(url) 
{
    var img = new Image();
    img.src = url;
    return url;
}
for(var i=0; i&lt;5; i++)
{
    imageArray[i] = imageItem(imageDir + i + ".jpg");
}
function randNum(x, y)
{
   var range = y - x + 1;
   return Math.floor(Math.random() * range) + x;
}
function getNextImage() 
{
    imageNum = (random_display) ? randNum(0, imageArray.length-1) : ((imageNum+1) % imageArray.length);
    return imageArray[imageNum];
}
function getPrevImage()
{
    imageNum = (imageNum-1 &gt;= 0) ? (imageNum-1) : (imageArray.length-1);
    return imageArray[imageNum];
}
function prevImage() 
{
    var image_item = getPrevImage();
    place.src = place.alt = image_item.url;
}
function nextImage() 
{
    var image_item = getNextImage();
    place.src = place.alt = image_item.url;
}
function play() 
{
    nextImage();
    timerID = setTimeout(play, interval);
}
window.onload = function()
{
    place = document.slideImg;
    play();
};

  &lt;/script&gt;
</code></pre>
