$(document).ready(function() {	
	// tirar marginRight do último elemento do menu;
	$('#menu li:last-child').css('marginRight', '0');
	
	// efeito de cycle para o destaque na home;
	$('#destaque-home ul').cycle({ 		 
		pause: 1, 
		random: 0,
		timeout: 7000,
		speed: 1500,
		pager:  '.news-nav', 
		pagerAnchorBuilder: function(idx, slide) { 
			// return selector string for existing anchor 
			return '.news-nav a:eq(' + idx + ')'; 
    	} 
	});
	
	// efeito de cycle para o destaque na home;
	$('#destaque-twitter ul').cycle({ 		 
		pause: 1, 
		random: 0,
		timeout: 7000,
		speed: 1500,
		pager:  '.news-nav', 
		pagerAnchorBuilder: function(idx, slide) { 
			// return selector string for existing anchor 
			return '.news-nav a:eq(' + idx + ')'; 
    	} 
	});
	
	// opacidade nos elementos de "clientes";
	$('#clientes ul li').fadeTo('fast', 0.2);
	
	$('#clientes ul li').hover(function() {
		$(this).stop().fadeTo('fast', 1.0);
	}, function() {
		$(this).stop().fadeTo('fast', 0.2);
	});
	
	// função para tooltip em "clientes";
	function tooltipClientes(){
		$('#clientes ul li a.img').hover(function() {
			var title = $('#clientes a.img[title]');
			var description = $('#clientes a.img[description]');
			
			return title;	
		});		
	};
	
	// footer fixed se conteúdo for menor do que window;
	function calcularFooter() {
		var windowHeight = $(window).height() - Number(60);
		var documentHeight = $('body').height();
		
		if(windowHeight > documentHeight) {			
			$('.malha-bg').css({
				'height': windowHeight
			})
		} else {
			$('.malha-bg').css({
				'min-height': windowHeight
			})
		}
	}
	
	calcularFooter();
	
	$(window).resize(function() {
		calcularFooter();
	})	
	
	// histórico de posts;
	$('#historico-posts ul li h4 a').click(function(){
		$(this).parent().parent().find('ul').slideToggle('fast', function() {
			$(this).parent().toggleClass('aberto');	
		});
		
		return false;	
	});
	
	$('#historico-posts ul li ul li h5 a').click(function(){
		$(this).parent().parent().find('ul').slideToggle('fast', function() {
			$(this).parent().toggleClass('aberto');	
		});
		
		return false;	
	});
	
	// tirando última borda da lista em "tudo sobre a martinica";
	$('#tudo-sobre ul li:last-child').css({
		border: 'none',
		padding: '0'
	});
	
	$('#sobre ul li:nth-child(2n)').css({
		marginRight: '0'
	});
	
	// tooltip voltando para a esquerda qd chegar a extremidade;
	$('#clientes.content ul li:nth-child(6n)').addClass('tooltip-esquerda');
});

