function validaCNPJ(cnpj)
      {
      var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
      digitos_iguais = 1;
      if (cnpj.length < 14 && cnpj.length < 15)
            return false;
      for (i = 0; i < cnpj.length - 1; i++)
            if (cnpj.charAt(i) != cnpj.charAt(i + 1))
                  {
                  digitos_iguais = 0;
                  break;
                  }
      if (!digitos_iguais)
            {
            tamanho = cnpj.length - 2
            numeros = cnpj.substring(0,tamanho);
            digitos = cnpj.substring(tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(0))
                  return false;
            tamanho = tamanho + 1;
            numeros = cnpj.substring(0,tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(1))
                  return false;
            return true;
            }
      else
            return false;
      }





function validaCPF(_cpf){
	var soma = 0;
	var multiplicador = 9;

	if(_cpf.length == 11){
		for(var cont = (_cpf.length - 3); cont >= 0;--cont){
			soma += parseInt(_cpf.charAt(cont)) * multiplicador;

			--multiplicador;
			if(multiplicador == 0)
				multiplicador = 9;
		}

		var div = (soma % 11);
		if(div == 10)
			div = 0;

		if(div == parseInt(_cpf.charAt(_cpf.length - 2))){
			soma = 0;
			multiplicador = 9;

			for(var cont = (_cpf.length - 2); cont >= 0;--cont){
				soma += parseInt(_cpf.charAt(cont)) * multiplicador;

				--multiplicador;
			}


			div = (soma % 11);
			if(div == 10)
				div = 0;

			if(div == parseInt(_cpf.charAt(_cpf.length - 1))){
				return true;
			}
		}
	}
	return false;
}

function validaEMail(_email){
	if(_email == ""){
		return false;
	}
	else{
		if(_email.indexOf('@') < 0 || _email.substring(_email.indexOf('@')).indexOf('.') < 0)
			return false;
	}

	return true;
}
