//este js contém as chamadas as funções comuns a todo projeto
var id = 1;


$(document).ready(function(){
	/*==============================================
	 GERAIS
	================================================*/
	
	//faz o preload das imagens linkadas no CSS
	//$.preloadCssImages();
	
	/*==============================================
	 HOME
	================================================*/
	/*Chamada da função para controlar o esconde/mostra dos cursos na home
	para cada box contendo o span "abrir", feche-o. */
	var arrayBoxCursos = $(".fechar");
	jQuery.each(arrayBoxCursos, function() {        
		if($(this).html() == "abrir") {
			$(this).parent().find("ul, a.txt-company").css("display", "none");
			if($(this).hasClass("verde")) { //troca o icone de menos para mais
				$(this).addClass("over-verde");
			} else {
				$(this).addClass("over-azul");
			};
			$(this).attr("title","Clique para mostrar os cursos");
		}
	});
	
	$(".fechar").click(
		 function(){
			$(this).parent().find("ul, a.txt-company").slideToggle("fast");
			
			if($(this).html() == "abrir") {
				$(this).html("fechar");
				$(this).attr("title","Clique para esconder os cursos");
				if($(this).hasClass("verde")) {
					$(this).removeClass("over-verde");
				} else {
					$(this).removeClass("over-azul");
				};
			} else {
				$(this).html("abrir");
				$(this).attr("title","Clique para mostrar os cursos");
				if($(this).hasClass("verde")) {
					$(this).addClass("over-verde");
				} else {
					$(this).addClass("over-azul");
				};
			}
		}
	);
	/*==============================================
	 CURSOS
	================================================*/
	$(".bloco-projetos h3").toggle(
		 function(){
			$(this).parent().find("table").show();
			$(this).attr("title","Clique para esconder os cursos e datas");
			$(this).removeClass("aberta");			
		},
		 function() {
			$(this).parent().find("table").hide();			
			$(this).attr("title","Clique para mostrar os cursos e datas");
			$(this).addClass("aberta");				
		 }
	);	
	/*==============================================
	 FAQ
	================================================*/
	$(".tits-faq").toggle(
		 function(){
			$(this).parent().find("dd").slideToggle("fast");
			$(this).attr("title","Clique para esconder a informação");
			$(this).addClass("aberta");
			$.ajax({
			  type: "GET",
			  url: $(this).attr("abbr"),
			  dataType: "script"
			});			
		},
		 function() {
			$(this).parent().find("dd").slideToggle("fast");	
			$(this).attr("title","Clique para mostrar a informação");
			$(this).removeClass("aberta");
		 }
	);	
	$(".toggle-faq").toggle(
			function(){      
				$(".tits-faq").parent().find("dd").css("display", "block");
				$(this).html("Fechar todas as perguntas");
			},
			function(){
				$(".tits-faq").parent().find("dd").css("display", "none");
				$(this).html("Abrir todas as perguntas");
			}
		);
  
	
	/*==============================================
	 CASES
	================================================*/
	$(".lista-cases").hover(
		function(){
			$(this).addClass("over");
			$(this).find("dd a").addClass("over");
		},
		function(){
			$(this).removeClass("over");
			$(this).find("dd a").removeClass("over");
		}
	);
	$(".lista-cases").click(
		function(){
			var link = $(this).find("a").attr("href");
			window.location = link;
		}
	);
	

/*==============================================
 CURSOS
================================================*/	
	var arrayImagens = $("#destaque-cursos img");
	jQuery.each(arrayImagens, function() {
		$("#destaque-cursos").find("p").addClass("vazio");
	});


/* GRÁFICO DA POS-GRADUACAO
================================================*/
	$("#abre-grafico-pos").click(
		function(){
			$("#grafico-pos").slideDown(1000);
			$("input, select").css("visibility", "hidden");
			
		});
	$("#grafico-pos").click(
		function(){
			$(this).fadeOut("slow");
			$("input, select").css("visibility", "visible");
		});
	
/*==============================================
 MAPA LOCALIZACAO SEMINARIO
================================================*/
	$(".mapa_loca").click(
		function(){
			$(this).parent().parent().find(".mapa_loca_grande").slideDown(1000);
			$("input, select").css("visibility", "hidden");			
		});
	$(".mapa_loca_grande").click(
		function(){
			$(this).fadeOut(1000)
			$("input, select").css("visibility", "visible");
		});
	

/*==============================================
SEMINARIOS
================================================*/
	$("#fisica").click(
		function(){
			$("#lb-nome").html("Nome completo*");
			$("#lb-cpf").html("CPF*");
			$("#lb-empresa").html("Empresa*");
			$("#lb-cargo").html("Cargo*");
			$("#lb-formacao").html("Formação Acadêmica*");
			$("#lb-fisica").addClass("marcado");
			$("#lb-juridica").removeClass("marcado");
	});
	$("#juridica").click(
		function(){
			$("#lb-nome").html("Razão Social*");
			$("#lb-cpf").html("CNPJ*");
			$("#lb-empresa").html("Inscrição Estadual*");
			$("#lb-cargo").html("Nome do contato*");
			$("#lb-formacao").html("Cargo*");
			$("#lb-fisica").removeClass("marcado");
			$("#lb-juridica").addClass("marcado");
	});

});//fecha o documento.ready
