$(document).ready(function() {
						   
	$('#container-destaques').nivoSlider({
		effect: 'boxRain',
		captionOpacity: 0,
		pauseTime: 6000,
		directionNavHide: false
	});

/* LIGHTBOX
------------------------------------------------------------------*/
	$("#inscricao a").fancybox({
		overlayColor: '#3c3c3c',
		overlayOpacity: 0.8,
		speedIn: 500,
		type: 'iframe',
		titleShow: false,
		autoScale: false,
		width: 695,
		height: '85%'
	});
	
	$("a[rel=fancybox]").fancybox({
		overlayColor: '#3c3c3c',
		overlayOpacity: 0.8,
		speedIn: 500,
		titleShow: false
	});


/* MOSTRA/ESCONDE
------------------------------------------------------------------*/
	$('.conteudo-item p').each(function(index) {
		$(this).css('height', $(this).height());
	});

	$(".conteudo-item").hide(); // Esconde todos os boxes
	
	$(".titulo-item").click(
		function() {
			var resposta = $(this).next();
			var siblings = $(this).parent().siblings();
			var secao = $(this).parent();
			
			if ( $(resposta).is(':visible') ) {
				
				$(resposta).slideUp("slow");
				$(this).removeClass("conteudo-aberto");
				
			} else {
				
				$(siblings).find(".conteudo-item").slideUp("slow");
				$(siblings).find(".titulo-item").removeClass("conteudo-aberto");
				
				$(resposta).slideDown("slow", function() {
					$('html, body').animate({
						scrollTop: $(secao).offset().top
					}, 800);
				});
				$(this).addClass("conteudo-aberto");
			}
		}
	);


/* PAGINAÇÃO
------------------------------------------------------------------*/
	$(".wp-pagenavi *:last").css("border-right","0 none");
	
	
	$('#lista-cursos').masonry({
		itemSelector: '#lista-cursos li'
	});


/* BUSCA
------------------------------------------------------------------*/
	if( $("#s").is(":empty") ) {
		$("#s").val( $("#searchform label").text() );
	}


/* LIMPA OS CAMPOS DO FORMULÁRIO
------------------------------------------------------------------*/
	swapValue = [];
    $("#news input[type=text], #s, #commentform input[type=text]").each(function(i){
        swapValue[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValue[i]) {
                $(this).val("");
            }
            $(this).addClass("focus");
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValue[i]);
            }
            $(this).removeClass("focus");
        });
    });


/* SOCIAL MEDIA
------------------------------------------------------------------*/
	$("#social-media li a").each(
		function() {
			$("<span></span>").appendTo( $(this) );
			$(this).find("span").hide();
		}
	);
	
	/*$("#social-media li").live('mouseover mouseout', function(event) {
		if (event.type == 'mouseover') {
			$(this).find("span").fadeIn();
		} else {
			$(this).find("span").fadeOut();
		}
	});*/
	
	$("#social-media li").hover(
		function(event) {
			$(this).find("span").fadeIn();
		},
		function() {
			$(this).find("span").fadeOut();
		}
	);

	$(function($){
        $(".tweets").tweet({
          join_text: false,
          username: "cursoforumrio",
          avatar_size: 0,
          count: 4,
          loading_text: "Carregando...",
		  template: "{text}{time}",
        });
      });
	
});
