var scrollposition = 0;
var _step = 146;
var scrollIds = ['scroll1','scroll2','scroll3','scroll4'];
var scrollObjs = [];

function initScroll()
{
	for(var i=0; i < scrollIds.length; i++)
	{
		var ul = document.getElementById(scrollIds[i]);
		if(ul)
		{
			var _as = ul.parentNode.parentNode.parentNode.getElementsByTagName('a');
			for(var j=0; j < _as.length; j++)
			{
				if(_as[j].className.indexOf("left-scroll") != -1)
				{
					_as[j].href = "javascript:;";	
					_as[j].onclick = _prev;
					_as[j]._index = i;
					ul._left = _as[j];

				}
				if(_as[j].className.indexOf("right-scroll") != -1)
				{
					_as[j].href = "javascript:;";	
					_as[j].onclick = _next;
					_as[j]._index = i;
					ul._right = _as[j];
				}
			}
			
			scrollObjs[i] = ul;
	
/*
				if(20 < ul.parentNode.offsetLeft + ul.offsetWidth - ul.parentNode.parentNode.offsetWidth)
				{
					anext.style.display = "block";
				}		
				if(ul.parentNode.offsetLeft < 0)
				{
					aprev.style.display = "block";
				}		
*/
		}
	}
}

function _next()
{
	var ul = scrollObjs[this._index];
	if(20 < ul.parentNode.offsetLeft + ul.offsetWidth - ul.parentNode.parentNode.offsetWidth)
	{
		ul.parentNode.style.left = ul.parentNode.offsetLeft - _step + "px";
		//ul._left.style.display = "block";
	}
	if(20 >= ul.parentNode.offsetLeft + ul.offsetWidth - ul.parentNode.parentNode.offsetWidth)
	{
		//ul._right.style.display = "none";
	}
}

function _prev()
{
	var ul = scrollObjs[this._index];
	if(ul.parentNode.offsetLeft < 0)
	{
		ul.parentNode.style.left = ul.parentNode.offsetLeft + _step + "px";
		//ul._right.style.display = "block";
	}
	if(ul.parentNode.offsetLeft == 0)
	{
		//ul._left.style.display = "none";
	}
}

if (window.addEventListener)
	window.addEventListener("load", initScroll, false);
else if (window.attachEvent)
	window.attachEvent("onload", initScroll);