var imgTimer;
imageAmount = 3;
Interval = 7000;

window.onload = function()
{
	imgTimer = setTimeout("imgToRight("+imageAmount+")", Interval);
}

function imgToRight(imgAmount)
{
	clearTimeout(imgTimer);
	var container = document.getElementById("img_scroller_container");
	
	container.scrollLeft+=4;
	
	var nextC = container.scrollLeft % 580;
	if(nextC == 0)
	{
		if(container.scrollLeft == (imgAmount-1) * 580)
			imgTimer = setTimeout("imgToLeft("+imgAmount+")",Interval);
		else
			imgTimer = setTimeout("imgToRight("+imgAmount+")",Interval);
	}
	else
	{
		imgTimer = setTimeout("imgToRight("+imgAmount+")",10);
	}
	

}

function imgToLeft(imgAmount)
{
	clearTimeout(imgTimer);
	var container = document.getElementById("img_scroller_container");
	
	container.scrollLeft-=4;
	
	var nextC = container.scrollLeft % 580;
	if(nextC == 0)
	{
		if(container.scrollLeft == 0)
			imgTimer = setTimeout("imgToRight("+imgAmount+")",Interval);
		else
			imgTimer = setTimeout("imgToLeft("+imgAmount+")",Interval);
	}
	else
	{
		imgTimer = setTimeout("imgToLeft("+imgAmount+")",10);
	}
	

}
