$(function() {
    $('.error').hide();
    $('input').focus(function (){$(this).css({"border": "1px solid #3E0B08"})});
	$('input').blur(function (){$(this).css({"border": "1px solid #CCC"})});
	$('textarea').focus(function (){$(this).css({"border": "1px solid #3E0B08"})});
	$('textarea').blur(function (){$(this).css({"border": "1px solid #CCC"})});
    $(".submit").click(function() {
        $('.error').hide();
        var nome = $("#nome").val();
		if (nome == "") {
            $("#nome_erro").show();
            $("#nome").focus();
        return false;
        }
        var email = $("#email").val();
		if (email == "") {
            $("#email_erro").show();
            $("#email").focus();
        return false;
        }
		var mensagem = $("#mensagem").val();
		if (mensagem == "") {
            $("#mensagem_erro").show();
            $("#mensagem").focus();
        return false;
        }

        var dataString = 'nome='+ nome + '&email=' + email + '&mensagem=' + mensagem;
        $.ajax({
        type: "POST",
        url: "contato_ok.php",
        data: dataString,
        success: function() {
            $('#form1').html("<div id='message'><\/div>");
            $('#message').html("<p><strong>Mensagem enviada!<\/strong><\/p>")
            .append("<p>Em breve responderemos.<\/p>")
            .hide()
            .fadeIn(500, function() {
                $('#message').append("<img id='checkmark' src='layout/enviado.gif' />");
            });
        }
        });
        return false;
	});
});
runOnLoad(function(){
  $("input#nome").select().focus();
});
