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

  $(".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;
    }
		// email test
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		
		var email = $("input#email").val();
		if (email == "" || ( ! (reg.test(email)) ) ) {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		
		
		var dataString = 'name='+ name + '&email=' + email;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://www.hgacreative.com/bin/process.php",
	  // url: "http://hgacreativemail.com/interface/list.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Thanks!</h2>")
        .append("<p>We will be in touch soon.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message');
		  /*.append("<img id='checkmark' src='images/check.png' />");*/
        });
      }
     });
    return false;
	});
});
