/* --------------------------------------------------------------------
 *	easyslideshow
 *	This script is part of Onlinetools 
 *  http://www.onlinetools.org/easyslideshow/
 *	free of use with these lines included!  
 *
 *  Version 1.0 initial                                      
 * --------------------------------------------------------------------*/

/* --------------------------------------------------------------------
 *	Setting up the data.
 * --------------------------------------------------------------------*/
rotator=true; 	// needed for initialising the rotator
n=0;			// initialising the first image 
// The images, add and delete yours here...
theImages="0.jpg, 1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg, 6.jpg".split(", ");
allImages=theImages.length;
// Creating the needed image objects => preloading
imgObjects=new Array();
for (i in theImages)
{
	imgObjects[i]=new Image();
	imgObjects[i].src=theImages[i];
}
/* --------------------------------------------------------------------
 *	function autoplay() 
 *  Allows to automatically change the images.
 *  Options:
 *    run - can be 1 or 0, 1 starts the play, 0 ends it 
 *    srcimage - defines the image that will be replaced by the others
 *    direction - 1 forward -1 backward
 *    speed - speed in milliseconds
 *  requires the function rotate()
 * --------------------------------------------------------------------*/
function autoplay(run,srcimage,direction,speed)
{
	// delete old settings
	clearInterval(rotator)
	if (run != 0)
	{
		rotator=setInterval("rotate('"+srcimage+"',"+direction+")",speed);
	}else{
		clearInterval(rotator);
	}
}

/* --------------------------------------------------------------------
 *	function rotate() 
 *  Allows to change the source image to the next or last in the list.
 *  Options:
 *    srcimage - defines the image that will be replaced by the others
 *    direction - 1 forward -1 backward
 * --------------------------------------------------------------------*/
function rotate(srcimage,direction)
{
	n=n+direction;
	if (n==allImages) n=0;
	if (n==-1) n=allImages-1;
	document.images[srcimage].src=imgObjects[n].src;
}
