jQuery(document).ready(function(){
	// TOOLTIPS TOPO
	$('.thumbnail').hide();
	jQuery('ul#redes_topo li a').hover(function(){
		$('.thumbnail').show();
		jQuery(this).next('.thumbnail').stop().animate({bottom:-20,opacity:1},250);
	},function(){
		jQuery(this).next('.thumbnail').stop().animate({opacity:0},250,function(){jQuery(this).css({bottom:-30})});
		$('.thumbnail').hide();
	});
	
	// SUBMENU PRINCIPAL
	$("#menu ul li a").hover(function(){
		$(this).parent().find("ul.submenu").show();
		$(this).parent().find("a.main").addClass("sel");
		$(this).parent().hover(function() {
		}, function(){	
			$(this).parent().find("ul.submenu").hide();
			$(this).parent().find("a.main").removeClass("sel");
		});
		}).hover(function() { 
			$(this).addClass("subhover");
			
		}, function(){
			$(this).removeClass("subhover");
	});
	
	// NEWSLETTER TOP
    $(".bt_newsletter_top").click(function(){
		if ($("#newsletter_top").is(":hidden")){
			$("#newsletter_top").fadeIn(300);
		}
		else{
			$("#newsletter_top").fadeOut(300);
		}
	});
	$("#newsletter_top, .bt_newsletter_top").click(function(e){e.stopPropagation();});
	$('.bt_contato_top, .bt_contato_bot, .bt_newsletter_bot, .bt_box_funcionamento').click(function(){$("#newsletter_top").fadeOut(300);});
	// NEWSLETTER BOT
    $(".bt_newsletter_bot").click(function(){
		if ($("#newsletter_bot").is(":hidden")){
			$("#newsletter_bot").fadeIn(300);
		}
		else{
			$("#newsletter_bot").fadeOut(300);
		}
	});
	$("#newsletter_bot, .bt_newsletter_bot").click(function(e){e.stopPropagation();});
	$('.bt_contato_top, .bt_contato_bot, .bt_newsletter_top, .bt_box_funcionamento').click(function(){$("#newsletter_bot").fadeOut(300);});	
	
	// CONTATO TOP
    $(".bt_contato_top").click(function(){
		if ($("#contato_top").is(":hidden")){
			$("#contato_top").fadeIn(300);
		}
		else{
			$("#contato_top").fadeOut(300);
		}
	});
	$("#contato_top, .bt_contato_top").click(function(d){d.stopPropagation();});
	$('.bt_contato_bot, .bt_newsletter_top, .bt_newsletter_bot, .bt_box_funcionamento').click(function(){$("#contato_top").fadeOut(300);});
	// CONTATO BOT
    $(".bt_contato_bot").click(function(){
		if ($("#contato_bot").is(":hidden")){
			$("#contato_bot").fadeIn(300);
		}
		else{
			$("#contato_bot").fadeOut(300);
		}
	});
	$("#contato_bot, .bt_contato_bot").click(function(d){d.stopPropagation();});
	$('.bt_contato_top, .bt_newsletter_top, .bt_newsletter_bot, .bt_box_funcionamento').click(function(){$("#contato_bot").fadeOut(300);});	

	//DROP HORARIO FUNCIONAMENTO
	
	Image1= new Image()
	Image1.src = url + "/imgs/geral/bg_titulo.png"
	
	Image2 = new Image()
	Image2.src = url + "/imgs/geral/bg_titulo_especial.png"
	
	Image3 = new Image()
	Image3.src = url + "/imgs/geral/bg_cont_horarios_especiais.png"
	
	Image4 = new Image()
	Image4.src = url + "/imgs/geral/fechar_cont_horarios_especiais.png"
	
	Image5 = new Image()
	Image5.src = url + "/imgs/geral/track_cont_horarios_especiais.png"
	
    Image6 = new Image()
	Image6.src = url + "/imgs/geral/bg_submenu.png"
	
	Image7 = new Image()
	Image7.src = url + "/imgs/geral/bg_newsletter_top.png"
	
	Image8 = new Image()
	Image8.src = url + "/imgs/geral/bg_contato_top.png"
	
	Image9 = new Image()
	Image9.src = url + "/imgs/formularios/bt_enviarcontato.png"
	
	Image10 = new Image()
	Image10.src = url + "/imgs/formularios/bt_cadastro.png"
	
	Image11 = new Image()
	Image11.src = url + "/imgs/geral/bg_contato_bot.png"
	
	Image12 = new Image()
	Image12.src = url + "/imgs/geral/bg_newsletter_bot.png"
	
	//$(this).find('.cont_horarios').hide();
	$(".bt_box_funcionamento").click(function(){
		if ($("#box_funcionamento .cont_horarios").is(":hidden")){
			$("#box_funcionamento .cont_horarios").slideDown();
			fleXenv.initByClass("flexcroll");
		}
		else{
			$("#box_funcionamento .cont_horarios").slideUp();
		}
	});
	$('#box_funcionamento .cont_horarios, #box_funcionamento').click(function(c){
		c.stopPropagation();
	});
	$('#box_funcionamento .cont_horarios .bt_fechar').click(function(){
		$('#box_funcionamento .cont_horarios').slideUp();
	});
	$('.bt_contato_top, .bt_contato_bot, .bt_newsletter_top, .bt_newsletter_bot').click(function(){
		$('#box_funcionamento .cont_horarios').slideUp();
	});	
	
	$(document).click(function(){
		$("#newsletter_top").fadeOut(300);
		$("#newsletter_bot").fadeOut(300);
		$("#contato_top").fadeOut(300);
		$("#contato_bot").fadeOut(300);
		$('#box_funcionamento .cont_horarios').slideUp();
    });	
	// ABAS INSTITUCIONAL
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	
	
	// TOOLTIPS INSTITUCIONAL
	jQuery('ul.tabs li a').hover(function(){
		$('.thumbnail').show();
		jQuery(this).next('.thumbnail').stop().animate({top:-35,opacity:1},250);
	},function(){
		jQuery(this).next('.thumbnail').stop().animate({opacity:0},250,function(){jQuery(this).css({top:-45})});
		$('.thumbnail').hide();
	});
	
	
	//FAQ
	$('#faq ul').each(function() {
        var n = Math.round(($('li', this).length)/2);
		var mae = $(this).parent();
		var $bigList = $(this),
		group    = $bigList.find('li:lt('+n+')').remove();	
	    var i = 1;
	    while(group.length){
		    $('<ul class="coluna0'+i+'" />').append(group).appendTo(mae);
		    group = $bigList.find('li:lt('+n+')').remove();
            i++;
	    }
	    $(this).remove();	  
    });
	$(".coluna01 .pergunta").addClass("closed");
	$(".coluna01 .resposta").hide();
	$(".coluna01 .pergunta").click(function() {
		$(".coluna01 .resposta").slideUp("fast");
		$(".coluna01 .pergunta").removeClass("opened").addClass("closed");
		if ($(this).next(".coluna01 .resposta").is(":hidden")) {
			$(this).next(".coluna01 .resposta").slideDown("fast");
			$(this).removeClass("closed").addClass("opened");
		}
	});
	
	$(".coluna02 .pergunta").addClass("closed");
	$(".coluna02 .resposta").hide();
	$(".coluna02 .pergunta").click(function() {
		$(".coluna02 .resposta").slideUp("fast");
		$(".coluna02 .pergunta").removeClass("opened").addClass("closed");
		if ($(this).next(".coluna02 .resposta").is(":hidden")) {
			$(this).next(".coluna02 .resposta").slideDown("fast");
			$(this).removeClass("closed").addClass("opened");
		}
	});
	
	
	//LISTA NOVIDADES
	$('#share').each(function() {
        var n = Math.round(($('.novidade', this).length)/2);
		var mae = $(this).parent();
		var $bigList = $(this),
		group    = $bigList.find('.novidade:lt('+n+')').remove();	
	    var i = 1;
	    while(group.length){
		    $('<div class="coluna0'+i+'" />').append(group).appendTo(mae);
		    group = $bigList.find('.novidade:lt('+n+')').remove();
            i++;
	    }
	    $(this).remove();	  
    });
    
    

    // MODAL DESTAQUE
	$('#contdestaque').hide();

	$("#box_filmes").click(function(e){e.stopPropagation();});
	$(document).click(function(){
		$('#contdestaque').fadeOut(200, function(){
		  $("#box_filmes").animate({"height":"191px"},500, function() {
			  $("#imagem_destaque").fadeIn(200);
			  $('.bt_trailer, .bt_fotos, .bt_sinopse, .bt_horarios').removeClass("sel");
		  });
		})
	});

    /**
     * Funções AJAX - Destaque dos filmes na home
     */
    

    var req = siteurl+'/requester-filmes/';

    jQuery('#box_filmes .maisbotoes a').click(function(e) {

        var Link = this;
		// desce o destaque
        $("#imagem_destaque").fadeOut(200, function() {
			  $("#box_filmes").animate({"height":"370px"},500, function(){}
			);
		});
		$('.bt_trailer, .bt_fotos, .bt_sinopse, .bt_horarios').removeClass("sel");
		$(Link).addClass("sel");
        
        var loader = req+'?pid='+jQuery(Link).attr('rel')+'&tela='+jQuery(Link).attr('title');
        
		$('#contdestaque').fadeOut(200, function(){
			$('#contdestaque').load(loader, function(r) {
				$('#contdestaque').fadeIn(200);
			});
		});
        e.stopPropagation();
        return false;
       
    });
    
    /**
     * Select dos filmes
     */
    jQuery('.buscar select').each(function() {
       jQuery(this).change(function() {
          if(jQuery(this).val() != 'javascript:void(0);') {
              window.location = jQuery(this).val();
          } 
       }); 
    });
    
    
});

// LIGHTBOX
Shadowbox.init({
    handleOversize:     "drag",
    displayNav:         true,
    handleUnsupported:  "remove",
    autoplayMovies:     false
});


