// JavaScript Document

function startScrolling()
{
	var i, actDiv, prevDiv, divMinHeight, actHeight;
	
	if(typeof(scrollerList.length)!="undefined")
	{
		actDiv=document.getElementById(scrollerList[0]+"");
		containerHeight=actDiv.parentNode.offsetHeight;
		actDiv.style.top=containerHeight;
		actDiv.style.left=0;
		divMinHeight=actDiv.offsetHeight;
		prevDiv=actDiv;
		for(i=1; i<scrollerList.length; i++)
		{
			actDiv=document.getElementById(scrollerList[i]);
			actDiv.style.left=0;
			actDiv.style.top=parseInt(prevDiv.style.top)+prevDiv.offsetHeight;
			actHeight=actDiv.offsetHeight;
			divMinHeight=(divMinHeight<actHeight)? divMinHeight: actHeight;
			prevDiv=actDiv;
		}
		
		timer=setInterval("scrUp()", timeInterval);
	}
}

function scrUp()
{
	var i, count, actDiv, lastDiv;
	
	for(count=0, i=0; count<scrollerList.length; count++)
	{
		actDiv=document.getElementById(scrollerList[i]);
		if(parseInt(actDiv.style.top)>=-actDiv.offsetHeight)
		{
			actDiv.style.top=parseInt(actDiv.style.top)-actSpeed;
			i++;
		}
		else
		{
			lastDiv=document.getElementById(scrollerList[scrollerList.length-1]);
			actDiv.style.top=Math.max(parseInt(lastDiv.style.top)+lastDiv.offsetHeight, containerHeight);
			scrollerList.push(scrollerList.shift());
		}
	}
}

function pause(actDiv)
{
	actSpeed=0;
	actDiv.style.color="#FF9900";
}

function restart(actDiv)
{
	actSpeed=speed;
	actDiv.style.color="#FFFFFF";
}

function errorHandler(msg, url, line) 
{
	alert("Errore javascript: "+msg+"\n pagina: "+url+" linea: "+line);
	return true;
}
