// JavaScript Document
////////////////////////////////////////////////////////////////////////////////
// "Scroll de Notícias"                                                       //
// Breno Damas M. Ribeiro                                                     //
// M.M. Informática - Desenvolvimento Web                                     //
// Iniciado em: 05/09/2006, última versão em: 08/09/2006                      //
////////////////////////////////////////////////////////////////////////////////
// Construtor ([objeto[,delay]]) => objeto: null, id ou obj... delay: milissegundos
var rolante=function () {
	var o=null;
	var d=50;

	var al=arguments.length;
	if(al>0) {
		o=arguments[0];
		if(typeof(o)==typeof('string')) {
			o=document.getElementById(o);
		}
		if(o!=null) {
			o.style.overflow='hidden';
			var h=o.clientHeight;
			o.innerHTML='<div style=\"height:'+h+'px;padding:0px;margin:0px;\">&nbsp;</div>'+o.innerHTML+'<div style=\"height:'+h+'px;padding:0px;margin:0px;\">&nbsp;</div>';
		}
		if(al>1) d=arguments[1];
	}

	this.div = o;
	this.delay = d;
	this.inter = null;

	delete o;
	delete d;
	delete al;
};

rolante.prototype.nome = function () {
	var k='';
	var o=null;
	for(k in window) {
		o=eval('window.'+k);
		if(o==this) {
			alert(k+'.passo');
			return k;
		}
	}
};

rolante.prototype.pausa = function () {
	if(this.inter!=null) clearInterval(this.inter);
	this.inter=null;
};

rolante.prototype.para = function () {
	if(this.inter!=null) clearInterval(this.inter);
	this.inter=null;
	this.div.scrollTop=0;
};

rolante.prototype.passo = function () {
	if(this.div!=null) {
		var p=1;
		if(arguments.length>0) p=arguments[0];
		if((this.div.scrollHeight-this.div.clientHeight)>this.div.scrollTop) {
			this.div.scrollTop+=p;
		} else {
			this.div.scrollTop=0;
		}
	}
};

rolante.prototype.inicia = function () {
	if(this.inter==null && this.div!=null) {
		hits=this;
		this.inter=window.setInterval('hits.passo()',this.delay);//verificar erro aqui...
	}
};
rolante.prototype.continua = rolante.prototype.inicia;