


function Ticker(noticias,campo,tempo){
	this.dados = [];
	this.index = -1;
	this.campo = document.getElementById(campo);
	this.noticias = document.getElementById(noticias);
	this.count = 0;
	this.tempo = tempo;
	this.interval = 0;
	this.waitInterval = 0;
	this.textAt;
	this.hrefAt;
	this.targetAt;
	this.init();
}

Ticker.prototype.init = function(){
	var nodes = this.noticias.getElementsByTagName('li');
	for (var i=0;i<nodes.length;i++) {
		var node = nodes[i];
		var a = node.getElementsByTagName('a');
		if(a.length > 0) {
			var text = a[0].innerHTML;
			var href = a[0].href;
			var target = a[0].target;
			this.addItem(text,href,target);
		} else {
			this.addItem(node.innerHTML,'','');
		}
	}
	this.next();
}

Ticker.prototype.addItem = function(text,href,target){
	this.dados.push( { text:text, href:href, target:target } );
}

Ticker.prototype.next = function(){
	clearInterval(this.waitInterval);
	if((this.index+1)<this.dados.length) this.index++;
	else this.index = 0;
	this.textAt = this.dados[this.index].text;
	this.hrefAt = this.dados[this.index].href;
	this.targetAt = this.dados[this.index].target;
	this.reset();
	this.update();
}

Ticker.prototype.reset = function(){
	this.campo.innerHTML ='';
	this.count = 0;
}

Ticker.prototype.wait = function(){
	clearInterval(this.waitInterval);
	var l = this;
	this.waitInterval = setInterval(function(){
		l.next();
		clearInterval(this.waitInterval);
	},this.tempo);
}

Ticker.prototype.write = function(){
	if(this.hrefAt.length > 0) {
		this.campo.innerHTML = '<a target="' + this.targetAt + '" href="' + this.hrefAt + '">' + this.textAt.substr(0,this.count) + '</a>';
	} else {
		this.campo.innerHTML = '<span>' + this.textAt.substr(0,this.count) + '</span>';
	}
	this.count++;
	if(this.count >= this.textAt.length + 1){
		clearInterval(this.interval);
		this.wait();
	}
}

Ticker.prototype.update = function(){			
	clearInterval(this.interval);
	var l = this;
	this.interval = setInterval(function(){
		l.write();
	},50);
}

	
function mudaRes(n) {
	document.getElementById('glbBarra').className = 'r' + n;
	document.body.className = 'res' + n;
	res = n;
	if (res>=1024) {
		document.getElementById('direita').style.marginLeft = '4px';
			} else if (res<=800) {
			document.getElementById('direita').style.marginLeft = '6px';
			}
			try {
			if(typeof trGLBload != 'undefined') trGLBload();
			} catch(e) {}
		}

		var tickerObj = new Ticker('naoPercaLista','naoPercaConteudo',2000);		