		function checkMail(mail){
	        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	        if(typeof(mail) == "string"){
	                if(er.test(mail)){ return true; }
	        }else if(typeof(mail) == "object"){
	                if(er.test(mail.value)){ 
	                                        return true; 
	                                }
	        }else{
	                return false;
	                }
		}
	/*ENVIAR NEWSLETTER*/
	$(document).ready(function() {
		$("#resposta_news").ajaxStart(function(){ $(this).html("<div id=loader_news>Mensagem sendo enviada, por favor aguarde...</div>"); });
	$('#enviar_news').click(function() {
	
		var email    = $('#email_news').val();
		  if (!checkMail(email))
		  {
			$('#resposta_news').html("Este email não é valido!");
			return false;
		  }
			$.post('../includes/newsletter.php',
				{ email:email },
				function(data, textStatus) {
				$('#resposta_news').html(data);
				});
				return false;
				});
	
	});
	/formulario de contato*/
	$(document).ready(function() {
	$("#resposta").ajaxStart(function(){ $(this).html("<div id=ajax_loader>Mensagem sendo enviada, por favor aguarde...</div>"); });
	$('#submit_contato').click(function() {
		
		var nome     = $('#nome').val();
		var email    = $('#email2').val();
		var cidade   = $('#cidade').val();
		var estado    = $('#estado').val();
		var telefone      = $('#telefone2').val();
		var dt_nascimento = $('#dt_nascimento2').val();
		var assunto    = $('#assunto').val();
		var comentario      = $('#comentario').val();
		
		if($('#news').is(':checked'))
		{
			var news = 1;
		}
		  	if (!checkMail(email))
		  	{
		  		$('#resposta').html("Email Inválido!");
		  		return false;
		  	}		 	
			if(nome == '' || email == ''  )                    
			{
				$('#resposta').html("Preencha todos os campos corretamente!");
				return false;
			}
			$.post('./mail.php',
			{ nome: nome, email: email, cidade:cidade, estado:estado, telefone:telefone, dt_nascimento:dt_nascimento, assunto:assunto, comentario:comentario, news:news, acao:'contato' },
			function(data, textStatus) {
			$('#resposta').html(data);
			});
			return false;
			});
});


