$(function() {
	$('.error').hide();

	$("#buttonLimpiar").click(function() {
		$('.error').hide();
		$("input#email").focus();
	});

	$("#buttonSubmit").click(function() {
		$('.error').hide();

		var email = $("input#email").val();
		if (email == "") {
			$("label#email_error").show();
			$("input#email").focus();
			return false;
		}

		if (!validar_correo(email)) {
			$("label#email_error_validacion").show();
			$("input#email").focus();
			return false;
		}

		var dataString = 'email=' + email;

		$.ajax( {
			type : "POST",
			url : "recordarPassword.enviar.php",
			data : dataString,
			cache : false,
			contentType : "application/x-www-form-urlencoded;charset=utf-8",
			dataType : "text",
			success : function(data) {
				mostrarAlert('Correcto',data);
			},
			error : function() {
				mostrarAlert('Error','Se ha producido un error.');
			}
		});
		return false;
	});
});
runOnLoad(function() {
	$("input#email").select().focus();
});
