// JavaScript Document

function verificaCNPJ(CNPJparaVerificar)
{
if(CNPJparaVerificar == 0)
	{
	return(0);
	}
else
	{
	g=CNPJparaVerificar.length-2;
	if(RealTestaCNPJ(CNPJparaVerificar,g) == 1)
		{
		g=CNPJparaVerificar.length-1;
		if(RealTestaCNPJ(CNPJparaVerificar,g) == 1)
			{	
			return(1);
			}
		else
			{
			return(0);
			}
		}
	else
		{
		return(0);
		}
	}
}

function RealTestaCNPJ(CNPJ,g)
{
var VerCNPJ=0;
var ind=2;
var tam;
for(f=g;f>0;f--)
	{
	VerCNPJ+=parseInt(CNPJ.charAt(f-1))*ind;
	if(ind>8)
		{
		ind=2;
		}
	else
		{
		ind++;
		}
	}
	VerCNPJ%=11;
	if(VerCNPJ==0 || VerCNPJ==1)
		{
		VerCNPJ=0;
		}
	else
		{
		VerCNPJ=11-VerCNPJ;
		}
if(VerCNPJ!=parseInt(CNPJ.charAt(g)))
	{
	return(0);
	}
else
	{
	return(1);
	}
}

function ocultaCampos(camposString)
{
splitString = camposString.split(",") ;

for (x=0;x<=(splitString.length-1);x++)
	{
	if (document.getElementById(splitString[x]) != null)
		{
		document.getElementById(splitString[x]).style.visibility='hidden';
		document.getElementById(splitString[x]).style.position='absolute';
		}
	}
}

function mostraCampos(camposString)
{
splitString = camposString.split(",") ;

for (x=0;x<=(splitString.length-1);x++)
	{
	if (document.getElementById(splitString[x]) != null)
		{
		document.getElementById(splitString[x]).style.visibility='visible';
		document.getElementById(splitString[x]).style.position='relative';
		}
	}
}

function mostraSeq()
{
var wi;
wi=setTimeout("tornaBranco('q01')",100);
wi=setTimeout("tornaBranco('q02')",200);
wi=setTimeout("tornaBranco('q03')",300);
wi=setTimeout("tornaBranco('q04')",400);
wi=setTimeout("tornaBranco('q05')",500);
wi=setTimeout("tornaBranco('q06')",600);
wi=setTimeout("tornaBranco('q07')",700);
wi=setTimeout("tornaCinza('q01')",800);
wi=setTimeout("tornaCinza('q02')",900);
wi=setTimeout("tornaCinza('q03')",1000);
wi=setTimeout("tornaCinza('q04')",1100);
wi=setTimeout("tornaCinza('q05')",1200);
wi=setTimeout("tornaCinza('q06')",1300);
wi=setTimeout("tornaCinza('q07')",1400);
wi=setTimeout("mostraSeq()",1400);
}

function tornaBranco(lID)
{
document.getElementById(lID).style.backgroundColor='';
}

function tornaCinza(lID)
{
document.getElementById(lID).style.backgroundColor='#999999';
}

function apenasnumericos(caracter)
{
if(document.all) {var tecla = event.keyCode;}else {if(document.layers) {var tecla = caracter.which;}}if(tecla > 47 && tecla < 58) {return true;}else {if (tecla != 8) {return false;}else {return true;}}
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 ;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return null;
}

function setCookie(c_name,value)
{
var exdate=new Date("December 31, 2023");
exdate = exdate.toGMTString();
document.cookie=c_name + '=' + escape(value) + '; expires=Thu, 31-Dec-2023 00:00:00 GMT';
}
