//*************************************************************************************
//These variables can be changed to alter the functioning of the scroll control - Start

var myMovePause  = 6000;				//time interval that determines the auto scroll in miliseconds
var myBlockItems = 8;					//total number of items. These should correspond to the number of div items in the Home page content area 5 section
var myMoveBlocks = 1; 					//number of block to move when the next, previous buttons are clicked.

//These variables can be changed to alter the functioning of the scroll control - End
//*************************************************************************************


var myBlockWidth = 190;					//width for a div item. This should remain as it is unless the css files are also changed
var scroller = null; 
var count = 0
var myMoveReset  = myBlockWidth * myBlockItems;


window.onload = init;

function init()
{
	scroller = document.getElementById('scroller');
	scroller.style.right = '0px';
	myTimer=setTimeout(doMove,myMovePause);
	showControl();
}

function doMove()
{
	if (count < myBlockItems + myMoveBlocks )
	{
		toggleNext();
		myTimer=setTimeout("doMove()",myMovePause);
		count++;
	}
	else
	{
		scroller.style.right = (parseInt(scroller.style.right)-myMoveReset + 'px');
		count-=myBlockItems;
		doMove();
	}
}

function toggleNext()
{
	t1 = new Tween(scroller.style, 'right', Tween.regularEaseInOut, parseInt(scroller.style.right)+0, parseInt(scroller.style.right)+myBlockWidth, 2, 'px');
	hideControl();
	t1.start();
	setTimeout(showControl,2000);
}


function hideControl()
{
	document.getElementById('t3').style.display = 'none';
	document.getElementById('t3disabled').style.display = 'block';
}


function showControl()
{
	document.getElementById('t3').style.display = 'block';
	document.getElementById('t3disabled').style.display = 'none';
}


function toggleForward()
{
	if( count < myBlockItems )
	{
			clearTimeout(myTimer);
			t1 = new Tween(scroller.style, 'right', Tween.regularEaseInOut, parseInt(scroller.style.right)+0, parseInt(scroller.style.right)+(myBlockWidth*myMoveBlocks), 2, 'px');
			hideControl();
			t1.start();
			setTimeout(showControl,2000);
			myTimer=setTimeout("doMove()",myMovePause);
			count+=myMoveBlocks;
	}
	else
	{
			scroller.style.right = (parseInt(scroller.style.right)-myMoveReset + 'px');
			count-=myBlockItems;
			toggleFour();
	}
}


function toggleBackward()
{
	if( count > (myMoveBlocks - 1) )
	{
			clearTimeout(myTimer);
			t1 = new Tween(scroller.style, 'right', Tween.regularEaseInOut, parseInt(scroller.style.right)+0, parseInt(scroller.style.right)-(myBlockWidth*myMoveBlocks), 2, 'px');
			hideControl();
			t1.start();
			setTimeout(showControl,2000);
			myTimer=setTimeout("doMove()",myMovePause);
			count-=myMoveBlocks;
	}
	else
	{
			document.getElementById('scroller').style.right = (parseInt(scroller.style.right)+myMoveReset + 'px');
			count+=myBlockItems;
			toggleOneBack();
	}
}

function stopCount()
{
	clearTimeout(myTimer);
}




