$(function() {
  $('.error').hide();
  $('input.text').css({backgroundColor:""});
  $('input.text').focus(function(){
    $(this).css({backgroundColor:""});
  });
  $('input.text').blur(function(){
    $(this).css({backgroundColor:""});
  });

  $(".send").click(function() {
		// validate and process form
		// first hide any error messages
    $('.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 message = $("textarea#message").val();
		if (message == "") {
      $("label#messae_error").show();
      $("textarea#message").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='alert'></div>");
        $('#alert').html("<h6>Contact Form Submitted!</h6>")
        .append("<blockquote>Thanks for contacting me, i'll be in touch with you soon!</blockquote>")
        .hide()
        .fadeIn(1500, function() {
          $('#alert').append("");
        });
      }
     });
    return false;
	});
});