function IsEmail(EMAIL){
// verifica se o endereço de email é válido e retorna true ou false.
// Ex.: if (!IsEmail(document.form.email.value)) {executa função}

// Não pode ser vazio, elimina os espaços
    EMAIL = trim(EMAIL);
    if (EMAIL == '') {
        return false;
    }
// Procura caracteres inválidos no email digitado
    Invalid  = " /:,;";
    for (i=0; i<Invalid.length; i++) {
        if (EMAIL.indexOf(Invalid.charAt(i),0) > -1) {
            return false;
        }
    }
// O email não pode começar com www
    upper = EMAIL;
    upper.toLowerCase;
    if (upper.substr(0,3) == 'www') {
        return false;
    }
// Completa com 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 válido 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);
}

