function tooltips() {
// select all desired input fields and attach tooltips to them
	$("#checkout :input").tooltip({
		// place tooltip on the right edge
		position: "center right",
		// a little tweaking of the position
		offset: [-2, 1],
		// use the built-in fadeIn/fadeOut effect
		effect: "fade",
		// custom opacity setting
		opacity: 0.7
	});
};
function valida_envia(correo){

//Variables
	var textoValido = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú .";
	var emailValido = "-_@0123456789" + "abcdefghijklmnopqrstuvwxyz.";
	var numeroValido = "0123456789";
	
// revisa estado en producto
	if (document.checkout.producto.selectedIndex==0){
        alert ( "Debe elegir un producto." );
		document.checkout.producto.focus()
		return 0;
	}
//valido el nombre
	var txtnombre = document.checkout.nombre.value.length
    if ((txtnombre < 3) || ( txtnombre > 20)){
		alert('Debe introducir su nombre con un mínimo de 3 caracteres'); 
		document.checkout.nombre.focus();
		return (false);
		}
	var checkStrNombre = document.checkout.nombre.value;
	var allNombreValid = true;
	for (i = 0; i < checkStrNombre.length; i++) {
		ch = checkStrNombre.charAt(i);
		for (j = 0; j < textoValido.length; j++)
		if (ch == textoValido.charAt(j))
		break;
		if (j == textoValido.length) {
			allNombreValid = false;
			break;
			}
		}
		if (!allNombreValid) {
			alert("Escriba sólo letras en el campo Nombre");
			document.checkout.nombre.focus();
			return (false);
		}
//valido el apellido
	var txtapellido = document.checkout.apellido.value.length
    if ((txtapellido < 3) || ( txtapellido > 20)){
		alert('Debe introducir su apellido con un mínimo de 3 caracteres'); 
		document.checkout.apellido.focus();
		return (false);
		}
	var checkStrApellido = document.checkout.apellido.value;
	var allApellidoValid = true;
	for (i = 0; i < checkStrApellido.length; i++) {
		ch = checkStrApellido.charAt(i);
		for (j = 0; j < textoValido.length; j++)
		if (ch == textoValido.charAt(j))
		break;
		if (j == textoValido.length) {
			allApellidoValid = false;
			break;
			}
		}
		if (!allApellidoValid) {
			alert("Escriba sólo letras en el campo Apellido");
			document.checkout.apellido.focus();
			return (false);
		}
// revisa estado en combobox
	if (document.checkout.estado.selectedIndex==0){
        alert ( "Debe elegir un estado." );
		document.checkout.estado.focus()
		return 0;
	}

//Revisa correos			
			var txtEmail = document.checkout.email.value
			m1 = txtEmail.indexOf('@', 1) == -1; //se fija si contiene la arroba
			d2 = (txtEmail.indexOf('@', 1) == 1)+2; //se fija si la @ está al menos a dos caracteres
			m2 = txtEmail.indexOf('.', d2) == -1; // verifica que contenga un punto
			m3 = txtEmail.length < 7; // verifica que al menos tenga 7 caracteres en total ¿Por qué? una dirección con un mínimo de caracteres para que sea valida, será [email]x@xx.xx[/email]			
 		if (m1||m2||m3) {
			alert("Escriba una dirección de correo válida en el campo Dirección de correo");
			document.checkout.email.focus();
			return (false);
		}

	var allEmailValid = true;
	for (i = 0; i < txtEmail.length; i++) {
		ch = txtEmail.charAt(i);
		for (j = 0; j < emailValido.length; j++)
		if (ch == emailValido.charAt(j))
		break;
		if (j == emailValido.length) {
			allEmailValid = false;
			break;
			}
		}
		if (!allEmailValid) {
			alert("Escriba caracteres válidos en el campo Email. Recuerde que su correo no puede contener acentos, comas, espacios, mayúsculas ni la letra 'ñ'");
			document.checkout.email.focus();
			return (false);
		}

//valido telefono. tiene que ser entero de 10 caracteres

		var txtTel = document.checkout.telefono.value.length;
		var validar_tel = document.checkout.telefono.value;
		var allTelValid = true;
		for (i = 0; i < validar_tel.length; i++) {
			ch = validar_tel.charAt(i);
			for (j = 0; j < numeroValido.length; j++)
			if (ch == numeroValido.charAt(j))
			break;
			if (j == numeroValido.length) {
				allTelValid = false;
				break;
				}
			}
			if (!allTelValid) {
				alert("Escriba sólo números en al campo Teléfono");
				document.checkout.telefono.focus();
				return (false);
			}

    	if ((txtTel < 10) || ( txtTel > 10)){
			alert('Debe introducir su teléfono a 10 dígitos (con clave lada, es decir, las cifras que siguen al prefijo 01 en México)'); 
			document.checkout.telefono.focus();
			return (false);
			}
		else if (validar_tel <= 2220000000)
			{
			alert("Debes escribir una clave lada válida (las cifras que siguen al prefijo 01 en México)")
			document.checkout.telefono.focus();
				return (false);
			}


			
//valido telefono. tiene que ser entero de 10 caracteres
		var txtCel = document.checkout.celular.value.length;
		var validar_cel = document.checkout.celular.value;
    	if ((txtCel < 10) || ( txtCel > 10)){
			alert('Debe introducir su celular'); 
			document.checkout.celular.focus();
			return (false);
			}
	else if (validar_cel <= '2220000000')
			{
			alert("Debes escribir una clave lada válida para su número de celular (las dos cifras que siguen al prefijo 044)")
				document.checkout.celular.focus();
				return (false);
			}
		var checkStrCel = document.checkout.celular.value;
		var allTelValid = true;
		for (i = 0; i < checkStrCel.length; i++) {
			ch = checkStrCel.charAt(i);
			for (j = 0; j < numeroValido.length; j++)
			if (ch == numeroValido.charAt(j))
			break;
			if (j == numeroValido.length) {
				allTelValid = false;
				break;
				}
			}
			if (!allTelValid) {
				alert("Escriba sólo números en al campo Celular");
				document.checkout.celular.focus();
				return (false);
			}


//el formulario se envia
	document.checkout.submit();
}

