// JavaScript Document
	$(document).ready(function(){
		
		$("#centro").fadeOut(0);
		menu();
		//w3Opacity.fading('mestre',100,30,300);
		$("#img_grande").fadeOut(2000,function(){
			$("#centro").fadeIn(10);
			
			//w3Opacity.fading('cab',100,65,5000);			
		});
		
		
		
		//w3Opacity.fading('img_grande',100,0,500);
		
		
		
		
		
		
		
		
		var atual = 1;
		var proxima;
		var anterior;
		
		
		function nav(pasta,qtd_fotos){
			
			atual = 1;
			proxima;
			anterior;
			
			$("#mestre #conteudo #centro #direita #conjunto #troca_foto #navegacao #proxima").click(function(){
				trocar_foto("proxima",pasta,qtd_fotos);
			});
			
			
			$("#mestre #conteudo #centro #direita #conjunto #troca_foto #navegacao #anterior").click(function(){
				trocar_foto("anterior",pasta,qtd_fotos);
			});		
		}
		
		
		
		
		function trocar_foto(acao,pasta,qtd_fotos){
			
			if( acao == "proxima" ){
				atual++;
				if(atual > qtd_fotos){
					alert("ÚLTIMA FOTO !!!");
					atual = qtd_fotos;
					return;
				}
			}else if( acao == "anterior" ){
				atual--;
				if(atual < 1){
					alert("PRIMEIRA FOTO !!!");
					atual = 1;
					return;
				}
			}
			
			$("#mestre #conteudo #centro #direita #conjunto #troca_foto #foto").html("<img src='img/b/"+pasta+"/"+atual+".jpg' />");
			
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		function menu(){
			$("#bam_a").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/bam_a.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","1500px");
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#bam_b").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/bam_b.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","600px");
						nav("bamcrus_desafio",5);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#bam_c").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/bam_c.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","900px");
						nav("bambu_equipe",15);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#bam_d").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/bam_d.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","1400px");
						//nav("bamcrus_desafio",5);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#cursos").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/cursos.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","1500px");
						$("#form_cursos").click(function(){
							window.open("formulario_curso_civilizacao.html", "Pagina2" );
						});
						nav("civilizacao_do_bambu",8);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#noticias").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/noticias.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","835px");
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			
			$("#parceiros").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/parceiros.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","935px");
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			
			var sair;
			$("#contato").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/contato.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","450px");
						
						$("input[name=limpar]").click(function(){
							$(".text_form").each(function(){
								$(this).val("");
							});	
						});
						
						$("input[name=salvar]").click(function(){
							sair = 0;
							$(".text_form").each(function(){
								if(sair == 1){
									return;
								}
								if($(this).val() == ""){
									alert("PREENCHA TODOS OS CAMPOS!!!");
									sair = 1;
									return;
								}								
							});
							
							if(sair == 1){
								return;
							}

							alert("MENSAGEM ENVIADA COM SUCESSO!!!");
							
							$("#formm").submit();
							$("input[name=limpar]").click();	
							
						});
						
						
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			
			
			/*$("#o_bam_a").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/o_bam_a.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","3300px");
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});*/
			
			$("#cer_a").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/cer_a.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","735px");
						nav("bamcrus_desafio",5);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#cer_b").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/cer_b.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","550px");
						nav("cerbambu_estrutura",15);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#cer_c").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/cer_c.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","600px");
						nav("bamcrus_desafio",5);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#cer_d").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/cer_d.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","680px");
						nav("bamcrus_desafio",5);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#pro_a").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/pro_a.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","500px");
						//nav("bamcrus_desafio",5);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#pro_b").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/pro_b.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","500px");
						nav("revena30_educacao_para_sustentabilidade",13);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#pro_c").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/pro_c.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","500px");
						nav("revena30_economia_criativa_com_compromisso_ambiental",11);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#pro_d").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/pro_d.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","700px");
						nav("revena30_sequestro_de_carbono_como_ferramenta_social",23);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
			
			$("#pro_e").click(function(){

				$.ajax({
					type: "POST",
					url: "menu/pro_e.html",            
					success: function(response){						
						$("#conteudo").html(response);
						$("#conteudo").css("height","780px");
						nav("revena30_desenvolvimento_de_pesquisa",15);
					},
					error: function(XMLHttpRequest, textStatus, errorThrown){
						//alert(errorThrown);
					}
				});
				
			});
		}
		
		
		
	});
				

