you mean something like this:
Code:
function RandomSlider()
{
var self = this;
this.pictures = new Array();
this.timeout = 2000; // wait 2000 ms
this.aniTime = "fast" or 1500;
// generate a random number
this.randomStart = function()
{
return Math.floor(Math.random() * self.pictures + 1);
}
this.SetAnimate = function(arrIndex)
{
setTimeout(function()
{
// do animation or what you want
$(....).animate({ .... }, self.aniTime, 'linear', function()
{
// do stuff when you are done with animation
if(arrIndex == self..pictures.length)
{
// when the random index is the last item in your case image 5 and array index 4
// then start over again, start with array index 0
self.SetAnimate(0);
}
else
{
// set the next slider item ready
self.SetAnimate(arrIndex + 1);
}
});
}, self.timeout);
}
this.StartSlider = function()
{
// start animation
this.SetAnimate( this.randomStart() );
}
}
Usage:
/
/ you can put in the array ID's classes attr urls all you want
var picture_array = new Array();
picture_array[0] = "image1";
picture_array[1] = "image2";
picture_array[2] = "image3";
picture_array[3] = "image4";
picture_array[4] = "image5";
var slider = new RandomSlider();
slider.pictures = picture_array;
slider.StartSlider();