// JavaScript Document
function $(i){return document.getElementById(i)}
function $$(e,p){p=p||document; return p.getElementsByTagName(e)}

var PUB={};
PUB.inicia=function(idProp,qtdVisivel,t){
	this.div=$('posicao'+idProp);
	this.anuncios=$$('span',this.div);
	this.nAnuncios=this.anuncios.length;
	this.q=qtdVisivel;
	this.ponteiro=0;
	for(i=0;i<this.nAnuncios;i++)
		this.anuncios[i].style.display='none';
	
	for(i=0;i<this.nAnuncios&&i<qtdVisivel;i++){
			this.anuncios[this.ponteiro].style.display='block';
			this.ponteiro++;
	}

	if(!(this.nAnuncios<=qtdVisivel)){
		this.tout=setTimeout(new Function('PUB'+idProp+'.rota('+t+','+idProp+')'),t);
	}
}
PUB.inicia.prototype={
	rota:function(t,idProp){
		for(i=0;i<this.nAnuncios;i++)
			this.anuncios[i].style.display='none';
		for(i=0;i<this.q;i++){
			this.anuncios[this.ponteiro].style.display='block';
			if(this.ponteiro<this.nAnuncios-1)
				this.ponteiro++;
			else
				this.ponteiro=0;
		}
		clearTimeout(this.tout);
		this.tout=setTimeout(new Function('PUB'+idProp+'.rota('+t+','+idProp+')'),t);
	}
}
