 jQuery(document).ready(function($) {
    
  $('.error').hide();
  
  
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  
   $('textarea.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('textarea.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  
  
  
   $(".button").click(function() {// validate and process form
		// first hide any error messages
    $('.error').hide();
	
	 var contactname = $("input#contactname").val();
		if (contactname == "") {
      $("label#contactname_error").show();
      $("input#contactname").focus();
      return false;
    }
	
	
	 var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
	var message = $("textarea#message").val();
	if (message == "") {
      $("label#message_error").show();
      $("input#message").focus();
      return false;
    }
		
		
		
	
	
  var dataString = 'contactname='+ contactname +  '&phone=' + phone +  '&message=' + message + '&submit=' + 'submit';
  //alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "http://www.southeasttree.com/wp-content/themes/southeast/qcontact.php",
      data: dataString,
      success: function() {
	  $('#treequoteform').hide();
        $('#mjc').html("<div id='message2' align='center'></div>");
        $('#message2').html("<h2>Your message has been sent!</h2>")
        .append("<p>Thanks for contacting South East Trees Experts. </p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message2').append("<p align='center'><img id='checkmark' src='http://www.southeasttree.com/wp-content/themes/southeast/images/check.png' /></p>");
        });
      }
     });
 
	});
  
});
		
		
		
