var Dicas = {
	
	oDTs: null,
	oDDs: null,
	current: 0,
	
	Botoes: {
		oAnteriorOff: null, oProximoOff: null, oAnteriorOn: null, oProximoOn: null
	},
	
	toggle: function(e) {
		var src, oAnterior, oProximo
		
		// Seleciona o elemento que disparou o evento (link)
		src = e.currentTarget
		
		// Cancela a ação do link
		e.preventDefault()
		
		// Atualiza o índice da dica atual
		Dicas.current = (src.getAttribute('id') == 'nav-anterior') ? Dicas.current -= 1 : Dicas.current += 1
		
		// Esconde todas as dicas
		each(Dicas.oDTs, function(el, i) { remClass(el, 'show'); remClass(Dicas.oDDs[i], 'show') })
		
		//Mostra a dica atual
		addClass(Dicas.oDTs[Dicas.current], 'show')
		addClass(Dicas.oDDs[Dicas.current], 'show')
		
		// Seleciona os botões 'Anterior' e 'Próximo'
		oAnterior = getElem('nav-anterior')
		oProximo = getElem('nav-proximo')
		
		// Se for a primeira dica, desabilita o botão 'Anterior', senão, habilita
		if (Dicas.current == 0) 
			oAnterior.parentNode.replaceChild(Dicas.Botoes.oAnteriorOff, oAnterior)
		else if (oAnterior.nodeName.toLowerCase() == 'span') 
			oAnterior.parentNode.replaceChild(Dicas.Botoes.oAnteriorOn, oAnterior)
		
		// Se for a última dica, desabilita o botão 'Próximo', senão, habilita
		if (Dicas.current == Dicas.oDTs.length - 1) 
			oProximo.parentNode.replaceChild(Dicas.Botoes.oProximoOff, oProximo)
		else if (oProximo.nodeName.toLowerCase() == 'span') 
			oProximo.parentNode.replaceChild(Dicas.Botoes.oProximoOn, oProximo)
		
	},
	
	init: function() {
		
		// Botões
		Dicas.Botoes.oAnteriorOn = document.createElement('a')
		Dicas.Botoes.oAnteriorOn.setAttribute('id', 'nav-anterior')
		Dicas.Botoes.oAnteriorOn.setAttribute('title', 'Dica anterior')
		Dicas.Botoes.oAnteriorOn.appendChild(document.createTextNode('Anterior'))
		
		Dicas.Botoes.oProximoOn = document.createElement('a')
		Dicas.Botoes.oProximoOn.setAttribute('id', 'nav-proximo')
		Dicas.Botoes.oProximoOn.setAttribute('title', 'Próxima dica')
		Dicas.Botoes.oProximoOn.appendChild(document.createTextNode('Próxima'))
		
		Dicas.Botoes.oAnteriorOff = document.createElement('span')
		Dicas.Botoes.oAnteriorOff.setAttribute('id', 'nav-anterior')
		Dicas.Botoes.oAnteriorOff.appendChild(document.createTextNode('Anterior'))

		Dicas.Botoes.oProximoOff = document.createElement('span')
		Dicas.Botoes.oProximoOff.setAttribute('id', 'nav-proximo')
		Dicas.Botoes.oProximoOff.appendChild(document.createTextNode('Próxima'))
		
		Dicas.oDTs = getAll('dt', 'dicas')
		Dicas.oDDs = getAll('dd', 'dicas')
		
		for (i = 0; i < Dicas.oDTs.length; i++) 
			if (hasClass(Dicas.oDTs[i], 'show')) { Dicas.current = i; break }
		
		addEvent(getAll('a', 'navegacao').merge([Dicas.Botoes.oAnteriorOn, Dicas.Botoes.oProximoOn]), 'click', Dicas.toggle)
		
	}
	
}
