
function mlkPainelRolante(id, contentorID, velocidade, bDireitaParaEsquerda) {
  this.id = id;
  this.contentorID = contentorID;
  this.velocidade = velocidade;
  this.bDireitaParaEsquerda = bDireitaParaEsquerda;
  this.conteudo = document.getElementById(this.contentorID).innerHTML;
  document.getElementById(this.contentorID).style.overflow = 'hidden';
  if (document.getElementById(this.contentorID).style.width !== '') {
    this.largContentor = parseInt(document.getElementById(this.contentorID).style.width, 10);
  } else {
    this.largContentor = document.getElementById(this.contentorID).offsetWidth;
  }
  
}

mlkPainelRolante.prototype.inicia = function () {
	document.getElementById(this.contentorID).innerHTML = 
		'<table  cellspacing="0" cellpadding="0" width="100%">' +
		'<tr>' +
		  '<td><div style="height:0px; width:' + this.largContentor + 'px;"></div></td>' +		  
		  '<td style="white-space:nowrap;"><span id="' + this.id + '_conteudo" width="100%">&nbsp;</span></td>' +
		  '<td><div style="height:0px; width:' + this.largContentor + 'px;"></div></td>' +
		  '</tr>' +
		'</table>';
	document.getElementById(this.contentorID).scrollLeft = (this.bDireitaParaEsquerda ? document.getElementById(this.contentorID).scrollWidth - document.getElementById(this.contentorID).offsetWidth : 0);
	document.getElementById(this.id + '_conteudo').innerHTML = this.conteudo;
	document.getElementById(this.contentorID).style.display = 'block';
	this.roda();
}

mlkPainelRolante.prototype.roda = function () {
	if(!this.parado) {
	  document.getElementById(this.contentorID).scrollLeft += this.velocidade * (this.bDireitaParaEsquerda ? -1 : 1);
	}
	if (this.bDireitaParaEsquerda && document.getElementById(this.contentorID).scrollLeft <= 0) {
	  document.getElementById(this.contentorID).scrollLeft = document.getElementById(this.contentorID).scrollWidth - document.getElementById(this.contentorID).offsetWidth;
	}
	if(!this.bDireitaParaEsquerda && (document.getElementById(this.contentorID).scrollLeft >= (document.getElementById(this.contentorID).scrollWidth - document.getElementById(this.contentorID).offsetWidth))) {
	  document.getElementById(this.contentorID).scrollLeft = 0;
	}
	window.setTimeout(this.id + '.roda();', 30);
}

mlkPainelRolante.prototype.pausa = function (bParar) {
  this.parado = bParar;
}

