//Div panel 1
content = document.getElementById('panel');
ctrls = [
	document.getElementById('down'),
	document.getElementById('up')
//        document.getElementById('left'),
//        document.getElementById('right')
];

pixels = 2;
lastScroll = 0;
timeOut = null;

stopScrolling = function(){
	clearTimeout( timeOut );
}

scrollIt = function( vertScroll, goUp ){
//	alert('tsete');
	if( vertScroll )
		content.scrollTop += goUp ? -pixels : pixels;
	else
		content.scrollLeft += goUp ? -pixels : pixels;
		if( vertScroll ? ( lastScroll == content.scrollTop ) : ( lastScroll == content.scrollLeft ) )
			return false;
		lastScroll = vertScroll ? content.scrollTop : content.scrollLeft;
		if( timeOut != null )
			clearTimeout( timeOut );
		timeOut = setTimeout( 'scrollIt(' + vertScroll + ',' + goUp + ')', 50 );
}

// Direita e esquerda
//ctrls[0].onmouseover = function(){ scrollIt( false, false ); }
//ctrls[1].onmouseover = function(){ scrollIt( false, true ); }

// Cima e Baixo - Removido por sobescrever o preloadimages do botao, entao a funcao foi inserida diretamente na tag
//ctrls[0].onmouseover = function(){ scrollIt( true, false ); }
//ctrls[1].onmouseover = function(){ scrollIt( true, true ); }

// Idem item acima
//for( i = 0; i < ctrls.length; i++ )
//	ctrls[i].onmouseout = function(){ stopScrolling(); };

//Fim Div panel 1




//Div panel 2
content2 = document.getElementById('panel_2');
ctrls2 = [
	document.getElementById('down_2'),
	document.getElementById('up_2')
//        document.getElementById('left'),
//        document.getElementById('right')
];

pixels2 = 2;
lastScroll2 = 0;
teste = null;

stopScrolling2 = function(){
	clearTimeout( teste );
}

scrollIt2 = function( vertScroll2, goUp2 ){
	if( vertScroll2 )
		content2.scrollTop += goUp2 ? -pixels2 : pixels2;
	else
		content2.scrollLeft += goUp2 ? -pixels2 : pixels2;
		if( vertScroll2 ? ( lastScroll2 == content2.scrollTop ) : ( lastScroll2 == content2.scrollLeft ) )
			return false;
		lastScroll2 = vertScroll2 ? content2.scrollTop : content2.scrollLeft;
		if( teste != null )
			clearTimeout( teste );
		teste = setTimeout( 'scrollIt2(' + vertScroll2 + ',' + goUp2 + ')', 50 );
}

// Direita e esquerda
//ctrls[0].onmouseover = function(){ scrollIt( false, false ); }
//ctrls[1].onmouseover = function(){ scrollIt( false, true ); }

// Cima e Baixo - Removido por sobescrever o preloadimages do botao, entao a funcao foi inserida diretamente na tag
//ctrls[0].onmouseover = function(){ scrollIt( true, false ); }
//ctrls[1].onmouseover = function(){ scrollIt( true, true ); }

// Idem item acima
//for( i = 0; i < ctrls.length; i++ )
//	ctrls[i].onmouseout = function(){ stopScrolling(); };

//Fim Div panel 2

