$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFE1E2"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFE1E2"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFE1E2"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("input#email").focus();
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      $("input#phone").focus();
      return false;
    }
		var telefone = $("input#telefone").val();
		if (telefone == "") {
      $("input#telefone").focus();
      return false;
    }
		var mensagem = $("textarea#mensagem").val();

		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&telefone=' + telefone + '&mensagem=' + mensagem;
		//(dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#form').html("<div id='message'></div>");
        $('#message').html("<img id='checkmark' src='images/check.png' alt='Checkmark' />")
        .append("<h2>Sua mensagem foi enviada com sucesso!</h2>")
		.hide()
        .fadeIn(1500, function() {
          $('#message').append(" ");
        });
	  }
     });
    return false;
	});
});
