$(function()
{
	// Cria o Scroll
	$('#contCheio').jScrollPane({scrollbarWidth:7, scrollbarMargin:10});

	
	// Cria o Submenu		 

	$(".menu").each(function(){ 
			var el = $('#' + $(this).attr('id') + ' ul:eq(0)');
			var $int;
			
			$(this).hover(function(){ 
					el.show();
			}, function(){ 
					el.hide();
			});
			
			$('li', this).hover(function(){
					$('ul', this).show();
			}, function(){ 
					$('ul', this).hide();
			});
	
	}); 


	$(".menu ul").each(function(){ 
		$('li:last',this).css({border:'none'});
	});
	
	$(".botaoExpandir").click(function(){
		
		$divAnt = $(this).parent();
		if($("div",$divAnt).is(':hidden')){
			$("div",$divAnt).show();
		}else{
			$("div",$divAnt).hide();
		}
		posicionaRodape();
	});
	
	$("#assinatura").css('opacity',0.20);
	$("#assinatura").mouseover(function(){
		$(this).stop(true, true).fadeTo("normal", 1);
	});
	$("#assinatura").mouseout(function(){
		$(this).stop(true, true).fadeTo("normal", 0.20);
	});
	
	$(".galeria-boxes").mouseover(function(){
		$(this).stop(true, true).css({"opacity":"1"});
	});
	
	$(".galeria-boxes").mouseout(function(){
		$(this).stop(true, true).css({"opacity":"0.7"});
	});
	
	$(".galeria-boxes").click(function(){
		$(this).clone()
		.css({"border":"solid 1px #fff","position":"absolute","padding":"0", "margin":"0", "top":$(this).offset().top, "left":$(this).offset().left,"background":"#fff"})
		.html("")
		.insertAfter(this)
		.animate({"width":"320px", "height":"240px", "top":$(".imgDestaque").offset().top, "left":$(".imgDestaque").offset().left},1000);
		
		$.scrollTo(".tit1",800);
	});
	
	$(".galeria-boxes").css({"opacity":"0.7"});
});

function carregaEstados(){
	$.post('includes/getEstados.php', '', function(retorno){
		$("#slctEstados").html(retorno);
	});
}
function carregaCidades(uf){
	$.post('includes/getCidades.php', {uf:uf}, function(retorno){
		$("#slctCidades").html(retorno);
	});
}

function insereFlash(filename,name,largura,altura){
			AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', largura,
			'height', altura,
			'src', 'a',
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', 'a',
			'bgcolor', '#ffffff',
			'name', 'a',
			'menu', 'true',
			'allowScriptAccess','sameDomain',
			'movie', filename,
			'salign', ''
			); //end AC code
	
}

function posicionaRodape(){
	altura = parseInt($(".materiaTexto").height()+$(".materiaTexto").offset().top+20);

	if(altura<500){
		altura = 770;

		$(".box")
		.css({"height":600})
		.show();
	}
	
	
	
	$("#rodape")
	.css({top:altura})
	.show();	
}

function vFormFaleConosco(){
	$("#msg").show();
	$("#msg").html("Enviando...");
		
	$err	 	= "";
	$enviarPara = $("#enviarPara").val();
	$nome		= $("#txtnome").val();
	$email		= $("#txtemail").val();
	$telefone	= $("#txttelefone").val();
	$mensagem	= $("#txtmensagem").val();
	
	
	if($nome==""){
		$err += "- Informe seu nome <br>";
	}
	
	if($email==""){
		$err += "- Informe seu email <br>";
	}
	
	if($mensagem==""){
		$err += "- Digite a mensagem <br>";
	}
	
	if($err!=""){
		$("#msg").html("<div style='color:red; font-size:11px'><b>Erro(s) encontrado(s):</b> <br><br>" + $err + "</div>");
		posicionaRodape();
	}else{
		$.post("faleconosco_enviaremail.php",$("#faleConosco").serialize(),
			function(retorno){
				if(retorno=="1"){
					$("#msg").html("<div style='color:#57a01d; font-size:11px; font-weight:bold'>Mensagem enviada com sucesso!</div>");
					posicionaRodape();
					$("#faleConosco")[0].reset();
				}else{
					$("#msg").html("<div style='color:red; font-size:11px; font-weight:bold'>Erro ao enviar a mensagem!</div>");
					posicionaRodape();
				}
			}
		);
	}
	return false;
}
