var digitsInUSPhoneNumber = 7;
var digits = "0123456789";

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 (isWhitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

function isTelnumero(c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == " ") || ((c >= "0") && (c <= "9")) || (c == "-") || (c == "."))
}

 function isChequesito (c)
{ return ((c == "'") || (c == '"'))
}

function email (c)
{ return ((c == "@"))
}
 function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || (c == " ") || (c == "á") || (c == "í") || (c == "ó") || (c == "ú") || (c == "é") || (c == "ñ") || (c == "Ñ") )
}

function isLetterFILE (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) || ((c >= "0") && (c <= "9")) || (c == " ") || (c == ".") || (c == ":") || (c == "_") || (c == "-") || (c == "/") || (c == "\\") || (c == ",") || (c == ";") || (c == "!") || (c == "[") || (c == "]") || (c == "{") || (c == "}") || (c == "(") || (c == ")") || (c == "+") || (c == "#") || (c == "@") || (c == "$") || (c == "^") || (c == "%") || (c == "&") || (c == "=") || (c == "á") || (c == "é") || (c == "í") || (c == "ó") || (c == "ú") || (c == "Á") || (c == "É") || (c == "Í") || (c == "Ó") || (c == "Ú") )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isReal (c)
{   return ( ((c >= "0") && (c <= "9")) || (c == "."))
}

function isInteger (s)

{   var i;

    if (isEmpty(s))
       if (isInteger.arguments.length == 1) return false;
       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 isAlphabetic (s)
{
   var i;

    if (isEmpty(s))
    {
       if (isAlphabetic.arguments.length == 1) return false;
       else return (isAlphabetic.arguments[1] == true);
    }

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;

        if (isChequesito(c))
        return false;
    }

    // All characters are letters.
    return true;
}


function isAlphabeticFILE (s)
{
   var i;

    if (isEmpty(s))
    {
       if (isAlphabetic.arguments.length == 1) return false;
       else return (isAlphabetic.arguments[1] == true);
    }

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetterFILE(c))
        return false;

        if (isChequesito(c))
        return false;
    }

    // All characters are letters.
    return true;
}


 function isTelefono (s)
{
   var i;

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isTelnumero(c))
        return false;
      }


    // All characters are letters.
    return true;
}

function isemail (s)
{   var i = 1;
    var sLength = s.length;
    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }
    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;
    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }
    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function isNumero (s)
{
   var i;

    if (isEmpty(s))
    {
       if (isNumero.arguments.length == 1) return false;
       else return (isNumero.arguments[1] == true);
    }

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (isLetter(c))
        return false;

        if (isChequesito(c))
        return false;
    }
    // All characters are letters.
    return true;
}

function isapostrofe (s)
{
   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is letter.
        var c = s.charAt(i);

        if (isChequesito(c))
        return false;
    }

    // All characters are letters.
    return true;
}