$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#acf0f2"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#acf0f2"});
  });
  $('textarea.text-input').css({backgroundColor:"#acf0f2"});
  $('textarea.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('textarea.text-input').blur(function(){
    $(this).css({backgroundColor:"#acf0f2"});
  });

  $("#submit-btn").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "name") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "email") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var message = $("textarea#message").val();
		if (message == "type here...") {
      $("label#message_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_working.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='final_message'></div>");
        $('#final_message').html("<h2>Contact Form Submitted!</h2>")
        .append("<p>We will be in touch soon!!!</p>")
        .hide()
        .fadeIn(500, function() {
          $('#final_message').append("<img id='checkmark' src='css/images/check.png' />");
        });
      }
     });
    return false;
	});
});

