/**
 * Scrolls to the next logo
 */
function scrollToNext()
{
	/* reset margins for all nodes! */
	var nodes = $("client-list").getElementsByTagName("P");

	for (var i = 0; i < nodes.length; i++)
	{
		if (nodes[i].getElementsByTagName("IMG").length == 1)
		{
			nodes[i].style.margin = "0px";
		}
		else
		{
			$("client-list").removeChild(nodes[i]);
			//nodes[i] = null;
			//delete nodes[i];
		}
	}

	/* start scrolling (delay is to show the current logo for a short while) */
	if (nodes.length > 1)
	{
		setTimeout(_doScroll, 1000);
	}
} // function scrollToNext

/**
 * Handles the actual scrolling.
 */
function _doScroll()
{
	var firstNode = $("client-list").getElementsByTagName("P")[0];

	var newMarginTop = parseInt(firstNode.style.marginTop) - 1;
	firstNode.style.marginTop = newMarginTop + "px";

	if (newMarginTop <= -elementDimensions(firstNode).h)
	{
		updateList();
	}
	else
	{
		setTimeout(_doScroll, 20);
	}
} // function _doScroll

/**
 * Updates the UL, placing the first element at the end.
 * Calls scrollToNext() afterwards.
 */
function updateList()
{
	var firstNode = $("client-list").getElementsByTagName("P")[0];
	$("client-list").appendChild(firstNode);

	scrollToNext();
} // function updateList

/* start scrolling */
addLoadEvent(scrollToNext);
