NoticiasRotativas = {
	
	json: '',
	noticiaAtiva: 0,
	total: 0,
	pausado: false,
	
	trocar: function() {
		$('#destaque-img').hide();
	
		var html_render;
		
		tmp_image = new Image();
		tmp_image.src = '/upload/img/thumb/'+NoticiasRotativas.json[NoticiasRotativas.noticiaAtiva].imagem;
				
		html_render = '<a class="img-noticia" href="/noticia/ler/id/'+NoticiasRotativas.json[NoticiasRotativas.noticiaAtiva].id+'">';
		html_render += '<img src="'+tmp_image.src+'" alt="" width="272" height="185" /></a>';
		
		$('#destaque-chamada').html('<a href="/noticia/ler/id/'+NoticiasRotativas.json[NoticiasRotativas.noticiaAtiva].id+'">'+NoticiasRotativas.json[NoticiasRotativas.noticiaAtiva].titulo+'</a>');
		$('#destaque-img').html (html_render);		
		$('#destaque-img').fadeIn();
	},
	
	proximaNoticia: function() {
		if ((NoticiasRotativas.noticiaAtiva + 1) < NoticiasRotativas.json.length) {
			NoticiasRotativas.noticiaAtiva++;
			NoticiasRotativas.trocar();
		} else {
			NoticiasRotativas.noticiaAtiva = 0;
			NoticiasRotativas.trocar();	
		}
	},
	
	noticiaAnterior: function() {
		if ((NoticiasRotativas.noticiaAtiva - 1) >= 0){
			NoticiasRotativas.noticiaAtiva--;
			NoticiasRotativas.trocar();
		} else {
			NoticiasRotativas.noticiaAtiva = NoticiasRotativas.json.length - 1;
			NoticiasRotativas.trocar();		
		}
	},
	
	pausarNoticia: function() {
		if (NoticiasRotativas.pausado == true) {
			NoticiasRotativas.pausado = false;
		} else {
			NoticiasRotativas.pausado = true;
		}
	},
	
	rotacao: function() {
		if (NoticiasRotativas.pausado == false) {
			NoticiasRotativas.proximaNoticia();	
		}
	},
	
	iniciar: function() {
		if (NoticiasRotativas.json.length > 0) {
			window.setInterval(NoticiasRotativas.rotacao,10000);
		}
	}
}
