// JavaScript Document]

__timeScroll = null;
__movePx = null;
__scrollPos = new Array;
__scrollMax = null;
__directionScroll = null;
__time2Move = 5;
__typeScroll = 'News';

__qtdMovePx = 12;

function scrollDownNews(type)
{
	if(!type)
		type = __typeScroll;
	__directionScroll = 1;
	__movePx = - __qtdMovePx;
	moveScroll(type,__directionScroll);
}

function scrollUpNews(type)
{
	 if(!type)
                type = __typeScroll;

	__directionScroll = 2;
	__movePx =  __qtdMovePx;
	moveScroll(type,__directionScroll);
}

function moveScroll(type,direction)
{
	if(!type)
		type =  __typeScroll;

	if(!__scrollPos[type])
		__scrollPos[type] = 0;
	
	//document.getElementById('debug').innerHTML += type+"<br/>";

	//alert(type);
	news = document.getElementById('scroll'+type);
	hN = getHeight(news);
	
	areaNews = document.getElementById('list'+ type);
	aH = getHeight(areaNews);
	
	var __scrollMax = aH - hN - 200 ;
	
	if((null != __movePx)&&((__scrollPos[type]>__scrollMax)||(__scrollPos[type]<0)))
	{
		__scrollPos[type]+=__movePx;
		
		if(__scrollPos[type]<__scrollMax&&direction==1)
			__scrollPos[type]=__scrollMax;
		else if(__scrollPos[type]>0 && direction==2)
			__scrollPos[type] =0 ;
		
		news.style.marginTop = __scrollPos[type]+'px';
		//news.scrollTop = __scrollPos+'px';
		
		setTimeout("moveScroll('"+type+"','"+direction+"')",__time2Move);
	}
	else
	{
		stopScroll();
	}
}

function stopScroll()
{
	clearTimeout(__timeScroll);
	 __movePx = null;
	 __scrollMax = null;
}

function debug(text)
{
	document.getElementById('debug').innerHTML += text + '<br />';
}
