var Root;
Root=new Object();
Root.ScrollUp=f_ScrollUp;
Root.ScrollStopAll=f_ScrollStopAll;
Root.ScrollStartAll=f_ScrollStartAll;
Root.ScrollDelay=f_ScrollDelay;

Root.Directions=new Array();
Root.Directions[2]="ScrollUp";

Root.Name="Root";
Root.Timer=-1;
Root.ScrollerOn=false;
Root.Delay=20;
Root.Speed=1;
Root.LastDir=2;
Root.StayB4Exit=0;
Root.SpotSpacing=6;
Root.Spot=new Array();

function InitScroller()
{
	Root.Layer=getLayer("divRoot");
	Root.AreaLeftX=0;
	Root.AreaLeftY=0;
	Root.AreaRightX=getWidth(Root.Layer);
	Root.AreaRightY=getHeight(Root.Layer);
	Root.XScroll=Root.AreaRightX/2;
	Root.YScroll=Root.AreaRightY/2;
	clipLayer(Root.Layer, Root.AreaLeftX, Root.AreaLeftY, Root.AreaRightX, Root.AreaRightY);
	for (i=0; i<Root.CountSpot; i++)
	{
		Root.Spot[i].Layer=getLayer("divSpot"+(i+1));
		moveLayerTo(Root.Spot[i].Layer, Root.XScroll-getWidth(Root.Spot[i].Layer)/2, Root.AreaRightY);
		showLayer(Root.Spot[i].Layer);
		Root.Spot[i].LastDir=Root.LastDir;
	}
	Root.Spot[0].Moving=true;
	Root.ScrollStartAll();
}

function f_ScrollUp()
{
	Top=getTop(this.Layer);
	Height=getHeight(this.Layer);
	if ( Top==Root.AreaLeftY )
	{
		moveLayerBy(this.Layer, 0, -1);
		Root.ScrollDelay();
	}
	else if ( Root.ScrollerOn && Top>(Root.AreaLeftY-Height) )
	{
		moveLayerBy(this.Layer, 0, -Root.Speed);
		this.Timer=setTimeout(this.Name+"."+Root.Directions[this.LastDir]+"();", Root.Delay);
	}
	else if ( Top<=(Root.AreaLeftY-Height) )
	{
		this.Moving=false;
		moveLayerTo(this.Layer, Root.XScroll-getWidth(this.Layer)/2, Root.AreaRightY);
	}
	if ( getBottom(this.Layer)==Root.AreaRightY-Root.SpotSpacing )
	{
		Index=(this.Index+1)<Root.CountSpot?this.Index+1:0;
		Root.Spot[Index].Moving=true;
		Root.Spot[Index].Layer.Timer=setTimeout(Root.Spot[Index].Name+"."+Root.Directions[Root.Spot[Index].LastDir]+"();", Root.Delay);
	}
}

function f_ScrollStop()
{
	clearTimeout(this.Timer);
}

function f_ScrollStart()
{
	this.Timer=setTimeout(this.Name+"."+Root.Directions[this.LastDir]+"();", Root.Delay);
}

function f_ScrollStopAll()
{
	Root.ScrollerOn=false;
	for (i=0; i<Root.CountSpot; i++)
		clearTimeout(this.Spot[i].Timer);
}

function f_ScrollStartAll()
{
	Root.ScrollerOn=true;
	for (i=0; i<Root.CountSpot; i++)
		if ( this.Spot[i].Moving )
			this.Spot[i].Timer=setTimeout(this.Spot[i].Name+"."+Root.Directions[this.Spot[i].LastDir]+"();", Root.Delay);
}

function f_ScrollDelay()
{
	this.ScrollStopAll();
	setTimeout("Root.ScrollStartAll();", Root.StayB4Exit);
}

