function goto(url) {
	document.location.href = url;
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g,"");
}

function VerificaEmail(mail){
  var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

  if(er.test(mail)) {
	return true;
  } else {
   	return false;
  }

}

function VerificaData(campo, bNulos)
{
    valor = campo.value;
    dia = valor.substring(0,2);
    mes = valor.substring(3,5);
    ano = valor.substring(6,10);

    if (bNulos == false) {
        if ( (dia=="") && (mes=="") && (ano=="") ) {
            alert("Este campo não pode ser nulo");
            campo.focus();
            campo.select();
            return false;
        }
    } else {
        if ( (dia=="") && (mes=="") && (ano=="") ) {
            return true;
        }
    }

    barra1 = valor.substring(2,3);
    barra2 = valor.substring(5,6);

        msgErro = '';

    if ( (isNaN(dia)) || (isNaN(mes)) || (isNaN(ano)) )
    {
        alert('Data inválida. Por favor, digite novamente.');
        return false;
    } else {
        if ( (barra1 != '/') || (barra2 != '/') )
        {
             alert('Data inválida. Por favor, digite novamente.');
             return false;
        }

        if ( (dia=="") || (mes=="") || (ano=="") )
        {
            alert('Formato inválido de data. Por favor, digite novamente.');
            return false;
        } else {
            if ((dia>31)||(dia<1))
            {
                alert('Dia inválido. Por favor, preencha corretamente');
                return false;
            }
            if ((mes>12)||(mes<1))
            {
                alert('Mês inválido. Por favor, preencha corretamente');
                return false;
            }
            if (ano.length < 4)
            {
                alert('Ano inválido. Por favor, preencha corretamente');
                return false;
            }
            if (mes==2)
            {
                if (((dia)>29)||(dia=='29' && (ano)%4!=0))
                {
                    alert('Dia inválido. Por favor, preencha corretamente');
                    return false;
                }
            } else {
                if ( ( (mes==4) || (mes==6) || (mes==9) || mes=='11') && (dia>30) )
                {
                    alert('Dia inválido. Por favor, preencha corretamente');
                    return false;
                } else {
                    if (dia>31)
                    {
                        alert('Dia inválido. Por favor, preencha corretamente');
                        return false;
                    }
                }
            }
        }
    }
return true;
}
