function RENformatar(renavam){
   valorFormatado = "";
   for (i=0;i<9-(renavam.length);i++)   {
      valorFormatado = valorFormatado + "0";
   }
   valorFormatado = valorFormatado + renavam;
   return valorFormatado;
}

function RENCalcDigVer(renavam){
	//Calculo do dígito verificador
	soma = 0;
	renav = RENformatar(renavam);
	for (i=(renav.length)-1,j=2;i>0;i--,j++){
      aux = renav.substring(i-1,i);
      soma = soma + (j * aux);
   }
   digito = 11-(soma-((parseInt(soma/11))*11));
   if (digito == 10)
      digito = 0;
   if (digito == 11)
      digito = 0;
   aux = renav.substring(8,9);
   if (aux==digito)
      return true
   else{
      alert("Dígito verificador inválido.");
      return false;
   }
   return true;
}

function RENvalida()
{
	renav = document.debitos.ren.value;
	if (renav==""){
		alert("Informe o Renavam.");
		return false;
	}
	if (isNaN(renav))	{
		alert("Renavam inválido.");
		return false;
	}

	if (RENCalcDigVer(renav))
	   return true
	else
	   return false;
}

function Browser(){
   document.debitos.navigator.value= navigator.appName;
   document.debitos.versao.value = navigator.appVersion;
   document.debitos.ren.focus();
}
        function popup(url, name, width, height)
        {
           var str = "height=" + height + ",innerHeight=" + height;
                str += ",width=" + width + ",innerWidth=" + width;
                str += ",status=yes,scrollbars=yes,resizable=no";
                  if (window.screen)
                {
                        var ah = screen.availHeight - 30;
                        var aw = screen.availWidth - 10;
                        var xc = (aw - width) / 2;
                        var yc = (ah - height) / 2;

                        str += ",left=" + xc + ",screenX=" + xc;
                        str += ",top=" + yc + ",screenY=" + yc;
                }
                var win = window.open(url, name, str);
        }

