var lastGo = Array();
var moving = 0;


function goRight(id, maxWidth)
{
	clearTimeouts(lastGo);
	px = 200;

	if(document.getElementById(id).scrollLeft + maxWidth == document.getElementById(id).scrollWidth)
	{
		for(i = document.getElementById(id).scrollWidth; i > 0; i--)
		{
			lastGo.push(window.setTimeout("scroll_e('" + id + "', -15);",  i * 20));
		}
	}
	else
	{
		for(i = 0; i < px / 3; i++)
		{
			lastGo.push(window.setTimeout("scroll_e('" + id + "', 3);",  i * 20));
		}
	}
}

function goLeft(id)
{
	clearTimeouts(lastGo);
	px = 200;
	
	if(document.getElementById(id).scrollLeft == 0)
	{
		for(i = 0; i < document.getElementById(id).scrollWidth; i++)
		{
			lastGo.push(window.setTimeout("scroll_e('" + id + "', 15);",  i * 20));
		}
	}
	else
	{
		for(i = 0; i < px / 3; i++)
		{
			lastGo.push(window.setTimeout("scroll_e('" + id + "', -3);",  i * 20));
		}
	}
}

function clearTimeouts(arr)
{
	for(i = 0; i < arr.length; i++)
	{
		window.clearTimeout(arr[i]);
	}
	
	arr = Array();
}

function scroll_e(id, left)
{
	document.getElementById(id).scrollLeft += left;
}
