$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var firstname = $("input#firstname").val();
		if (firstname == "") {
      $("label#firstname_error").show();
      $("input#firstname").focus();
      return false;
    }
	  var lastname = $("input#lastname").val();
		if (lastname == "") {
      $("label#lastname_error").show();
      $("input#lastname").focus();
      return false;
    }
	  var company = $("input#company").val();
		if (company == "") {
      $("label#company_error").show();
      $("input#company").focus();
      return false;
    }
	  var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
	var title = $("input#title").val();
	var phone = $("input#phone").val();
	var industry = $("input#industry").val();
	var comments = $("input#comments").val();
		
		var dataString = 'firstname='+ firstname + '&lastname=' + lastname + '&company=' + company + '&title=' + title + '&phone=' + phone + '&email=' + email + '&industry=' + industry + '&comments=' + comments;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<strong>Contact Form Submitted!</strong>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  //$("input#firstname").select().focus();
});

