$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  /*$('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#E4F5FA"});
  });*/
  
 
/* end edit */
  
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
	$('.error').hide();
  });

  $(".submitbtn").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();
	  $('input.text-input').css({backgroundColor:"#FFB0B0"});
      return false;
    }
	//address
	var address = $("input#address").val();

	
	
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
	   $('input.text-input').css({backgroundColor:"#FFB0B0"});
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
	   $('input.text-input').css({backgroundColor:"#FFB0B0"});
      return false;
    }
		
		var msg = $("textarea#msg").val();
		if (msg == "") {
      $("label#msg_error").show();
      $("textarea#msg").focus();
	   $('input.text-input').css({backgroundColor:"#FFB0B0"});
	 
	   
      return false;
    }
		
		var dataString = 'name='+ name +'&address='+address+ '&email=' + email + '&phone=' + phone+ '&msg=' + msg;
		//alert (dataString);return false;  
		
		$.ajax({
      type: "POST",
      url: "process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Thank You! <img id='checkmark' src='../../js/images/check.png' /></h2> ")
        .append("<p>We appreciate you taking the time to contact us.</p><h2>If You Made A Request for a Proposal</h2><p>Now  that we have some of your project basics, you can expect a phone call  or an email within one or two business days from one of our talented  consultants. They will further discuss your project with you so that we  can send an accurate proposal. We look forward to creating your next  identity on the web.</p><h2>If You Reported An Issue With Your Website </h2><p>We are on it.. and you should be hearing from someone shortly.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});

