
	var whitespace = " \t\n\r";
	var defaultEmptyOK = false;


	function isEmpty(s)
	{
		return ((s == null) || (s.length == 0));
	}

	function isInteger(s)
	{   var i;
	    if (isEmpty(s)) 
	       if (isInteger.arguments.length == 1) return defaultEmptyOK;
	       else return (isInteger.arguments[1] == true);

	    // Search through string's characters one by one
	    // until we find a non-numeric character.
	    // When we do, return false; if we don't, return true.
		
	    for (i = 0; i < s.length; i++)
	    {   
	        // Check that current character is number.
	        var c = s.charAt(i);

	        if (!isDigit(c)) return false;
	    }

	    // All characters are numbers.
	    return true;
	}


	function isDigit(c)
	{   
		return ((c >= "0") && (c <= "9"));
	}


	function isWhitespace(s)
		{   var i;

		    // Is s empty?
		    if (isEmpty(s)) return true;

		    // Search through string's characters one by one
		    // until we find a non-whitespace character.
		    // When we do, return false; if we don't, return true.

		    for (i = 0; i < s.length; i++)
		    {   
		        // Check that current character isn't whitespace.
		        var c = s.charAt(i);

		        if (whitespace.indexOf(c) == -1) return false;
		    }

		    // All characters are whitespace.
		    return true;
		}


	// ***** Comprueba Telefono *****
	function checkTelefono(Tel)
	{
		if (!isInteger(Tel))
		{
			alert("El Teléfono debe ser un valor numérico");
			return false;
		}
		else
		{
			if (Tel.length != 9)
			{
				alert("El Teléfono debe ser un número de 9 dígitos");
				return false;
			}
			else
			{
				if((Tel.substring(0,1)=="6") || (Tel.substring(0,1) =="9"))
				{
					return true;
				}
				else
				{
					alert("El Teléfono debe empezar por 6 0 9");
					return false;
				}
			}
		}
		return true;
	}


	// ***** Comprueba Email *****
	function isEmail (s) {
		if (isEmpty(s))
		if (isEmail.arguments.length == 1) return defaultEmptyOK;
		else return (isEmail.arguments[1] == true);

		// tiene espacios en blanco??
		if (isWhitespace(s)){
			alert ("El Correo electrónico no tiene un formato válido.");
			return false;
		}
		    
		var i = 1;
		var sLength = s.length;

		// Buscando la @
		while ((i < sLength) && (s.charAt(i) != "@")) {
			 i++;
		}

		if ((i >= sLength) || (s.charAt(i) != "@")){
			alert ("El Correo electrónico no tiene un formato válido.");
			return false;
		}
		else i += 2;

		// Buscando el .
		while ((i < sLength) && (s.charAt(i) != ".")) {
			i++;
		}

		// Debe de haber al menos un carácter después del punto
		if ((i >= sLength - 1) || (s.charAt(i) != ".")){
			alert ("El Correo electrónico no tiene un formato válido.");
			return false;
		}
		else return true;
	}


