$(function() {
  $('.mandatory').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"});
  });

  $(".go-button").click(function() {
    $('.mandatory').hide();
		
	  var name = $("input#name").val();
	  if (name == "") {
		$("span#name_error").show();
		$("input#name").focus();
		return false;
	  }
	  var email = $("input#email").val();
	  if (email == "") {
		$("span#email_error").show();
		$("input#email").focus();
		return false;
	  }
		
	  var phone = $("input#phone").val();
	  var troop = $("input#unit").val();
	  var address = $("input#address").val();
	
	  var subject = $("input#subject").val();
	  if (subject == "") {
		$("span#subject_error").show();
		$("input#subject").focus();
		return false;
	  }
	
	  var message = $("textarea#message").val();
	  if (message == "") {
		$("span#message_error").show();
		$("textarea#message").focus();
		return false;
	  }
		
	  var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&subject=' + subject + '&unit=' + troop + '&address=' + address + '&message=' + message;
		
	  $.ajax({
		type: "POST",
		url: "./includes/mail_quick_contact.php",
		data: dataString,
		success: function() {
		  $('#footer').html("<div id='footer-form-message'></div>");
		  $('#footer-form-message').html("<h4>Thank You!</h4>")
		  .append("<p>Your message has been received and we will be in touch soon.</p>")
		  .hide()
		  .fadeIn(1500);
		}
	  });
	  return false;
  });
});
