
$(document).ready(function() {
	
//------------------------------------------//
	//Conteudo que aparece nos campos//
	
	var strnome = "nome"  
	var strmail = "e-mail"
	
//------------------------------------------//
	
	$("#nome").val(strnome);
	$("#email").val(strmail);
	
	$("#nome").click(function(){
		if ($("#nome").val() == strnome){
			$("#nome").val("");
		}
	});
	
	$("#email").click(function() {
		if($("#email").val() == strmail){
			$("#email").val("");
		}
	});
	
	$("#nome").blur(function() {
	if ($("#nome").val() == ""){
			$("#nome").val(strnome);
		}
	});
	
	$("#email").blur(function() {
		if ($("#email").val() == ""){
			$("#email").val(strmail);
		}
	});
	
	$("#enviar").click(function(){		
		if ($("#nome").val() == strnome){
			$("#msgnews").html("Preencha o nome!");
		}else if ($("#email").val() == strmail){
			$("#msgnews").html("Preencha o email!");
		}else{
			var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
			if (!regmail.test($("#email").val())) {
				$("#msgnews").html("Email Invalido!");
			}else{
				var nomeDig  = $("#nome").val();
				var emailDig = $("#email").val();
				$.ajax({
					type: 'get',
				  	data: 'nome='+nomeDig+'&email='+emailDig,
				  	url:'php/news.php',
				  	success: function(retorno){
						$('#msgnews').html(retorno);
						$("#nome").val(strnome);
						$("#email").val(strmail);
				  	}
				})
			}
		}
	});
	
});


