// Istruzioni:
// 1) Impostare il nome dell'elemento contenitore (es. scroll) nella pagina principale
// 2) Impostare velocità, distanza fra i blocchi che scorrono e posizione di partenza del 
//	primo blocco
// 3) Creare nella pagine .htm dello scroll 2 DIV identiche (che contengano 2 tabelle identiche)
//	una chiamata "datacontainer" e una chiamata "datacontainer2"

// Impostazioni:
var nomeContenitore = "wScroll"
var scrollspeed = 2
var distanzaFineInizio = 50
// inizio: "top", "middle", "bottom"
var inizio = "top"
// -- Fine impostazioni
var altezzaScroll
var thelength
var thelength2
var numContenitore

function initialize()
{
eval("marqueeheight=document.all? parent.document.all." + nomeContenitore + ".offsetHeight : parent.document.getElementById('" + nomeContenitore + "').style.offsetHeight")
altezzaScroll = parseInt(marqueeheight) - (parseInt(marqueeheight) * 12 / 100)
dataobj=document.all? document.all.datacontainer : document.getElementById("datacontainer")
dataobj2=document.all? document.all.datacontainer2 : document.getElementById("datacontainer2")
dataobj.style.position = "absolute"
dataobj2.style.position = "absolute"
thelength=dataobj.offsetHeight
thelength2=dataobj2.offsetHeight
if (inizio == "bottom")
	dataobj.style.top=altezzaScroll
if (inizio == "top")
	dataobj.style.top = 1
if (inizio == "middle")
	dataobj.style.top = altezzaScroll / 2
dataobj2.style.top = parseInt(dataobj.style.top) + parseInt(thelength) + parseInt(distanzaFineInizio)
thelength < 10 ? thelength = 1000 : thelength = dataobj.offsetHeight
thelength2 < 10 ? thelength2 = 1000 : thelength2 = dataobj2.offsetHeight
numContenitore = 1
setTimeout("scrolltest()",1000)
}

function scrolltest()
{
	dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed
	dataobj2.style.top=parseInt(dataobj2.style.top)-scrollspeed

	if (numContenitore == 1)
	{
		obj = dataobj
		obj2 = dataobj2
	}
	else
	{
		obj = dataobj2
		obj2 = dataobj
	}
	//CONTROLLO FINE SCROLL CORRENTE:
	if (parseInt(obj.style.top) < 0)
	{
		if ((parseInt(obj.style.top)*(-1) + altezzaScroll) >= thelength)
		{
			if (numContenitore == 1)
			{
				obj = dataobj2
				obj2 = dataobj
				numContenitore = 2
			}
			else
			{	
				obj = dataobj
				obj2 = dataobj2
				numContenitore = 1
			}
			obj.style.top=altezzaScroll + parseInt(distanzaFineInizio)

		}
	}
	setTimeout("scrolltest()",130)
}




