function IsEmail(email)
{
// Verifica se o texto recebido é um endereço de e-mail válido e retorna true ou false.
// Ex.: if (!IsEmail(document.form.email.value)) {...}
// Willian Cruz, 03/Out/02 - wcruz@pobox.com
    // Não pode ser vazio
    email = trim(email);
    if (email == '') {
        return false;
    }
    // Procura caracteres inválidos
    Invalid  = " /:,;";
    for (i=0; i<Invalid.length; i++) {
        if (email.indexOf(Invalid.charAt(i),0) > -1) {
            return false;
        }
    }
    // Não pode começar com www
    upper = email;
    upper.toLowerCase;
    if (upper.substr(0,3) == 'www') {
        return false;
    }
    // Outras checagens
    Arroba   = email.indexOf('@');
    Arroba2  = email.lastIndexOf('@');
    Ponto    = email.lastIndexOf('.');
    if (    (Arroba < 1)        ||  // '@' nao pode ser o primeiro caractere
        (Arroba != Arroba2)     ||  // não pode ter duas '@'
        (Ponto <= Arroba+1) ||  // tem que haver pelo menos um caractere valido entre '@' e '.'
        (Ponto >= email.length-2 )  // tem que haver pelo menos dois caracteres após o último '.'
        ) {
            return false;
    }
    return true;
}

function trim(texto) {
    while (texto.length > 0 && texto.charAt(0) == ' ') {
        texto = texto.substr(1);
    }
    while (texto.length > 0 && texto.charAt(texto.length-1) == ' ') {
        texto = texto.substr(0,texto.length-1);
    }
    return texto;
}

function textCounter(field, maxlimit) {
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
}