$(function() {
  $('.error').hide();

  $(".btn").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	
	var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	
	var dataString = 'email=' + email;
		
		function success() {
	        $('#contact_form').html("<div id='message'></div>");
	        $('#message').html("")
	        .append("<p style='font-size:25px; float:left; line-height:normal;'>Gracias por suscribirte.</p>")
	        .hide()
	        .fadeIn(1500, function() {
	          $('#message').append("<img style='padding-left:0px;padding-top:60px;' id='checkmark' src='images/check.png' />");
        	});
        }
        function error() {
	        $('#contact_form').html("<div id='message'></div>");
	        $('#message').html("")
	        .append("<p style='font-size:25px; color:red; float:left; line-height:normal;'>Lo sentimos, tu correo ya est&aacute; registrado. Gracias.</p>");
		}
		$.post("http://www.mejoresempresasmexicanas.com/bin/send.php", { email: email },
   			function(data){
   			if(data){
     			success();
     		}else{
     			error();
     		}
   		});
		
    return false;
	});
});
