$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#EBFEFC"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
$('textarea').focus(function(){
    $(this).css({backgroundColor:"#EBFEFC"});
  });
  $('textarea').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  
  $(".button").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 company = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").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 + '&phone=' + phone;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "inc/form_process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message' style='margin:50px 0 0 200px;'></div>");
        $('#message').html("<img id='checkmark' src='images/check.png' /><br /><br /><br />")
        
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<h3>Thank You!</h3><p>We will be in touch soon.</p>");
        });
      }
     });
    return false;
	});
});

