//Manual Scroller- © Dynamic Drive 2001
//For full source code, visit http://www.dynamicdrive.com

//specify speed of scroll (greater=faster)
var speed = 3;

var iens6 = (document.all || document.getElementById);
var ns4 = document.layers;

var crossobj = null;
var contentheight = 0;
var contentwidth = 0;
var largura_maxima = 0;
var altura_maxima = 0;

function scroll_init(poObjeto, pcCamada, pnWidth, pnHeight) {
	largura_maxima = pnWidth;
	altura_maxima = pnHeight;
	document.write('<ilayer name="nscontainer" width="' + pnWidth + '" height="' + pnHeight + '" clip="0, 0, ' + pnWidth + ', ' + pnHeight + '">');
	document.write('<layer name="nscontent" width="' + pnWidth + '" height="' + pnHeight + '" visibility="hidden">');
	if (iens6) {
		document.write('<div id="container" style="position:relative;width:' + pnWidth + 'px;height:' + pnHeight + 'px;overflow:hidden;">');
		document.write('<div id="content" style="position:absolute;left:0px;top:0px">');
	}
	//document.write(pcTexto);
	document.write(document.getElementById(pcCamada).innerHTML);
	if (iens6) {
		document.write('</div></div>');
		crossobj = document.getElementById? document.getElementById("content") : document.all.content;
		contentheight = crossobj.offsetHeight;
		contentwidth = crossobj.offsetWidth;
	} else if (ns4){
		crossobj = document.nscontainer.document.nscontent;
		contentheight = crossobj.clip.height;
		contentwidth = crossobj.clip.width;
	}
	document.write('</layer>');
	document.write('</ilayer>');
	
	window.onload=getcontent_height;
}

function movedown(){
if (window.moveupvar) clearTimeout(moveupvar)
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+altura_maxima))
	crossobj.style.top=parseInt(crossobj.style.top)-speed+"px";
else if (ns4&&crossobj.top>=(contentheight*(-1)+altura_maxima))
	crossobj.top-=speed;
movedownvar=setTimeout("movedown()",20);
}

function moveup(){
if (window.movedownvar) clearTimeout(movedownvar)
if (iens6&&parseInt(crossobj.style.top)<=0)
	crossobj.style.top=parseInt(crossobj.style.top)+speed+"px";
else if (ns4&&crossobj.top<=0)
	crossobj.top+=speed;
moveupvar=setTimeout("moveup()",20);
}

function moveleft(){
if (window.moverightvar) clearTimeout(moverightvar);
if (iens6&&parseInt(crossobj.style.left)<=0)
	crossobj.style.left=parseInt(crossobj.style.left)+speed+"px";
else if (ns4&&crossobj.left<=0)
	crossobj.left+=speed;
moveleftvar=setTimeout("moveleft()",20);
}

function moveright(){
if (window.moveleftvar) clearTimeout(moveleftvar);
if (iens6&&parseInt(crossobj.style.left)>=(contentwidth*(-1)+largura_maxima))
	crossobj.style.left=parseInt(crossobj.style.left)-speed+"px";
else if (ns4&&crossobj.left>=(contentwidth*(-1)+largura_maxima))
	crossobj.left-=speed;
moveleftvar=setTimeout("moveright()",20);
}

function stopscroll(){
	if (window.moveupvar) clearTimeout(moveupvar);
	if (window.movedownvar) clearTimeout(movedownvar);
	if (window.moverightvar) clearTimeout(moverightvar);
	if (window.moveleftvar) clearTimeout(moveleftvar);
}

function movetop(){
stopscroll()
if (iens6)
	crossobj.style.top=0+"px";
else if (ns4)
	crossobj.top=0;
}

function getcontent_height() {
	if (iens6) {
		contentheight = crossobj.offsetHeight;
		contentwidth = crossobj.offsetWidth;
	} else if (ns4) {
		document.nscontainer.document.nscontent.visibility = "show";
	}
}