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

  $(".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 youremail = $("input#youremail").val();
		if (youremail == "") {
      $("label#name_error").show();
      $("input#youremail").focus();
      return false;
    }

		var store = $("select#store").val();
		if (store == "") {
      $("label#store_error").show();
      $("input#store").focus();
      return false;
    }
		var yourmessage = $("textarea#yourmessage").val();
		if (yourmessage == "") {
      $("label#yourmessage_error").show();
      $("textarea#yourmessage").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&store=' + store + '&yourmessage=' + yourmessage + '&youremail=' + youremail;
		alert (dataString);
		
		$.ajax({
      type: "GET",
      url: "aheymrmas.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<h2>Mr. Mas Form Submitted!</h2>")
        .append("<p>Thank You.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='/images/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#name").select().focus();
});
