 $(function() {  
   $('.error').hide();  
   $(".button").click(function() {  
     // validate and process form here  

     $('.error').hide();  
       var name = $("input#name").val();  
         if (name == "") {  
       $("label#name_error").show();  
       $("input#name").focus();  
       return false;  
     }  
         var email = $("input#email").val();  
         if (email == "") {  
       $("label#email_error").show();  
       $("input#email").focus();  
       return false;  
     }  

     var dataString = 'name='+ name + '&email=' + email;
     //alert (dataString);return false;
		
      $.ajax({
      type: "POST",
      url: "/email_process",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>You Details Have Been Submitted!</h2>")
        .append("<p>We will send future magazines straight to your inbox.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message');
        });
      }
     });
    return false;

   });  
 });  
