$(function() {
  $('.error').hide();
  $('input.input, textarea, select').css({backgroundColor:"#FFFDF0"}).css({borderColor:"#448aae"});
  $('input.input, textarea, select').focus(function(){
    $(this).css({backgroundColor:"#FFF0B7"}).css({borderColor:"#ff0000"});
  });
  $('input.input, textarea, select').blur(function(){
    $(this).css({backgroundColor:"#FFFDF0"}).css({borderColor:"#448aae"});
  });

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
		var nombre = $("input#txtNombre").val();
		if (nombre == "") {
		  $("label#error_nombre").show();
		  $("input#txtNombre").focus();
		  return false;
		}
		var apellido = $("input#txtApellido").val();
		if (apellido == "") {
		  $("label#error_apellido").show();
		  $("input#txtApellido").focus();
		  return false;
		}
		var email = $("input#txtEmail").val();
		if (email == "") {
		  $("label#error_email").show();
		  $("input#txtEmail").focus();
		  return false;
		}
		var pais = $("input#txtPais").val();
		if (pais == "") {
		  $("label#error_pais").show();
		  $("input#txtPais").focus();
		  return false;
		}
		var day = $("select#selDay").val();
		var month = $("select#selMonth").val();
		var year = $("select#selYear").val();
		var tour = $("input#txtTour").val();
		if (tour == "") {
		  $("label#error_tour").show();
		  $("input#txtTour").focus();
		  return false;
		}
		var sugerencia = $("textarea#txtSugerencia").val();
		
		var dataString = 'nombre=' + nombre + '&apellido=' + apellido + '&email=' + email + '&pais=' + pais + '&day=' + day + '&month=' + month + '&year=' + year + '&tour=' + tour + '&sugerencia=' + sugerencia;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "includes/process.php",
      data: dataString,
      success: function() {
        $('#frmBooking').html("<div id='message'></div>");
        $('#message').html("<h3>Su reserva ha sido enviada!</h3>")
        .append("<p>Pronto nos estaremos contactando con Ud. para confirmar su reserva.</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message')
		  // .append("<img id='checkmark' src='interface/check.png' />");
        });
      }
     });
    return false;
	});
});

/*
runOnLoad(function(){
  $("input#txtNombre").select().focus();
});
*/

