
function Highlights(){}

//Inicia as variaveis globais
var nowRegs;
var interval;
var reg = new Array();
var totalRegs;

//Inicia as funções orientadas
Highlights.prototype = {
	
	//Função que inicializa o sistema
	init:function(){
		var _a;
		nowRegs = 1;
		
		//Configura os ID's
		for(_a=1;_a<(totalRegs+1);_a++){
			reg[_a] = 'destaque_'+_a;
			if(_a == 1){
				//Caso seje a primeira aparece
				//document.getElementById(reg[_a]).style.display = 'inline';
				$('#'+reg[_a]).show();
			}else{
				//Caso contrario não
				//document.getElementById(reg[_a]).style.display = 'none';
				$('#'+reg[_a]).hide();
			}
		}
		
		//Inicia o loop dos registros
		this.startReg();
	},
	
	//Função para setar o total de registros
	setValues:function(a){
		
		//Verifica se é numero
		var er = /^[0-9]+$/;
		if(er.test(a)){
			totalRegs = a;
		}
	},
	
	//Função para alternar entre um registro e outro
	nextReg:function(){
		
		//Verifica se o registro é igual ao total
		if(nowRegs == totalRegs){
			
			//Caso sim retorna ao começo do loop
			//document.getElementById(reg[nowRegs]).style.display = 'none';
			$('#'+reg[nowRegs]).hide();
			nowRegs = 1;
			$('#'+reg[nowRegs]).show();
			//document.getElementById(reg[nowRegs]).style.display = 'inline';
		}else{
			
			//Caso não verifica se é menor que o total
			if(nowRegs < totalRegs){
				
				//Caso sim efetua o loop
				//document.getElementById(reg[nowRegs]).style.display = 'none';
				$('#'+reg[nowRegs]).hide();
				nowRegs += 1;
				$('#'+reg[nowRegs]).show();
				//document.getElementById(reg[nowRegs]).style.display = 'inline';
			}
		}
	},
	
	setReg:function(c){
		if(c <= totalRegs){
			//document.getElementById(reg[nowRegs]).style.display = 'none';
			$('#'+reg[nowRegs]).hide();
			nowRegs = c;
			$('#'+reg[nowRegs]).show();
			//document.getElementById(reg[nowRegs]).style.display = 'inline';
		}
	},
	
	//Função para pagar o loop dos registros
	stopReg:function(){
		
		//finaliza o intervalo
		clearInterval(interval);
	},
	
	//Função para iniciar o loop dos registros
	startReg:function(b){
		
		//verifica se é para iniciar passar um registro ao evento
		if(b){
			
			//Caso sim passa um registro e inicia o intervalo
			this.nextReg();
			interval = setInterval("Highlights.nextReg()",3000);
		}else{
			
			//Caso não inicia o intervalo sem passar um registro
			interval = setInterval("Highlights.nextReg()",3000);
		}
	}
}
