var picture_num = 0;
var current_picture = new Image();
var autorotate = 1; //0 - Off, 1 - On
var slideTimer = 0;

current_picture.src = pictures[picture_num];
picture_num = 1;

function start_show() 
{
	// Time is in seconds X 1000
	document["rotating_picture"].src = current_picture.src;
	
	if (autorotate == 1)
	{	
		slideTimer = setInterval("slideshow()", 5000);
	}
	else
	{
		slideshow();
	}
		
	
}
function slideshow() 
{
	current_picture.src = pictures[picture_num];
	document["rotating_picture"].src = current_picture.src;
	
	if (autorotate == 1)
	{	
		picture_num++;
	}
	
	if (picture_num == pictures.length) 
	{
		picture_num = 0;
	}

}	


function setpicture(cmd)
{
	autorotate = 0;
	clearInterval(slideTimer);
	document["stop"].src = "imageslideshow/stopgrey.gif";
	document["auto"].src = "imageslideshow/auto.gif";	
	
	if (cmd == 0)
	{
		picture_num = 0;
	}
	if (cmd == 1)
	{
		picture_num--;
		if (picture_num < 0)
		{
			picture_num = pictures.length - 1;
		}
	} 
	if (cmd == 2)
	{
		picture_num++;
		if (picture_num > pictures.length - 1)
		{
			picture_num = 0;
		}		
	} 
	if (cmd == 3)
	{
		picture_num = pictures.length - 1 ;
	} 
	
	if (cmd == 4)
	{
		autorotate = 1;
		picture_num++;
		document["stop"].src = "imageslideshow/stop.gif";
		document["auto"].src = "imageslideshow/autogrey.gif";
	} 
	
	start_show();

		
}
