var Imgvalue;
var Count =13; //Number of pictures
var Imgs = new Array(Count);
var ImgLoaded =0;
//Preload images
function preLoadImgs()
{
alert('Please wait while the image is loading Wait...');
for(var i=0;i
Imgs[i]=new Image();
downloadImage(i);
}
}
//Load a single image
function downloadImage(i)
{
var imageIndex = i 1; //The image starts with 1
Imgs[i] .src = "images/" imageIndex ".jpg";
Imgs[i].onLoad=validateImages(i);
}
//Verify whether the loading is successful, if not, reload
function validateImages(i){
if (!Imgs[i].complete)
{
window.setTimeout('downloadImage(' i ')',200);
}
else if (typeof Imgs[i].naturalWidth != "undefined" && Imgs[i].naturalWidth == 0)
{
window.setTimeout('downloadImage(' i ')',200);
}
else
{
ImgLoaded
if(ImgLoaded == Count)
{
document.getElementById('BtnStart'). disabled=false;
document .getElementById('BtnStop').disabled=false;
alert('Image loaded! ');
}
}
}
//Start
function RandStart()
{
Init = setInterval('SetRand()',50); >}
//Random display
function SetRand()
{
imageIndex = Math.floor(Math.random()*Count);
document.getElementById("ImgView"). src = Imgs[imageIndex].src;
}
//End
function RandStop()
{
window.clearInterval(Init);
}