$(document).ready(function() {
	
	//anima��o home
	if ($("#animacao").length>0) {
		$("#animacao .slides").cycle({
			fx:		'fade',
			timeout:5000,
			pager:	'#animacao .nav',
			pause:	true,
			pauseOnHover: true
		});
	}
	
	//anima��o home interna
	if ($("#animacao2").length>0) {
		var i = 0;
		$("#animacao2 .slides .slide").each(function(){
			$(this).attr("id","slide_"+i);
			var lnk = $(this).find("a.link").attr("href");
			$(this).find("img").wrap('<a href="'+lnk+'" />');
			i++;
		});
		$("#animacao2 .slides").after('<div class="nav"></div><div class="info"><p class="titulo"></p><p class="descricao"></p><a class="link">Mais Informações</a></div>');
		$("#animacao2 .slides").cycle({
			fx:		'scrollVert',
			timeout:5000,
			pager:	'#animacao2 .nav',
			pause:	true,
			pauseOnHover: true,
			before: function(currSlideElement, nextSlideElement, options, forwardFlag) {
						$("#animacao2 .info").fadeOut("slow");
					},
			after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
						var id = nextSlideElement.id;
						var titulo = $("#animacao2 #"+id+" p.titulo").text();
						var descricao = $("#animacao2 #"+id+" p.descricao").text();
						var lnk = $("#animacao2 #"+id+" a").attr("href");
						$("#animacao2 .info p.titulo").text(titulo);
						$("#animacao2 .info p.descricao").text(descricao);
						$("#animacao2 .info a.link").attr("href",lnk);
						$("#animacao2 .info").fadeIn("fast");
					}
		});
	}
	
	//abas da lateral
	if ($("#rightContent #fv").length>0) {
		
		//quebra nos thumbs
		$("#rightContent ul.thumbs").each(function(){
			$(this).find("li:nth-child(3n+3)").addClass("quebra")
		});
		
		var fv = $("#rightContent #fv");
		fv.find(".conteudo .conteudo-tab").hide();
		fv.find("ul.tabs li:first a").addClass("active");
		var id = fv.find("ul.tabs li:first a").attr("rel");
		fv.find("#"+id).show();
		fv.find("ul.tabs li a").click(function(){
			fv.find(".conteudo .conteudo-tab").hide();
			fv.find("ul.tabs li a").removeClass("active");
			$(this).addClass("active");
			var id = $(this).attr("rel");
			fv.find("#"+id).show();
			return false;
		});

	}

		
	//fancybox - ampliar fotos
	$("a.fancybox-foto").fancybox();

	//fancybox - ampliar video
	$("a.fancybox-video").fancybox({
		'width'				: 480,
		'height'			: 390,
		'autoScale'     	: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'                  : 'iframe'
	});
	
	
	//modal tarifas
	if ($("a.tarifas").length>0) {
		
		$("body").append('<div id="mask" />');
		
		$('a.tarifas').click(function(e) {
			e.preventDefault();
			var id = "#modal-tarifas";
			var maskHeight = $(document).height();
			var maskWidth = $(window).width();
			$('#mask').css({'width':maskWidth,'height':maskHeight});
			$("iframe").hide();
			$('#mask').fadeIn(500);	
			$('#mask').fadeTo("slow",0.82);	
			var winH = $(window).height();
			var winW = $(window).width();
			$(id).css('top',  (winH/2-$(id).height()/2) + $(document).scrollTop() );
			$(id).css('left', winW/2-$(id).width()/2);
			$(id).fadeIn(1000);
		});
		$('#modal-tarifas .close').click(function (e) {
			e.preventDefault();
			$('#mask').hide();
			$('#modal-tarifas').hide();
			//$("iframe").show();
		});		
		$('#mask').click(function () {
			$(this).hide();
			//$("iframe").show();
			$('#modal-tarifas').hide();
		});
		
	}
	
	
	//ajustezinho na assinatura
	$("#footer .criacao a").html("&nbsp;");
	
});
