
jQuery(document).ready(function() {
  if (jQuery('#mycarousel li').length != 0) {
	jQuery('#mycarousel').jcarousel();
	var larguraCarrossel = jQuery("#mycarousel").width() - 5;
	if(larguraCarrossel <= 725) { //largura do .conteudo-principal-internas-wrapper
	  jQuery(".jcarousel-container-horizontal").css("width",larguraCarrossel);
	  jQuery(".gallery").css("width",larguraCarrossel + 70);
	  jQuery(".jcarousel-prev-disabled-horizontal").attr("title", "Não existem mais fotos por enquanto");
	  jQuery(".jcarousel-next-disabled-horizontal").attr("title", "Não existem mais fotos por enquanto");
	}
  }
//equaliza as alturas dos containers de textos de algumas páginas
//true é necessário para o ie 6 - pois true renderiza em pixels
	if (jQuery('.exibe-colunas').length != 0) {
		jQuery('.exibe-colunas').equalHeights(true);
	}
	if (jQuery('.lista-fotos').length != 0) {
		jQuery('.lista-fotos').equalHeights(true);
	}
	if (jQuery('.galeria').length != 0) {
		jQuery('.galeria').equalHeights(true);
	}
  
//Banners popup
  if (jQuery('.popup-banner').length > 0) {
	jQuery('.popup-banner').show();
	var arrPopups = jQuery('.popup-banner');
	jQuery.each(arrPopups, function() {
	  if(arrPopups.length > 1) {
		var topPos = (jQuery(this).height() / arrPopups.length)+"px";
		var leftPos = ((jQuery(document).width() - jQuery(this).width()) / 3)+"px";
	  }else {
		var topPos = "170px";
		var leftPos = "20%";
	  }
	  
	  jQuery(this).css("top", topPos);
	  jQuery(this).css("left", leftPos);
	  
    });
	
  }
  jQuery('.botao-fechar').click(
	function() {
	  jQuery(this).parent().hide();
	}
  );  
//Fim Banners Popup
  
 // jQuery('.gallery a').lightBox();
  //jQuery('.img-destaque a').lightBox();

	//jQuery(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme: 'light_square'});
	//jQuery(".gallery a").prettyPhoto({theme: 'light_square'});
	//jQuery(".img-destaque a").prettyPhoto({theme: 'light_square'});
  
  jQuery("ul.sf-menu").superfish({ 
		  pathClass:'current' 
  });
  jQuery("ul.sf-menu>li").hover(
	  function() {
		  jQuery(this).find("a").addClass('selected-menu');
	  },
	  function() {
		  jQuery(this).find("a").removeClass('selected-menu');
	  }
  );
  jQuery(".canto-esq + li").addClass("first");
		
//controle do menu lateral das internas
  if(jQuery("a.marcado").length != 0) {
	jQuery(".menu a").parents("ul").hide();
  } 
  jQuery("a.marcado").parents("ul").show();
  //mostro o primeiro nivel (primeiro submenu) apenas.
  jQuery("a.marcado + ul").show();
  //Forço com que todo A que contiver um .fecha-menu seja marcado, para que nas subpáginas aparece correto - trato a exeção mais abaixo.
  jQuery(".fecha-menu").parent("a").addClass("marcado");  
  jQuery(".fecha-menu").attr("title","Clique para mostrar ou esconder o menu");
  
  jQuery(".fecha-menu").each(function() {
	  //acho todas a primeiras ul da avó de todos os span.fecha-menu
      var filhas = jQuery(this).parent().parent().find("ul").eq(0);
	  //vejo quais uls de filhas não estão abertas e removo a marcação
	  if(filhas.attr("style") == "display: none;" || filhas.attr("style") == "DISPLAY: none" ) { //o segundo valor da variavel é como o ie percebe
		jQuery(this).parent().removeClass("marcado");
	  }
	  
    });
  
  
  
  

  jQuery(".fecha-menu").toggle(
	function(){
	  var submenus = jQuery(this).parent().parent().find("ul");
	  if(submenus.find(".fecha-menu").length == 0) {
		jQuery(this).parent().parent().find("ul").slideToggle("fast");	  
	  } else {
		jQuery(this).parent().parent().find("ul:first").slideToggle("fast");	  
	  }
	  //forço a abertura das ul de mais alto nível (as netas, bisnetas etc)
	  jQuery(this).parent().parent().find("ul").eq(2).slideDown("fast");
   },
	function() {
	  jQuery(this).parent().parent().find("ul:first").slideToggle("fast");
	}
  );
//fim do controle do menu lateral das internas
  
  //busca
  //jQuery(".avancada").find(".radio").slideToggle("fast");
  
//  jQuery(".filtro-busca").toggle(
//	function() {
//	  jQuery(".avancada").find(".radio").slideToggle("fast");
//	  jQuery(this).find(".abrir").html("fechar");
//	},
//	function() {
//	  jQuery(".avancada").find(".radio").slideToggle("fast");
//	  jQuery(this).find(".abrir").html("abrir");
//	}
//  );
});


