var _manchetesdodia_tmp = window.onload;

var ALTURA_m = 56; NUMDE_ITERACOES_m = 7,
	PASSO_m = ALTURA_m / NUMDE_ITERACOES_m,
	PAUSA_m = 4000;

window.onload = function() {
	_manchetesdodia_tmp();
	
	var pais = new Rolo(document.getElementById("manchetesdodia").getElementsByTagName("ul")[0], 56);
	var interior = new Rolo(document.getElementById("manchetesdodia").getElementsByTagName("ul")[1], 84);
}

function Rolo(lista, altura_m) {
	this.altura_m = altura_m;
	this.passo_m = altura_m / NUMDE_ITERACOES_m;
	this.lista_m = lista;
	this.itens_m = this.lista_m.getElementsByTagName("li");
	this.tamanho_real_m = this.itens_m.length - 3;
	this.topo_maximo_m = - (this.itens_m.length - 1) * altura_m;
	this.lista_m.style.top = "-" + altura_m + "px";
	this.ativo_m = 1;

	var self = this;
	setTimeout(function() {self.mostrar_proxima_m()}, PAUSA_m);
}

Rolo.prototype.subir_m = function() {
	var topo = parseInt(this.lista_m.style.top) - this.passo_m;
	if(topo == this.topo_maximo_m) topo = -this.altura_m;

	this.lista_m.style.top = topo + "px";

	var self = this;
	if((topo) % this.altura_m == 0) {
		this.ativo_m = this.ativo_m + 1;
		if(this.ativo_m == this.tamanho_real_m + 1) {
			this.ativo_m = 1;
		}
		setTimeout(function() {self.mostrar_proxima_m()}, PAUSA_m);
	} else {
		setTimeout(function() {self.subir_m()}, 100);
	}
}

Rolo.prototype.mostrar_proxima_m = function() {
	this.subir_m();
}


