// JavaScript Document

var time;
var count;
var changed;
var timerOn;
var timeoutCheck;

count=1;
changed=0;

function startTimer ()
{

	if( !timerOn )
	{
		timerOn=1;
		doCount();
	}
}

function play()
{
		timerOn=1;
		document.getElementById("slideshowControl").src="images/frontpage/pause2.png";
		if(!timeoutCheck)
		{
			doCount();
		}
}

function pause()
{
	timerOn=0;
	document.getElementById("slideshowControl").src="images/frontpage/play2.png";
	
}

function playPause()
{
	if(timerOn)
	{
		pause();
	}
	else
	{
		play();
	}
}

function selectThumb( thumbId )
{
	count = thumbId
	$("slideshowImage").fade
	document.getElementById("slideshowImage").src=("images/frontpage/image_" + count + ".jpg");
	changed = 1
}

function doCount()
{
	if( timerOn )
	{
		if( !changed )
		{	
			document.getElementById("slideshowImage").src=("images/frontpage/image_" + count + ".jpg");
			count=count+1;
			if( count == 17 )
			{
				count = 1;
			}
		}
		changed = 0;
		time=setTimeout( doCount, 3000 );
		timeoutCheck = 1;
	}
	else
	{
		timeoutCheck = 0;
	}
}
