	$(document).ready(function(){
		$('#bt_send_comentario').css('cursor','pointer');
		$('#bt_send_comentario').bind('click', function() {
			if(checkContatoForm())
			{
				$('#bt_send_comentario').fadeOut('normal', function(){
					$('#msg_form_comments').html('<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Aguarde! Enviando Coment&aacute;rio.</strong></h3>');
					$('#msg_form_comments').fadeIn('normal', function(){
						var str = $("#form").serialize();
						$.post("_methods/send.php", str, function(data){
							var msg_retorno = '';
							if(data.retorno == 'erro')
								msg_retorno = '<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Ocorreu um erro. Tente novamente!</strong></h3>';
							else if(data.retorno == 'enviado')
								msg_retorno = '<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Obrigado!<br /><br /> Aguarde em quanto aprovamos seu coment&aacute;rio.</strong></h3>';

							$('#msg_form_comments').fadeOut('normal', function(){
								$('#msg_form_comments').html(msg_retorno);
								$('#msg_form_comments').fadeIn('normal', function(){
									timerId = setTimeout(function(){
										clearTimeout(timerId);
										$('#msg_form_comments').fadeOut('normal', function() {
											$('#form').each(function(){
												this.reset();
											});
											$('#bt_send_comentario').fadeIn('normal');
										});
									}, 9000);
								});
							});
						}, 'json');
					});
				});
			}
		});
		
		checkContatoForm = function()
		{
			var erro = '';
			var foco;
			
			if(document.forms['form_coment'].nome.value == '')
			{
				erro += '\n - Nome;';
				if(!foco)
					foco = document.forms['form_coment'].nome;
			}
			if(document.forms['form_coment'].email.value == '')
			{
				erro += '\n - E-mail;';
				if(!foco)
					foco = document.forms['form_coment'].email;
			}
			if(document.forms['form_coment'].comentario.value == '')
			{
				erro += '\n - Comentario;';
				if(!foco)
					foco = document.forms['form_coment'].comentario;
			}
			if(erro == '')
			{
				return true;
			}
			else
			{
				alert('Campos incorretos ou faltando:\n' + erro);
				foco.focus();
				return false;
			}
		}
		
		
		$('#bt_send_envia').css('cursor','pointer');
		$('#bt_send_envia').bind('click', function() {
				$('#bt_send_envia').fadeOut('normal', function(){
					$('#msg_form_envia').html('<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Aguarde! Enviando E-mail.</strong></h3>');
					$('#msg_form_envia').fadeIn('normal', function(){
						var str = $("#form").serialize();
						$.post("_methods/send.php", str, function(data){
							var msg_retorno = '';
							if(data.retorno == 'erro')
								msg_retorno = '<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Ocorreu um erro. Tente novamente!</strong></h3>';
							else if(data.retorno == 'enviado')
								msg_retorno = '<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Obrigado!<br /><br /> Seu e-mail foi enviado com sucesso.</strong></h3>';

							$('#msg_form_envia').fadeOut('normal', function(){
								$('#msg_form_envia').html(msg_retorno);
								$('#msg_form_envia').fadeIn('normal', function(){
									timerId = setTimeout(function(){
										clearTimeout(timerId);
										$('#msg_form_envia').fadeOut('normal', function() {
											$('#form').each(function(){
												this.reset();
											});
											$('#bt_send_envia').fadeIn('normal');
										});
									}, 9000);
								});
							});
						}, 'json');
					});
				});
	
	});
		
		
		$('#bt_send_visita').css('cursor','pointer');
		$('#bt_send_visita').bind('click', function() {
			if(checkVisitaForm())
			{
				$('#bt_send_visita').fadeOut('normal', function(){
					$('#msg_form_visita').html('<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Aguarde! Enviando E-mail.</strong></h3>');
					$('#msg_form_visita').fadeIn('normal', function(){
						var str = $("#form").serialize();
						$.post("_methods/send.php", str, function(data){
							var msg_retorno = '';
							if(data.retorno == 'erro')
								msg_retorno = '<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Ocorreu um erro. Tente novamente!</strong></h3>';
							else if(data.retorno == 'enviado')
								msg_retorno = '<h3 style="font-size:20px; color:#000; font-family:Arial, Helvetica, sans-serif; padding:50px 0px 0px 0px"><strong>Obrigado!<br /><br /> Seu e-mail foi enviado com sucesso.</strong></h3>';

							$('#msg_form_visita').fadeOut('normal', function(){
								$('#msg_form_visita').html(msg_retorno);
								$('#msg_form_visita').fadeIn('normal', function(){
									timerId = setTimeout(function(){
										clearTimeout(timerId);
										$('#msg_form_visita').fadeOut('normal', function() {
											$('#form').each(function(){
												this.reset();
											});
											$('#bt_send_visita').fadeIn('normal');
										});
									}, 9000);
								});
							});
						}, 'json');
					});
				});
				}
			});
		checkVisitaForm = function()
		{
			var erro = '';
			var foco;
			
			if(document.forms['form_visita'].nome.value == '')
			{
				erro += '\n - Seu Nome;';
				if(!foco)
					foco = document.forms['form_visita'].nome;
			}
			if(document.forms['form_visita'].filho.value == '')
			{
				erro += '\n - Nome do seu Filho;';
				if(!foco)
					foco = document.forms['form_visita'].filho;
			}
			if(document.forms['form_visita'].telefone.value == '')
			{
				erro += '\n - Seu Telefone;';
				if(!foco)
					foco = document.forms['form_visita'].telefone;
			}
			if(document.forms['form_visita'].email.value == '')
			{
				erro += '\n - Seu E-mail;';
				if(!foco)
					foco = document.forms['form_visita'].email;
			}
			if(document.forms['form_visita'].mensagem.value == '')
			{
				erro += '\n - Sua Mensagem;';
				if(!foco)
					foco = document.forms['form_visita'].mensagem;
			}
			if(erro == '')
			{
				return true;
			}
			else
			{
				alert('Campos incorretos ou faltando:\n' + erro);
				foco.focus();
				return false;
			}
		}

});

