$(document).ready(function (){
	$(".corpo_tooltip").hover(
		function(){
			$(this).find("a").animate({"top":"0"}, 500);
		},
		function(){
			$(this).find("a").stop(true).animate({"top":"100%"}, 500);
		}
	);

	$("#lista_noticias").html("<center>carregando</center>");
	$.get("/util/xml/noticias.xml", function (data){
		$("#lista_noticias").find("*").remove();
		var idx = 0;
		$(data).find("noticia:lt(3)").each(function(idx, elm){
				var titulo_chamada = $(elm).find("titulo_chamada").text();
				var chamada = $(elm).find("chamada").text();
				$("<div class='corpo_noticia_home'></div>").html("<a href='/noticias/noticia.html?p="+idx+"'><h3>"+titulo_chamada+"</h3><p>"+chamada+"</p></a>").appendTo("#lista_noticias");
		idx++;
		});
		$(".corpo_noticia_home").first().addClass("no-m");
	});
	
	$("#corpo_nossos_trabalhos").html("<center>carregando</center>");
	$.get("/util/xml/nossos_trabalhos.xml", function (data){
		$("#corpo_nossos_trabalhos").find("*").remove();
		var idx = 0;
		$(data).find("destaque:lt(6)").each(function(idx, elm){
				var image = $(elm).find("img").text();
				var title = $(elm).find("titulo").text();
				var texto =	$(elm).find("texto").text();
				var link = $(elm).find("link").text();
				
				$("<div class='corpo_tooltip'></div>").html("<img src='"+image+"' alt='"+texto+"' /><a href='"+link+"'><h2>"+title+"</h2><span>"+texto+"</span></a>").appendTo("#corpo_nossos_trabalhos");
			$(".corpo_tooltip").hover(
					function(){
						$(this).find("a").animate({"top":"0"}, 500);
					},
					function(){
						$(this).find("a").stop(true).animate({"top":"100%"}, 500);
					}
				);
		idx++;
		});
	});
	
	if ($("#carrousel").length > 0){
		$("#carrousel").jCarouselLite({
			vertical: true,
			btnNext: ".btn_nextz",
			btnPrev: ".btn_prevz",
			visible: 3.1
		});
		
		$("#carrousel a").click(function (e){
			e.preventDefault();
			var img_selected = $(this).attr("href")
			$("#img_left_case_simples").html("<img src='"+img_selected+"'>")
		});
	}
	
	if ($("#content_redes_twitter").length > 0){
		$('.scroll-pane').jScrollPane({showArrows:true, autoReinitialise: true});
		$(".LoadTwitter").tweet({
			avatar_size: 45,
			count: 4,
			username: ["Urbansummer","urbansummer"]
		}).bind("loaded",function(){
				var scrl = $(".scroll-pane").data('jsp');
				//$('.scroll-pane').jScrollPane({showArrows:true, autoReinitialise: true});
				scrl.reinitialise();
			});
	}
	
});

