$(function() {
  $('.error').hide();
  $('input.text-input').css({backgroundColor:"#FFFFFF"});
  $('input.text-input').focus(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });
  $('input.text-input').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var nombre = $("input#nombre").val();
		if (nombre == "") {
      $("label#error").show();
      $("input#nombre").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#error").show();
      $("input#email").focus();
      return false;
    }
		var mensaje = $("textarea#mensaje").val();
		if (mensaje == "") {
      $("label#error").show();
      $("textarea#mensaje").focus();
      return false;
    }
	//var dto=$("#dto").val();
		
		var dataString = 'nombre='+ nombre + '&email=' + email + '&mensaje=' + mensaje ;
		//alert (dataString);return false;
	  $.ajax({
      type: "POST",
      url: "motor/sendCorreo.php",
      data: dataString,
      success: function(datos) {
	 
        $('#cargaRespo').html("<div id='message'></div>");
        $('#message').html("<h2> Mensaje Enviado!</h2>")
        .append(datos)
		.hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("input#nombre").select().focus();
});
