$(document).ready(function(){
	
	$(".area_port4").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".area_port4 img").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".area_port3").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".area_port2").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".area_port1").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".area_port11").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".box_agencia").fadeTo("slow", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	
	$(".area_serv ul").hide();
	
	
	$(".area_serv").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
		$(this).children("ul").show("slow"); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
		$(this).children("ul").hide("slow");
	});
	
	
	$(".box_agencia").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
	});
	
	$(".area_port4").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
	});
	
	
	$(".area_port3").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
	});
	
	
	$(".area_port2").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
	});
	
	$(".area_port1").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
	});
	
	$(".area_port11").hover(function(){
		$(this).fadeTo("slow", 1.0).css({'backgroundColor':'#FFFFFF'}); // This should set the opacity to 100% on hover
	}
	,function(){
		$(this).fadeTo("slow", 0.4).css({'backgroundColor':'transparent'}); // This should set the opacity back to 30% on mouseout
	});
	
	$("#myController").jFlow({

			controller: ".jFlowControl", // must be class, use . sign

			slideWrapper : "#jFlowSlider", // must be id, use # sign

			slides: "#mySlides",  // the div where all your sliding divs are nested in

			selectedWrapper: "jFlowSelected",  // just pure text, no sign

			width: "1000px",  // this is the width for the content-slider

			height: "500px",  // this is the height for the content-slider

			duration: 600,  // time in miliseconds to transition one slide

			prev: ".jFlowPrev", // must be class, use . sign

			next: ".jFlowNext", // must be class, use . sign

			auto: true

    });
	
	
	// Quando o formulário for enviado, essa função é chamada
	$("#cadastra_news").click(function() {
		// Colocamos os valores de cada campo em uma váriavel para facilitar a manipulação
		var nome = $("#nome").val();
		var email = $("#email").val();
		// Exibe mensagem de carregamento
		$("#status").html("<img src='images/progress.gif' alt='Enviando' />");
		// Fazemos a requisão ajax com o arquivo envia.php e enviamos os valores de cada campo através do método POST
		$.post('news.php', {nome: nome, email: email}, function(resposta) {
				// Quando terminada a requisição
				// Exibe a div status
				$("#status").slideDown();
				// Se a resposta é um erro
				if (resposta != false) {
					// Exibe o erro na div
					$("#status").css({'color':'#e43333'}).html(resposta);
				} 
				// Se resposta for false, ou seja, não ocorreu nenhum erro
				else {
					// Exibe mensagem de sucesso
					$("#status").css({'color':'#90b0d5'}).html("Cadastro realizado com Sucesso!");
					// Limpando todos os campos
					$("#nome").val("");
					$("#email").val("");
				}
		});
	});
	
	// Quando o formulário for enviado, essa função é chamada
	$("#enviar").click(function() {
		// Colocamos os valores de cada campo em uma váriavel para facilitar a manipulação
		var nome = $("#nome").val();
		var email = $("#email").val();
		var telefone = $("#telefone").val();
		var assunto = $("#assunto").val();
		var mensagem = $("#mensagem").val();
		// Exibe mensagem de carregamento
		$("#status").html("<img src='images/progress.gif' alt='Enviando' />");
		// Fazemos a requisão ajax com o arquivo envia.php e enviamos os valores de cada campo através do método POST
		$.post('envia.php', {nome: nome, email: email, telefone: telefone, assunto: assunto, mensagem: mensagem}, function(resposta) {
				// Quando terminada a requisição
				// Exibe a div status
				$("#status").slideDown();
				// Se a resposta é um erro
				if (resposta != false) {
					// Exibe o erro na div
					$("#status").css({'color':'#e43333'}).html(resposta);
				} 
				// Se resposta for false, ou seja, não ocorreu nenhum erro
				else {
					// Exibe mensagem de sucesso
					$("#status").css({'color':'#90b0d5'}).html("E-mail enviado com Sucesso!");
					// Limpando todos os campos
					$("#nome").val("");
					$("#email").val("");
					$("#assunto").val("");
					$("#telefone").val("");
					$("#mensagem").val("");
					$("#status").delay(5000).fadeOut(400);
				}
		});
	});
	
	
	$(function(){
		$.fn.scrollToTop=function(){
		
			if($(window).scrollTop()=="0"){
				$("#floatdiv").fadeIn("slow")
			}
			
			var scrollDiv=$("#floatdiv");
			var y_fixo = $("#floatdiv").offset().top;
			
			$(window).scroll(function(){
									  
				var st = $(window).scrollTop();
				var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop();
			
				if(scrollBottom!="0"){
					$(scrollDiv).fadeOut("slow")
				}
				else{
					
					$(scrollDiv).animate({
							top: y_fixo+$(document).scrollTop()+"px"
							},{duration:550,queue:false}
					 );
					
					$(scrollDiv).fadeIn("slow")
				}
			});
		}
	});
		
		$(function() {
                $("#floatdiv").scrollToTop();
        });
	
	
	
	$(".content").load("busca.php");
	
});
