$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#eaffae"});
  $('input.text-input,textarea#message,input#mce-EMAIL').focus(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
 
  $('input.text-input,textarea#message,input#mce-EMAIL').blur(function(){
    $(this).css({backgroundColor:"#eaffae"});
  });
  $(".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 email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var company = $("input#company").val();
		if (company == "") {
      $("label#company_error").show();
      $("input#company").focus();
      return false;
    }
		var message = $("textarea#message").val();
		
		var dataString = 'name='+ name + '&email=' + email + '&company=' + company + '&message=' + message;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact-us').html("<div id='response' class='rounded'></div>");
        $('#response').html("<img id='checkmark' src='images/check.png' /><h2>Contact Form Submitted!</h2>")
        .append("<span>We will be in touch soon.</span>")
        .hide()
        .fadeIn(1500, function() {
          $('#response').append("");
        });
      }
     });
    return false;
	});
});
