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

		$('.error').hide();
		
		var name = $("input#name").val();
		var email = $("input#email").val();
		var message = $("textarea#message").val();
		
		if (name == "" || email == "" || message == "") {
			$(".error").show();

			return false;
		}
		
		var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
		
		$.ajax({
		type: "POST",
		url: "http://rickyrobertsiii.com/wordpress/wp-content/themes/RR/form/process.php",
		data: dataString,
		success: function() {
			$('#contact-form').html("<div id='message'></div>");
			$('#message').html("<h4>Contact Form Submitted!</h4>")
			.append("<p>Thank you for taking the time to reach out to me. I will be in touch soon. YOU ARE VALUED!</p>")
			.hide()
			.fadeIn(1500);
		},
		error: function () {
			$('#contact-form').html("<div id='message'></div>");
			$('#message').html("<h4>Contact Form Error!</h4>")
			.append("<p>There was an error. Try refreshing the page and trying again.</p>")
			.hide()
			.fadeIn(1500);
		}
		});
		
		return false;
	
	});
});
