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

  $(".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 phone = $("input#phone").val();
		var my_comment = $("textarea#my_comment").val();
		if (my_comment == "") {
      	$("label#my_comment_error").show();
     	 $("textarea#my_comment").focus();
      	return false;
   	 }
		

		
		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&my_comment=' + my_comment;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://www.georgyannaink.com/contact_form.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<b>Thank you for contacting Georgyanna Ink.</b><br />")
        .append("We will be in contact with you shortly.")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});
