Destaque = 
{
	Itens : null,
	Indice : -1,
	Ordem : 1,
	Automatico : true,
	Timeout : null,
	Carregar : function(itens)
	{
		this.Itens = itens;
		this.Proximo();
    },
	
    Proximo : function()
	{
		this.Preencher(1);
    },
	
    Anterior : function()
	{
		this.Preencher(0);
    },
    Navegacao : function()
	{
		this.Automatico = !this.Automatico;
		var nav = document.getElementById("dnav");
		if(this.Automatico){
			nav.src = "template/vozdobico/images/nav_pause.jpg";
			this.Agendar();
		}else{
			nav.src = "template/vozdobico/images/nav_play.jpg";
			clearTimeout(this.Timeout);
		}
    },
	
    Executar : function()
	{
		this.Preencher(this.Ordem);
    },
	
	PreencherPorIndice : function ( index )
	{
		this.Atualizar(index);
		
		if(this.Automatico)
		{
			this.Agendar();
		}
	},
	
    Preencher : function( ordem )
	{
		this.Ordem = ordem;

		var aux = this.Indice;
		if(this.Ordem == 1)
		{
			aux = aux+1;
		}
		else
		{
			aux = aux-1;
		}
		
		if( (aux >= 0) && (aux <= (this.Itens.length-1)) )
		{
			this.Indice = aux;
		}
		else if( (aux < 0) )
		{
			this.Indice = aux = this.Itens.length-1;
		}
		else if( (aux > (this.Itens.length-1)) )
		{
			this.Indice = aux = 0;
		}
		
		this.Atualizar(aux);
		
		if(this.Automatico)
		{
			this.Agendar();
		}
    },
	
	Agendar : function()
	{
		clearTimeout(this.Timeout);
		this.Timeout = setTimeout("Destaque.Executar()", (1000*10));
	},
	
	Atualizar : function( index )
	{
		
		var links = document.getElementsByName('link_noticias');
		for(var i = 0; i < links.length; i++)
		{
			links[i].className = "flnavNumero";
		}
		var linkSelecionado = document.getElementById("noticia_"+index);
		linkSelecionado.className = "flnavNumero flnavNumeroSelecionado";
		
		var obj1 = document.getElementById("dlink");
		var obj2 = document.getElementById("dimg");
		var obj3 = document.getElementById("dtitulo");
		//var obj4 = document.getElementById("dchapeu");
		
		obj1.href = this.Itens[index][1];
		obj2.src = this.Itens[index][2];
		obj3.innerHTML = this.Itens[index][0];
		//obj4.innerHTML = this.Itens[index][3];
	}
}
