// jQuery
$(function(){
	// Carrega o XML do portfolio
	var portfolioXML = $.ajax({
		type: "GET",
		dataType: "xml",
		url: "media/xml/portfolio.xml",
		success: function(xml){
			// Sorteia e coloca um item no rodapé
			var $projetoTotal = $(xml).find('projeto').size();
			var $projetoIndex = Math.floor(Math.random()*$projetoTotal);
			$(xml).find('projeto:eq('+$projetoIndex+')').each(function() {
			
				var $projeto = $(this);
				var $status = $projeto.attr('status');
				$('#rodape #projetos').find('#imagem img').attr('src',$projeto.attr('home'))
				.end().find('#cliente span').html($projeto.attr('cliente'))
				.end().find('#titulo span').html($projeto.attr('titulo'))
				.end().find('#titulo a').attr('href','nossos-projetos.php#'+$projeto.index());
				
					
				if($status == 'novo') {
					$('#imagem .status strong').text('Novo');
					$('#imagem .status').addClass($status);
				} else if($status == 'atualizado') {
					$('#imagem .status strong').text('Atualizado');
					$('#imagem .status').addClass($status);
				}
			});
		},
		error: function(request,error) {
			console.error(error);
		}
	});
});
