OK Here is some explaining of it:
var image1=new Image() //creating a DOM Image Element
image1.src="Sunset.jpg" //assigning the source & preloading the image file(s)...
var step=1 // creating a globally accessible counter variable;
if(!document.images) // checking for images coll., existence; duck-converting the find into Boolean (true / false)
return; // canceling the function if find turns false
document.images.slide.src=eval("image"+step+".src") // feeding the slide src attribute with the preloaded image loc., in steps.
if(step<5) step++ //checking if step var hasn't exceeded the max num., of images & incrementing by 1.
else step=1 //otherwise reset to starting value
setTimeout("slideit()","1500") // setting the timer of this function call
slideit() // initiating, actual function call
without spoiling the idea of the given approach completely, I would've rephrased it this way:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>
<img src="blue hills.jpg" name=slide width=350 height=300>
<script>
onload=slideit;
var src="sunset.jpg, winter.jpg, blue hills.jpg, turf.jpg, white.jpg".split(", "), images=[], step=0;
for(x in src)images[x]=new Image, images[x].src=src[x];
function slideit(){
if(!document.images)return;
document.images.slide.src=images[step].src;
if(step<4)step++;
else step=0;
setTimeout(slideit,1500);
}
</script>
</body>
</html>