/*========================================================*/
/* Funções da enquete            			  */				
/*========================================================*/

var resposta = "";

function votar() {
	if ( resposta != "") {
		window.open('http://www.guiaextremosul.com.br/enquetes/resultado_enquete.php?cod_resposta='+resposta+'&cod_enquete='+enquete,'votar','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=360,height=270,top=50,left=100');
	}
	else{
		alert('Selecione uma resposta!')
	}
}

function resultado_parcial() {
	window.open('http://www.guiaextremosul.com.br/enquetes/resultado_enquete.php?cod_enquete='+enquete,'resultado_parcial','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=360,height=270,top=50,left=100');
}


function popup_guia_medico() {
	window.open('http://www.unimedvitoria.com.br/guia_medico/index.php','Guia','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=530,height=490,top=30,left=100');
}


function popup_cadastra_senha() {
	window.open('https://www.Netxplorerconsultoria.com.br/servicosonline/cliente/cadastra_senha.php','Cadastro','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=530,height=490,top=30,left=100');
}



/*========================================================*/
/* Funções Javascript não revisadas            			  */				
/*========================================================*/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i>a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

var browser = navigator.appName
var isNav, isIE
if (browser == "Netscape") { 
      isNav = true	
}
else { 
if (browser == "Microsoft Internet Explorer") { 
      isIE = true	
}
}


var cm=null;
document.onclick = new Function("show(null)")

function show(el,m) {
if (isNav) {
	if (m) {
		m.visibility='show';
			}
	if ((m!=cm) && (cm)) cm.visibility='hidden'
	cm=m
} 
if(isIE) {
	if (m) {
		m.style.visibility='';
			}
	if ((m!=cm) && (cm)) cm.style.visibility='hidden'
	cm=m
}

}

function MM_HideLayers() { //v3.0
  var i,p,v,obj,args=MM_HideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function Popup(arq,janela,lar,alt) {
    window.open(arq,janela,'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,menubar=no,width='+lar+',height='+alt+'')
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


	function Item(name, subItens){
		this.name = name;
		this.subItens = subItens;
	}

	function subItem(value, name){
		this.name = name;
		this.value = value;
	}

	function writeCaptionRadio(cod, nomeArray){
		var str='';
		if (nomeArray != null){
			for(i=0; i < nomeArray.length; i++){
				if (nomeArray[i].value == cod){
					str = nomeArray[i].name;
				}
			}			
		}
		return str;
	}

	function writeCaption(cod, nomelist){
		var str = '', i;
		campolist = eval('document.form.'+nomelist);
		if (campolist != null){
			for (i = 0; i < campolist.length; i++){
				if (campolist.options[i].value == cod){
					str = campolist.options[i].text;
				}
			}
		}
		return str;
	}

	


/*==========================================================*/
/* Dada uma string a fumção Trim retira espaços em branco 	*/
/* à esquerda e à direita da string													*/
/*==========================================================*/
	function trim(str){
		var firstIndex = 0;
		var lastIndex = str.length-1;
		var retorno = '';
		while (str.charAt(firstIndex) == ' '){
			firstIndex++;
		}
		while (str.charAt(lastIndex) == ' '){
			lastIndex--;
		}
		lastIndex++;
		retorno = str.substring(firstIndex,lastIndex);
		return retorno;
	}

/*================================================================================*/
/* Dado	o um campo list e um campo hidden																					*/
/* Ao clicar no	list box define	o valor	do campo hidden	do formulario de remocao	*/
/*================================================================================*/
function checa_list(campolist1, campohidden1){
	campohidden1.value = campolist1.options[campolist1.selectedIndex].value;
	return;
}

/*================================================================================*/
/* Passados um campo list e o título do campo list																*/
/* Verifica se algum item está selecionado e alerta o usuário											*/
/* Se estiver selecionado avisa	o usuario que a	operação não podera ser	desfeita	*/
/*================================================================================*/
function checa_remove(nomecampolist1, msgvazia, msgselecionado){
	campolist1 = eval('document.form_list.'+nomecampolist1);
	if (campolist1 == null){
		alert(msgvazia);
		return false;
	}
	if (campolist1.selectedIndex == -1) {
		alert(msgselecionado);
		return false;
	}
	if (!confirm("Tem certeza que deseja apagar o item selecionado?")) {
		return false;
	}
	return true;
}

/*=====================================================*/
/* Passados nome e descricao de	um campo texto				 */
/* Verifica se o campo esta vazio e alerta o usuario	 */
/*=====================================================*/
function checa_insere(campotext1, msgvazia, msgexiste, nomecampolist1){
	if ((campotext1.value == "") || (campotext1.value == " ")){
		alert(msgvazia);
		campotext1.focus();
		return false;
	}	
	campolist1 = eval('document.form_list.'+nomecampolist1);
	if (campolist1 != null){
		for (var i = 0; i < campolist1.length; i++){
			if (iguais(campotext1.value, campolist1.options[i].text)){
				alert(msgexiste);
				campotext1.value = '' ;
				campotext1.focus();
				return false;
			}
		}
	}
	return true;
}
/*========================================================================*/
/* Passados duas strings essa função campara com CaseSensitive as duas		*/
/* e o retorno é bem trivial :o)																					*/
/*========================================================================*/
function iguais(str1, str2){
	if (str1.toUpperCase() == str2.toUpperCase()){
		return true;
	}
	return false;
}

/*=======================================================================*/
/* Função cujo objetivo é trocar o valor do listbox nas paginas nas quais*/
/* existem tabelas relacionadas														 */
/*=======================================================================*/
function troca(nomecampolist1, nomecampolist2, valorcampolist2){
	var campolist1 = eval('document.form_list.'+nomecampolist1);

	if (campolist1 != null){		
		var campolist2 = eval('document.form_insere.'+nomecampolist2);
		while (campolist1.length > 0){
			campolist1.options[0] = null;
		}	
		var j = 0;

		if (valorcampolist2 == ''){
			indiceselecionado = 0;
		}else{
			for(i = 0; i < campolist2.length; i++){
				if( campolist2.options[i].value == valorcampolist2 ){
					indiceselecionado = i;
				}
			}
		}

		for(i = 0; i < Objeto[indiceselecionado].subItens.length; i++){
			if(Objeto[indiceselecionado].subItens[i].name != ''){
				temp = new Option (Objeto[indiceselecionado].subItens[i].name,Objeto[indiceselecionado].subItens[i].value);
				campolist1.options[j] = temp;
				j++;
			}else{
				campolist1.length = 0;
			}
		}

		campolist2.selectedIndex = indiceselecionado;
		var campolist2_remove = eval('document.form_remove.'+nomecampolist2);
		campolist2_remove.value = campolist2.options[campolist2.selectedIndex].value;

	}
	return;
}


// Obtencao de dados do browser do visitante
var isNav = false, isIE = false, Versao="0.00";
var browserOK = false;
var pics;
browserOK = true;
pics = new Array();
var objCount = 0; 

AppName = navigator.appName;
AppVersion = navigator.appVersion;

if ( AppName.indexOf("Netscape") != -1 ) 
{
  isNav = true;
  Versao = AppVersion.substring(0, 4);
  document.captureEvents(Event.KEYDOWN);  
}
else if ( AppName.indexOf("Microsoft") != -1 ) {
   isIE = true;
   Versao = AppVersion.substring((AppVersion.indexOf("E")+1), (AppVersion.indexOf("E")+6));
}

NUMVER = parseFloat(Versao)
if ( NUMVER >= 5) {
   Versao = "5";
} else if ( NUMVER >= 4 ) {
   Versao = "4";
} else if ( NUMVER >= 3 ) {
   Versao = "3";
} else Versao = "2";


// Funcao para saltar de um campo para o proximo automaticamente
function salta(campo_atual, event, tamanho_maximo, campo_proximo)
{
  var tecla;
  var vr;

  if (isNav)
    tecla = event.which;
  else
    tecla = event.keyCode;
  vr = campo_atual.value;
  tam = vr.length;
  if (tam >= tamanho_maximo && tecla >= 48)
    campo_proximo.focus();
}


//Verifica e-mails válidos

function check_email (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	alert("Favor inserir um e-mail válido.");
	return false;
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    alert("Favor inserir um e-mail válido.");
    return false;
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Favor inserir um e-mail válido.");
		return false;
	    }
    }
    return true;
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Favor inserir um e-mail válido.");
    return false;
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("Favor inserir um e-mail válido.");
   return false;
}

if (len<2) {
   var errStr="Favor inserir um e-mail válido.";
   alert(errStr);
   return false;
}


return true;
}

/*====================================================================*/
/* Essa função recebe uma string na forma de data e retorna 'true' ou */
/* 'false' de acordo com a validade da data.                       		*/
/*====================================================================*/
function testDate(str){
	var dia, mes, ano;
	tempArray = str.split('/');
	tempArray[0] = chopLeftZero(tempArray[0]);
	tempArray[1] = chopLeftZero(tempArray[1]);
	tempArray[2] = chopLeftZero(tempArray[2]);
	dia = parseInt(tempArray[0]);
	mes = parseInt(tempArray[1]);
	ano = parseInt(tempArray[2]);

	if (ano < 1900){return false;}
	if (mes < 1 || mes > 12){return false;}
	if (dia < 1 || dia > 31){return false;}
	if (dia > 29 && mes == 2){return false;}
	if (dia == 29 && mes == 2){
		if(ano % 4 != 0){return false;}
	}
	if (dia == 31 && mes < 8 ){
		if (mes % 2 == 0){return false;}
	}
	if (dia == 31 && mes >= 8 ){
		if (mes % 2 == 1){return false;}
	}
	return true;
}

/*==========================================================================*/
/* Dado uma string essa função diz se a mesma é uma seqüêcia numérica válida*/
/*==========================================================================*/
function isNumber(str){
	var i;
	if (str == null || str == "" || str == " "){return false;}
	for (i=0; i<str.length; i++){
		if(!isDigit(str.charAt(i))){return false;}
	}
	return true;
}

/*=======================================================*/
/* Dado uma string essa função diz se a mesma está vazia */
/*=======================================================*/
function isEmpty(str){
	if (str == null || str == "" || str == " "){return true;}
	return false;
}

/*==================================================================*/
/* Essa função diz se a data é valida ou não.												*/
/* O parâmetro 'obr' é fundamental na decisão da validação da data	*/
/*==================================================================*/
function checkDate(campohidden, titledata, campotextdia, campotextmes, campotextano, obr){
	tempDate = concatDate(campotextdia, campotextmes, campotextano);
	if (tempDate == '-1'){
		// alert('O valor da '+titledata+' está incorreto.');
		alert(titledata+' inválida.');
		campotextdia.focus();
		return false;
	}
	if (tempDate == "" && obr == 0){return true;}
	if (tempDate != "" && testDate(tempDate)){
		campohidden.value = tempDate;
		return true;
	}else{
		// alert('O valor da '+titledata+' está incorreto.');
		alert(titledata+' inválida.');
		campotextdia.focus();
		return false;
	}
}

/*=====================================================*/
/* Função que recebe uma string e retira os caracteres */
/* iniciais enquanto forem o caracter zero '0'				 */
/*=====================================================*/
function chopLeftZero(str){
	var i = 0;
	while (str.charAt(i) == 0){
		i++;
	}
	str = str.slice(i, str.length+1);
	return str;
}


/*===================================================================================*/
/* Dada uma string essa função diz se ela é constituída apenas por espaços em branco */
/*===================================================================================*/
function isBlank(str){
	for (i=0; i>str.length; i++){
		if (str.charAt(i)!= ' '){return false;}
	}
	return true;
}

/*======================================================================*/
/* Dados campos dia, mês e ano se os 3 campos possuírem valores			*/
/* numéricos válidos os valores serão concatenados na forma de data		*/
/* e retornados, do contrário uma string vazia será retornada	se todos */
/* os campos estiverem vazios.														*/
/* Se algum dos campos não for vazio e não for um numérico válido o 	 	*/
/* código de retorno é (-1). 															*/
/*======================================================================*/
function concatDate(dia, mes, ano){
	var strDate = '';
	if (isNumber(dia.value) && isNumber(mes.value) && isNumber(ano.value)){
		strDate = dia.value+'/'+mes.value+'/'+ano.value;
		return strDate;
	}		
	if (!isEmpty(dia.value) || !isEmpty(mes.value) || !isEmpty(ano.value)){
	  strDate = '-1';
 		return strDate;
	}

return strDate;

}


/*==========================================================================*/
/* Dado um caracter essa função diz se o mesmo é um dígito numérico válido	*/
/*==========================================================================*/
function isDigit(ch){
	var i;
	if (ch == null || ch == "" || ch == " "){return false;}
	for (i=0; i<=9; i++){
		if (ch == i){return true;}
	}
	return false;
}

/*==========================================================================*/
/* Checa se o CPF e valido                                                  */
/*==========================================================================*/

function check_cpf (StrCPF)
{
 x = 0;
 soma = 0;
 dig1 = 0;
 dig2 = 0;
 texto = "";
 StrCPF1="";
 len = StrCPF.length; 
 x = len -1;
  for (var i=0; i <= len - 3; i++)
  {
   y = StrCPF.substring(i,i+1);
   soma = soma + ( y * x);
   x = x - 1;
   texto = texto + y;
  }
  dig1 = 11 - (soma % 11);
  if (dig1 == 10) dig1=0 ;
  if (dig1 == 11) dig1=0 ;
  StrCPF1 = StrCPF.substring(0,len - 2) + dig1 ;
  x = 11; soma=0;
  for (var i=0; i <= len - 2; i++)
  {
   soma = soma + (StrCPF1.substring(i,i+1) * x);
   x = x - 1;
  }
  dig2= 11 - (soma % 11);
  if (dig2 == 10) dig2=0;
  if (dig2 == 11) dig2=0;
  if ((dig1 + "" + dig2) == StrCPF.substring(len,len-2))
  {
   return true;
  }
  alert ("Número do CPF inválido.");
  return false;
 }


function check_cnpj (Strcnpj)
 {
      var varFirstChr = Strcnpj.charAt(0);
      var vlMult,vlControle,s1, s2 = "";
      var i,j,vlDgito,vlSoma = 0;
	  var vaCharcnpj = false;
      for ( var i=0; i<=13; i++ ) {

        var c = Strcnpj.charAt(i);
        if( ! (c>="0")&&(c<="9") )
        {
      alert("Número do CNPJ inválido.");
      document.form.str_cnpj.focus();
      return false; }
        if( c!=varFirstChr ) { vaCharcnpj = true; }
      }
      if( ! vaCharcnpj ) {

      alert("Número do CNPJ inválido.");
      document.form.str_cnpj.focus();
      return false;
      }


      s1 = Strcnpj.substring(0,12);
      s2 = Strcnpj.substring(12,15);
      vlMult = "543298765432";
      vlControle = "";
      for ( j=1; j<3; j++ ) {

       vlSoma = 0;
       for ( i=0; i<12; i++ )
        { vlSoma += eval( s1.charAt(i) )* eval( vlMult.charAt(i) );}
         if( j == 2 ){ vlSoma += (2 * vlDgito); }
         vlDgito = ((vlSoma*10) % 11);
         if( vlDgito == 10 ){ vlDgito = 0; }
         vlControle = vlControle + vlDgito;
         vlMult = "654329876543";
      }
      if( vlControle != s2 ) {
      alert("Número do CNPJ inválido.");
      document.form.str_cnpj.focus();
      return false;
      }
      else {
      return true;
      }                          


}

function validaCPF(){
	var StrData = document.form.str_cpf.value;
	if (check_cpf(StrData) == false) {
		return false;
	}
	return true;
}

function validacnpj(){
	var StrData = document.form.str_cnpj.value;

	if (check_cnpj(StrData) == false) {
		return false;
	}
	return true;
}



	function FormataDadoCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres){
		var wTecla, wVr, wTam;	
	
		wTecla = pTeclaPres.keyCode;
		wVr = pCampo.value;
		wVr = wVr.replace( "-", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( "/", "" );
		wTam = wVr.length ;
		if (wTam < pTamMax && wTecla != 8) { 
		   wTam = wVr.length + 1 ; 
		}
	
		if (wTecla == 8 ) { 
		   wTam = wTam - 1 ; 
		}
				
		if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
			if ( wTam <= 2 ){
		 		pCampo.value = wVr ;
			}
			if (wTam > pPosTraco && wTam <= pTamMax) {
		       wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam);
			}
			if ( wTam == pTamMax){
			      wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam);
			}
			pCampo.value = wVr;
		
		}
	
	}
	
	function VerificaSoCPF(pForm, pCampo) {
		var wVr, wTam, wSoma, wSoma2, i, j, wDig1, wDig2,
		    wVETOR_CC = new Array(9),
		    wVETOR_PESO = new Array(9);
		
		wVr = pCampo.value;
		wVr = wVr.replace( ".", "" );
	    wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( "-", "" );
		wTam = wVr.length + 1;
	
		if (wVr == ''){
		  return false;
		} 
	    if (wTam < 11) {
		  alert("Nº de dígitos do CPF menor que o normal. Redigite !!!");
		  pCampo.value = "";
		  pCampo.focus();
		  return false;
		}
	    
		for (i = 0; i < wVr.length; i++) {
		   if (isNaN(parseInt(wVr.charAt(i))) ) {
	  	     alert("O CPF contém dígitos inválidos. Corrija-o !!!");
		     pCampo.value = "";
		     pCampo.focus();
		     return false;
		   }
		}
		
		if (wVr == '00000000000' || wVr == '11111111111' || wVr == '22222222222' || wVr == '33333333333' || wVr == '44444444444' || wVr == '55555555555' || 
		    wVr == '66666666666' || wVr == '77777777777' || wVr == '88888888888' || wVr == '99999999999') {
	  	     alert("Este Tipo de CPF é Inválido! Redigite-o !!!");
		     pCampo.value = "";
		     pCampo.focus();
		     return false;
		}
	  wSoma = 0;
		wSoma2 = 0;
	    j = 2;
	    for (i = 0; i < 11; i++) {
		   wVETOR_CC[i] = wVr.charAt(i);
		   wVETOR_PESO[i] = j;
		   j++; 
		} 
	    i = 0;	  
	    while (i < 9)  {
		   i++;
		   if (i < 10) {
	          wSoma += wVETOR_CC[9 - i] * wVETOR_PESO[i - 1]; }
		   wSoma2 += wVETOR_CC[10 - i] * wVETOR_PESO[i - 1];
		}
		wDig1 = (wSoma * 10) % 11;
		wDig2 = (wSoma2 * 10) % 11;
		if (wDig1 == 10) { 
		    wDig1 = 0;
		}	
		if (wDig2 == 10) { 
		    wDig2 = 0;
		}		
	    if (parseInt(wVr.charAt(9)) != wDig1 || parseInt(wVr.charAt(10)) != wDig2) {
	  	     alert("CPF com Dígito Verificador inválido. Redigite-o !!!");
		     pCampo.value = "";
		     pCampo.focus();
		     return false;
	    }	
		return true;
	}


	//onKeyDown="FormataDadoCGC(form,this,event)"
	function FormataDadoCGC(pForm,pCampo,pTeclaPres){
		var wTecla, wVr, wTam;	
	
		wTecla = pTeclaPres.keyCode;
		wVr = pCampo.value;
		wVr = wVr.replace( "-", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( ".", "" );
		wVr = wVr.replace( "/", "" );
		wTam = wVr.length ;
	
		if (wTam < 14 && wTecla != 8) { 
		   wTam = wVr.length + 1 ; 
		}
	
		if (wTecla == 8 ) { 
		   wTam = wTam - 1 ; 
		}
				
		if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
			if ( wTam <= 2 ){
		 		pCampo.value = wVr ;
			}
			if (wTam > 2 && wTam <= 14) {
			   wVr = wVr.substr(0, wTam - 2) + '-' + wVr.substr(wTam - 2, wTam);
			}
			if ( wTam == 14){
		       wVr = wVr.substr( 0, wTam - 12 ) + '.' + wVr.substr(wTam - 12, 3) + '.' + wVr.substr(wTam - 9, 3) + "/" + wVr.substr(wTam - 6, wTam);
			}
			pCampo.value = wVr;
		
		}
	
	}
	
	//onBlur="dvCGC(form, this);"
	function dvCGC(pForm, pCampo)
	{ 
	var Numero = pCampo.value.substr(0, 15); 
	var Digito = pCampo.value.substr(16, 2);
	var CNPJ = pCampo.value
	
	Numero = Numero.replace(".","");
	Numero = Numero.replace(".","");
	Numero = Numero.replace("/","");
	Numero = Numero.replace("-","");
	
	CNPJ = CNPJ.replace(".","");
	CNPJ = CNPJ.replace(".","");
	CNPJ = CNPJ.replace("/","");
	CNPJ = CNPJ.replace("-","");
	
	var CGC = Numero;
	var peso1 = '543298765432';
	var peso2 = '654329876543';
	var soma1 = 0;
	var soma2 = 0;
	var digito1 = 0;
	var digito2 = 0;
	
		 if (CNPJ == '00000000000000'){
		 	alert("CNPJ Inválido. Redigite!");
				pCampo.value = "";
		  	pCampo.focus();
		  	return false;
		 } 
		 
		 if ((Numero.length + Digito.length + 1 > 1) && (Numero.length + Digito.length + 1 < 15)) 
		 {
		  alert("Nº de dígitos do CNPJ menor que o normal. Redigite !!!");
		  pCampo.value = "";
		  pCampo.focus();
		  return false;
		 }	
	 
	 	if (Numero.length + Digito.length + 1 > 1){
	 		 
			 for (i = 1; i < 12 - Numero.length + 1; i++) 
			 {
			  CGC = eval("'" + 0 + CGC + "'")
			 }
			    
			 for (i = 1; i < CGC.length+1; i++) 
			 {
			  soma1 += CGC.substring(i, i-1) * peso1.substring(i, i-1);
			 } 
			
			 soma1 %= 11;
			
			 if (soma1  < 2) 
			 {
			  digito1 = 0;
			 }
			 else 
			 {
			  digito1 = 11 - soma1; 
			 }
			
			 for (i = 1; i < CGC.length+1; i++) 
			 {
			  soma2 += CGC.substring(i, i-1) * peso2.substring(i, i-1);
			 } 
			 
			 soma2 += digito1 * 2 
			 soma2 %= 11;
			
			 if (soma2  < 2) 
			 {
			  digito2 = 0;
			 }
			 else 
			 {
			  digito2 = 11 - soma2; 
			 }
			
			 if (eval("'" + digito1 + digito2 + "'") != Digito)
			 {
			  alert("CNPJ inválido. Redigite !!!");
			  pCampo.value = "";
			  pCampo.focus();
			  return false;
			 }
			 else 
			 {
			  return true;
			 }
		}
	}



