var marcasL, tdWidth, windowSize, i, tbl, tableWidth, leftLimit, right;

function initMarcas() {
	marcasL    = 0; // "position left" inicial
	tdWidth    = 130; //largura de cada TD: 88 pixels da logo + 36 pixels de padding;
	windowSize = 630; //124 x 5 (visualização a cada clique)
	i = 1;			 //iterarador do numero de cliques para a esquerda
	
	tbl		   = document.getElementById("marcas");
	tableWidth = document.getElementsByTagName("td").length * tdWidth;	
	leftLimit  = tableWidth - windowSize;	
	
	right = false;
}


function moveLeft(r) {					
		
		if(r!=null) right = false;
		
		if(marcasL > -leftLimit && !right) {
			var tblL = marcasL - 20;		
			tbl.style.left = tblL + "px";
			if(tblL > -leftLimit) marcasL = marcasL - 20;
			
			if( marcasL > -(i*windowSize) ) window.setTimeout("moveLeft()",10);	
			else {i++;}						
		}	

}

function movR(n) {	
		var n1 = Number(n);
		if(n1 < 0 && right) {
				
			var tblR = n1 + 20;
			tbl.style.left = tblR + "px";
			if(tblR < 0) n1 += 20;
			window.setTimeout("movR(" + n1 + ")",10);
		}
}

function moveRight() {
	right = true;
	i = 1;
	marcasL = 0;			
	var mRight = tbl.style.left.substring(0, tbl.style.left.indexOf("p"));	
	movR(mRight);		
}