///////////////////////////////////////////////////////////////////////////////////////////////
// Validação de campos
///////////////////////////////////////////////////////////////////////////////////////////////
	// valida o contato simples: default.php - Site
	function valida_contato(){
		with(document.form1) {
			if (Nome.value == ""){
				alert("Informe o seu nome!")
				Nome.focus();
				return false;
			}
			if (Fone.value == "" && Email.value == ""){
				alert("Informe um e-mail ou um telefone!")
				Email.focus();
				return false;
			}
			if (Mensagem.value == ""){
				alert("Informe a sua mensagem!")
				Mensagem.focus();
				return false;
			}
		}
	}
	
	// valida a enquete: default.php - Site
	function valida_form2(cmd){
		if (cmd == 1){
			var marcado = -1
			for (i=0; i<respostaE2.length; i++) {
				if (respostaE2[i].checked) {
					marcado = i
					var idRespostas = respostaE2[i].value;
				}
			}
			if (marcado == -1) {
				alert("Escolha ao menos uma resposta.");
				respostaE2[0].focus();
			} else {
				window.open('../php/externos/resEnquete.php?comando=703&idRespostas='+idRespostas,'resEnquete','status=0,menubar=0,resizable=0,toolbars=0,scrollbars=auto,left=0,top=0,width=100,height=100');
			}
		} else {
			window.open('../php/externos/resEnquete.php?comando=704','resEnquete','status=0,menubar=0,resizable=0,toolbars=0,scrollbars=auto,left=0,top=0,width=100,height=100');
		}
	}
	
	// valida o formulário de pedido on-line: default.php - Site
	function valida_livro(){
		with(document.form1) {
			if (Nome.value == ""){
				alert("Informe o seu nome!")
				Nome.focus();
				return false;
			}
			if (Email.value == ""){
				alert("Informe o seu e-mail!")
				Email.focus();
				return false;
			}
			if (DtaAniversario.value == ""){
				alert("Informe a sua data de aniversário!")
				DtaAniversario.focus();
				return false;
			}
		}
	}
	
	// valida o contato simples: default.php - Admin
	function valida_login(){
		with(document.mainForm) {
			if (Login.value == ""){
				alert("Informe o login!")
				Login.focus();
				return false;
			}
			if (Senha.value == ""){
				alert("Informe a senha!")
				Senha.focus();
				return false;
			}
		}
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Abertura de janelas
/////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre a janela de download - Site - php/index.php
	function start_download(idMP3){
		var start_d = window.open('04_download.php?idMP3='+idMP3,'start_download','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=400,height=400');
	}
	
	// 03 - Esta função abre uma nova galeria de imagens - Site - php/index.php
	function galeria_fotos(idG){
		if (idG != 0){
			var URL = "?strPage=17&idGaleria="+idG;
			document.location.href = URL;
		} else {
			alert("Escolha uma galeria!");
		}
	}
	
	// 04 - Esta função abre a janela das fotos - Site - php/index.php
	function detalhes_foto(idF){
		var detalhes_f = window.open('detalhes_foto/?comando=700&idFotos='+idF,'detalhes_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
// Notícias //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre a janela das fotos - Site - php/index.php
	function detalhes_noticia(idN){
		if (idN > 0){
			var URL = "?strPage=50&idNoticias="+idN;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão da notícia - Site - php/index.php
	function detalhes_noticia_imp(id){
		if (id > 0){
			var detalhes_ni = window.open('externos/detalhes_noticia_imp.php?comando=700&idNoticias='+id,'detalhes_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
	// 03 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function ampliar_foto(idF){
		var detalhes_f = window.open('externos/ampliar_foto.php?comando=700&idFotos='+idF,'ampliar_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
// Entrevistas //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre os detalhes - Site - php/index.php
	function detalhes_entrevista(id){
		if (id > 0){
			var URL = "?strPage=52&idEntrevista="+id;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão - Site - php/index.php
	function detalhes_entrevista_imp(id){
		if (id > 0){
			var detalhes_imp = window.open('externos/detalhes_entrevista_imp.php?comando=700&idEntrevista='+id,'detalhes_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
	// 03 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function ampliar_foto_ent(id){
		var detalhes_f = window.open('externos/ampliar_foto_ent.php?comando=700&idFotos='+id,'ampliar_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
// Campo Grande //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre os detalhes - Site - php/index.php
	function detalhes_cg(id){
		if (id > 0){
			var URL = "?strPage=53&idCG="+id;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão - Site - php/index.php
	function detalhes_cg_imp(id){
		if (id > 0){
			var detalhes_imp = window.open('externos/detalhes_cg_imp.php?comando=700&idCG='+id,'detalhes_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
	// 03 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function ampliar_foto_cg(id){
		var detalhes_f = window.open('externos/ampliar_foto_cg.php?comando=700&idFotos='+id,'ampliar_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
// Municípios //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre os detalhes - Site - php/index.php
	function detalhes_mun(id){
		if (id > 0){
			var URL = "?strPage=54&idMunicipios="+id;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão - Site - php/index.php
	function detalhes_mun_imp(id){
		if (id > 0){
			var detalhes_imp = window.open('externos/detalhes_mun_imp.php?comando=700&idMunicipios='+id,'detalhes_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
	// 03 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function ampliar_foto_mun(id){
		var detalhes_f = window.open('externos/ampliar_foto_mun.php?comando=700&idFotos='+id,'ampliar_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
	// 04 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function municipios_achar(n){
		if (n > 0){
			var URL = "?strPage=4&NroCidade="+n;
			document.location.href = URL;
		}
	}
	
// Assembléia //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre os detalhes - Site - php/index.php
	function detalhes_ass(id){
		if (id > 0){
			var URL = "?strPage=55&idAssembleia="+id;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão - Site - php/index.php
	function detalhes_ass_imp(id){
		if (id > 0){
			var detalhes_imp = window.open('externos/detalhes_ass_imp.php?comando=700&idAssembleia='+id,'detalhes_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
	// 03 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function ampliar_foto_ass(id){
		var detalhes_f = window.open('externos/ampliar_foto_ass.php?comando=700&idFotos='+id,'ampliar_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
// Pronunciamentos //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função abre os detalhes - Site - php/index.php
	function detalhes_pron(id){
		if (id > 0){
			var URL = "?strPage=56&idPronunciamentos="+id;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão - Site - php/index.php
	function detalhes_pron_imp(id){
		if (id > 0){
			var detalhes_imp = window.open('externos/detalhes_pron_imp.php?comando=700&idPronunciamentos='+id,'detalhes_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
	// 03 - Esta função abre a janela de ampliação das fotos - Site - php/index.php
	function ampliar_foto_pron(id){
		var detalhes_f = window.open('externos/ampliar_foto_pron.php?comando=700&idFotos='+id,'ampliar_foto','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
	}
	
// Projetos/Leis //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função exibe os detalhes dos projetos/leis - Site - php/index.php
	function efetuar_busca(string){
		if (string != ""){
			var URL = "?strPage=70&strBusca="+string;
			document.location.href = URL;
		}
	}
	
// Projetos/Leis //////////////////////////////////////////////////////////////////////////
	
	// 01 - Esta função exibe os detalhes dos projetos/leis - Site - php/index.php
	function detalhes_projetos_leis(idP){
		if (idP > 0){
			var URL = "?strPage=51&idProjetos="+idP;
			document.location.href = URL;
		}
	}
	
	// 02 - Esta função abre a janela de impressão da projetos/lei - Site - php/index.php
	function detalhes_projetos_leis_imp(idP){
		if (idP > 0){
			var detalhes_pli = window.open('externos/detalhes_projetos_leis_imp.php?comando=700&idProjetos='+idP,'detalhes_projetos_leis_imp','resizable=1,status=0,menubar=0,toolbars=0,scrollbars=1,left=0,top=0,width=100,height=100');
		}
	}
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////  Funções gerais
/////////////////////////////////////////////////////////////////////////////////////////////////////////

	// Este é um round personalizado - pedidos - Site e Admin - comandos.js
	function roundP(num){
		var num = ""+num+"";
		var cd = num.indexOf(".");
		if (cd == "") {
			cd = num.indexOf(",");
			if (cd == "") {
				return num;
			} else {
				num = num.substring(0,cd);
				return num;
			}
		} else {
			num = num.substring(0,cd);
			return num;
		}
	}
	
	/// Calcular DV dos protocolos - pedidos - Site e Admin - comandos.js
	function DV(numx){
		var cDV = (numx - (9 * (roundP(numx/9))));
		var nDV = numx+""+cDV;
		return nDV;
	}
	
	/// Esta função testa o DV dos protocolos
	function tDV(prot) {
		var prot = ""+prot+"";
		if (prot.length > 8) {return false;}
		var nDV = prot.substr(0,7);
		var cDVp = prot.substr(7,1);
		var cDVc = (nDV - (9 * (roundP(nDV/9))));
		if (cDVp == cDVc){
			return true;
		} else {
			return false;
		}
	}
	
	/// Esta função limpa números de caracteres indesejados
	function limparStr(st){
		var str = st;
		str = str.replace (".","");
		str = str.replace (".","");
		str = str.replace (".","");
		str = str.replace ("-","");
		str = str.replace ("-","");
		str = str.replace ("/","");
		str = str.replace ("/","");
		return str;
	}
	
	/// ESTAS FUNÇÕES HABILITAM CNPJ OU CPF - Site - php/index.php
	function vC1(x){
		if (x.Cpf.value != ""){
			x.Cnpj.disabled = true;
			x.Cnpj.className="caixa_texto4";
			NmeRazao.innerText = "Nome:";
			link2.innerHTML = "";
			x.FantasiaEstab.disabled = true;
			x.FantasiaEstab.className="caixa_texto4";
		} else {
			x.Cnpj.disabled = false;
			x.Cnpj.className="caixa_texto1";
			NmeRazao.innerText = "Nome/Razão social:";
			link2.innerHTML = "<a href='javascript:recuperar_cnpj(document.mainForm.Cnpj.value)' class='menor_preto' onMouseOut=\"this.className='menor_preto'\" onMouseOver=\"this.className='menor_cinza'\">recuperar</a>";
			x.FantasiaEstab.disabled = false;
			x.FantasiaEstab.className="caixa_texto1";
			x.Cnpj.value = ""; x.NmeRazao.value = ""; x.FantasiaEstab.value = ""; x.NmeContato.value = ""; x.TelFixo.value = ""; 
			x.TelCel.value = ""; x.CLogradouro.value = ""; x.CNum.value = ""; x.CComp.value = ""; x.CBairroDist.value = ""; 
			x.CCep.value = ""; x.CCP.value = ""; x.CPontoRef.value = ""; x.CCidade.value = ""; x.CUF.value = "";
			x.ELogradouro.value = ""; x.ENum.value = ""; x.EComp.value = ""; x.EBairroDist.value = ""; x.ECep.value = ""; 
			x.ECP.value = ""; x.EPontoRef.value = ""; x.ECidade.value = ""; x.EUF.value = "";
		}
	}
	
	function vC2(x){
		if (x.Cnpj.value != ""){
			x.Cpf.disabled = true;
			x.Cpf.className="caixa_texto4";
			NmeRazao.innerText = "Razão social:";
			link1.innerHTML = "";
		} else {
			x.Cpf.disabled = false;
			x.Cpf.className="caixa_texto1";
			NmeRazao.innerText = "Nome/Razão social:";
			link1.innerHTML = "<a href='javascript:recuperar_cpf(document.mainForm.Cpf.value)' class='menor_preto' onMouseOut=\"this.className='menor_preto'\" onMouseOver=\"this.className='menor_cinza'\">recuperar</a>";
			x.Cpf.value = ""; x.NmeRazao.value = ""; x.FantasiaEstab.value = ""; x.NmeContato.value = ""; x.TelFixo.value = ""; 
			x.TelCel.value = ""; x.CLogradouro.value = ""; x.CNum.value = ""; x.CComp.value = ""; x.CBairroDist.value = ""; 
			x.CCep.value = ""; x.CCP.value = ""; x.CPontoRef.value = ""; x.CCidade.value = ""; x.CUF.value = "";
			x.ELogradouro.value = ""; x.ENum.value = ""; x.EComp.value = ""; x.EBairroDist.value = ""; x.ECep.value = ""; 
			x.ECP.value = ""; x.EPontoRef.value = ""; x.ECidade.value = ""; x.EUF.value = "";
		}
	}
	
	/// FUNÇÕES DE ESTILO - Site
    function move_i(what) { what.style.background='#648EBA'; }
    function move_o(what) { what.style.background='#AEC4DB'; }
	
	/// A FUNÇÃO ABAIXO APLICA MÁSCARA EM UM CAMPO - Site e Admin
	function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
		//alert(objForm.UmidadeMax.value);
		 var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
		if(document.all) { // Internet Explorer
			nTecla = evtKeyPress.keyCode;
		} else if(document.layers) { // Nestcape
			nTecla = evtKeyPress.which;
		}
		
		sValue = objForm[strField].value;

		// Limpa todos os caracteres de formatação que já estiverem no campo.
		sValue = sValue.toString().replace( ":", "" );
		sValue = sValue.toString().replace( ":", "" );
		sValue = sValue.toString().replace( "-", "" );
		sValue = sValue.toString().replace( "-", "" );
		sValue = sValue.toString().replace( ".", "" );
		sValue = sValue.toString().replace( ".", "" );
		sValue = sValue.toString().replace( "/", "" );
		sValue = sValue.toString().replace( "/", "" );
		sValue = sValue.toString().replace( "(", "" );
		sValue = sValue.toString().replace( "(", "" );
		sValue = sValue.toString().replace( ")", "" );
		sValue = sValue.toString().replace( ")", "" );
		sValue = sValue.toString().replace( " ", "" );
		sValue = sValue.toString().replace( " ", "" );
		sValue = sValue.toString().replace( ",", "" );
		sValue = sValue.toString().replace( ",", "" );
		sValue = sValue.toString().replace( ",", "" );
		fldLen = sValue.length;
		mskLen = sMask.length;
		
		i = 0;
		nCount = 0;
		sCod = "";
		mskLen = fldLen;

		while (i <= mskLen) {
			bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
			bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ") || (sMask.charAt(i) == ","))
			if (bolMask) {
				sCod += sMask.charAt(i);
				mskLen++; 
			} else {
				sCod += sValue.charAt(nCount);
				nCount++;
			}
			i++;
		}

		objForm[strField].value = sCod;

		if (nTecla != 8) { // backspace
			if (sMask.charAt(i-1) == "9") { // apenas números...
				return ((nTecla > 47) && (nTecla < 58)); // números de 0 a 9
			} else { // qualquer caracter...
				return true;
			}
		} else {
			return true;
		}
	}
	
	/// A FUNÇÃO ABAIXO FAZ A VERIFICAÇÃO NUMÉRICA - Site e Admin
	function VerificarNum(obj,event){
		var Tecla = event.which;
		if(Tecla == null) Tecla = event.keyCode;
		if ( Tecla < 48 || Tecla > 59 ){
			event.returnValue = false;
			//alert("Só devem ser digitados números!")
			return false;
		}
		event.returnValue = true;
		return true;
	}
	
	/// A FUNÇÃO ABAIXO FAZ A VERIFICAÇÃO DE DATA - Site e Admin
	function VerificarData(dt,campo,anoV){
		if (dt != "") {
			// verificar tamanho do campo
			tm = dt.length;
			var contE = 0;
			if (tm != 10) contE++;
			// verificar barras
			if (dt.substring(0,1) == "/") contE++;
			var n = 0;
			var contB = 0;
			while (n < 10){
				b = dt.substring(n,n+1);
				if (b == "/") contB++;
				n++;
			}
			if (contB != 2) contE++;
			// posição das barras
			pB = dt.indexOf("/",0);
			sB = dt.indexOf("/",pB+1);
			// coleta do dia, mês e ano
			var dia = dt.substring(0,pB);
			var mes = dt.substring(pB+1,sB);
			var ano = dt.substring(sB+1,dt.length);
			// verificar regras para dia, mês e ano
			if (dia > 31) contE++;
			if (mes > 12) contE++;
			//if (ano > anoV+2 || ano < anoV) contE++;
			// verificar se aconteceu algum erro
			if (contE > 0) {
				alert("Data inválida");
				campo.value = "";
				campo.focus();
			}
		}
	}
	
	/// A FUNÇÃO ABAIXO FAZ A VERIFICAÇÃO DE DATA EM CAMPOS DE PROMPT - Site e Admin
	function VerificarDataPrompt(dt){
		// verificar tamanho do campo
		if (isNaN(dt)){contE++;}
		tm = dt.length;
		var contE = 0;
		if (tm != 10) contE++;
		// verificar barras
		if (dt.substring(0,1) == "/") contE++;
		var n = 0;
		var contB = 0;
		while (n < 10){
			b = dt.substring(n,n+1);
			if (b == "/") contB++;
			n++;
		}
		if (contB != 2) contE++;
		// posição das barras
		pB = dt.indexOf("/",0);
		sB = dt.indexOf("/",pB+1);
		// coleta do dia, mês e ano
		var dia = dt.substring(0,pB);
		var mes = dt.substring(pB+1,sB);
		var ano = dt.substring(sB+1,dt.length);
		// verificar regras para dia, mês e ano
		if (dia > 31) contE++;
		if (mes > 12) contE++;
		//if (ano > anoV+2 || ano < anoV) contE++;
		// verificar se aconteceu algum erro
		var beleza = 1;
		var podre = 0;
		if (contE > 0) {
			return podre;
		} else {
			return beleza;
		}
	}
	
	/// A FUNÇÃO ABAIXO VERIFICA E-MAIL - Site e Admin
	function VerificarEmail(em,campo){
		if (em != "" && em != "---"){
			var contE = 0;
			// verificar quantidade mínima de caracteres
			if (em.length < 8) {contE++};
			var varEmail, pos, dominio, pos2, extensao, carac, i;
			varEmail = em.toLowerCase();
			pos = varEmail.indexOf("@",0);
			dominio = varEmail.substring(pos+1);
			pos2 = dominio.indexOf(".",0);
			extensao = dominio.substr(pos2+1);
			// verificar se tem arroba @
			if ((varEmail.indexOf("@",0) == -1)) {contE++};
			// verificar se o dominio tem extensão
			if ((dominio.indexOf(".",0) < 2)) {contE++};
			// verificar a extensão
			if (extensao.length < 2) {contE++};
			// verificar caracteres especiais
			carac = new Array("!","#","$","%","&","*","(",")","+","=","/","\\","|","?","'","\"","{","}","[","]","ª","º",":",",",";","§","°","<",">");
			for(i=0; i<carac.length; i++) {
				if (varEmail.indexOf(carac[i],0) != -1) {contE++};
			}
			if (contE > 0) {
				alert("E-mail inválido");
				campo.select();
			}
		}
	}
	
	/// A FUNÇÃO ABAIXO TIRA ASPAS E APÓSTROFES - Site e Admin
	function tiraAA(text,campo){
		if (text != ""){
			sValue = text;
			var n = 0;
			while (n < 30) {
				sValue = sValue.toString().replace( "'", "" );
				sValue = sValue.toString().replace( "\"", "" );
				//sValue = sValue.toString().replace( "-", "" );
				sValue = sValue.toString().replace( "--", "" );
				n++;
			}
			campo.value = sValue;
			//campo.select();
		}
	}
	
	/// A FUNÇÃO ABAIXO SÓ PERMITE NÚMEROS - Site e Admin
	function soNum(num,campo){
		if (isNaN(num)){
			alert("Número inválido!");
			campo.value = "";
			campo.focus();
		}
	}
	
	/// A FUNÇÃO ABAIXO VERIFICA TEXTO - Site e Admin
	function VerificarTexto(obj,event){
		var Tecla = event.which;
		if(Tecla == null) Tecla = event.keyCode;
		if (Tecla >= 48 && Tecla <= 60){
			event.returnValue = false;
			//alert("Só devem ser digitados textos!")
			return false;
		}
		event.returnValue = true;
		return true;
	}
	
	/// A FUNÇÃO ABAIXO FAZ O FOCO PASSAR PARA O CAMPO VIZINHO - Site e Admin
	VerifiqueTAB=true;
	function Mostra(quem, tammax) {
		//var shiftK = window.event.shiftKey
		//alert(event.keyCode);
		if ((event.keyCode == 9) || (event.keyCode == 16)){
			VerifiqueTAB = false;
		} else {
			VerifiqueTAB = true;
		}
		
		// Se o tamanho do conteúdo do campo é igual ao tamanho máximo e a tabulação é verdadeira (sempre será)
		if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
			// Vamos descobrir qual é o id do formulário em questão ...
			var i=0, j=0, indice=-1;
			for (i=0; i < document.forms.length; i++) {
				for (j=0; j < document.forms[i].elements.length; j++) {
					if (document.forms[i].elements[j].name == quem.name) {
						indice=i;
						break;
					}
				}
				if (indice != -1)
					 break;
			}
			// ... para acharmos o id do campo atual e do próximo
			for (i=0; i <= document.forms[indice].elements.length; i++) {
				if (document.forms[indice].elements[i].name == quem.name) {
					// Vamos tomar a precaussão de passar o foco para um campo que não esteja oculto e muito menos desabilitado
					while ( ((document.forms[indice].elements[(i+1)].type == "hidden") && (i < document.forms[indice].elements.length)) || ((document.forms[indice].elements[(i+1)].disabled == true) && (i < document.forms[indice].elements.length)) ) {
						i++;
					}
					document.forms[indice].elements[(i+1)].focus();
					VerifiqueTAB=false;
					break;
				}
			}
		}
	}
	
	/// Esta função valida CPF
	function validaCPF(cpf,campo,form) {
		if (cpf != "") {
			// Vamos limpar a string e deixar apenas números
			var n = 0;
			while (n < 5) {
				cpf = cpf.toString().replace( ".", "" );
				cpf = cpf.toString().replace( "-", "" );
				n++;
			}
			erro = new String;
			erro = "Erros encontrados:\n";
			if (cpf.length < 11) erro += "- Sao necessarios 11 digitos para verificacao do CPF! \n"; 
			var nonNumbers = /\D/;
			if (nonNumbers.test(cpf)) erro += "- A verificacao de CPF suporta apenas numeros! \n\n"; 
			if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
				erro += "- Numero de CPF inválido!"
			}
			var a = []; // declaração do array
			var b = new Number; // declração de variável numérica
			var c = 11;
			// vamos achar o primeiro dv
			for (i=0; i<11; i++){
				a[i] = cpf.charAt(i); // captura todos os 11 números do 0 ... 10
				if (i < 9) b += (a[i] * --c); // b recebe a soma nos números multiplicando-os por 10, 9, 8 ...
			}
			if ((x = b % 11) < 2) {
				a[9] = 0; 
			} else {
				a[9] = 11-x ;
			}
			// vamos achar o segundo dv
			b = 0; c = 11;
			for (y=0; y<10; y++) {
				b += (a[y] * c--); // b recebe a soma nos números multiplicando-os por 11, 10, 9 ...
			}
			if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
			if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
				erro +="- Digito verificador com problema!";
			}
			if (erro.length > 20){
				alert(erro);
				campo.value = "";
				vC1(form);
				campo.focus();
			}
		}
	}
	
	/// A FUNÇÃO ABAIXO VALIDA UM CNPJ
	function validaCNPJ(cnpj,campo,form) {
		if (cnpj != "") {
			erro = new String;
			erro = "Erros encontrados:\n";
			if (cnpj.length < 18) erro += "- É necessario preencher corretamente o número do CNPJ! \n"; 
			if ((cnpj.charAt(2) != ".") || (cnpj.charAt(6) != ".") || (cnpj.charAt(10) != "/") || (cnpj.charAt(15) != "-")){
				erro += "- É necessário preencher corretamente o número do CNPJ! \n";
			}
			// Vamos substituir os caracteres que não são números
			if(document.layers && parseInt(navigator.appVersion) == 4){
				x = cnpj.substring(0,2);
				x += cnpj. substring (3,6);
				x += cnpj. substring (7,10);
				x += cnpj. substring (11,15);
				x += cnpj. substring (16,18);
				cnpj = x; 
			} else {
				cnpj = cnpj.replace (".","");
				cnpj = cnpj.replace (".","");
				cnpj = cnpj.replace ("-","");
				cnpj = cnpj.replace ("/","");
			}
			var nonNumbers = /\D/;
			if (nonNumbers.test(cnpj)) erro += "- O CNPJ suporta apenas números! \n"; 
			var a = [];
			var b = new Number;
			var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
			for (i=0; i<12; i++){
				a[i] = cnpj.charAt(i);
				b += a[i] * c[i+1];
			}
			if ((x = b % 11) < 2) {
				a[12] = 0;
			} else {
				a[12] = 11-x;
			}
			b = 0;
			for (y=0; y<13; y++) {
				b += (a[y] * c[y]); 
			}
			if ((x = b % 11) < 2) {
				a[13] = 0; 
			} else {
				a[13] = 11-x;
			}
			if ((cnpj.charAt(12) != a[12]) || (cnpj.charAt(13) != a[13])){
				erro +="- Dígito verificador do CNPJ com problema!";
			}
			if (erro.length > 20){
				alert(erro);
				campo.value = "";
				vC2(form);
				campo.focus();
			}
		}
	}	
	   
	/// A FUNÇÃO ABAIXO FORMATA UM NÚMERO EM MOEDA - Site e Admin
	function VerifVlr(vlr,event,campo){
		// capturar eventos e valores
		var Tecla = event.which;
		if(Tecla == null) Tecla = event.keyCode;
		var sValue = vlr;
		// limpar o valor das vírgulas
		sValue = sValue.toString().replace( ",", "" );
		sValue = sValue.toString().replace( ".", "" );
		// verificar se foram digitados apenas numeros
		if (sValue.length > 2 && sValue.length < 6){
			var int = sValue.substring(0,(sValue.length-2));
			var dec = sValue.substring((sValue.length-2),(sValue.length));
			campo.value = int+","+dec;
		}
		if (sValue.length >= 6){
			var xxx = sValue.substring(0,(sValue.length-2));
			var mil = xxx.substring(0,(xxx.length-3));
			var cnt = xxx.substring((xxx.length-3),(xxx.length));
			var dec = sValue.substring((sValue.length-2),(sValue.length));
			campo.value = mil+"."+cnt+","+dec;
		}
	}

	///////// A FUNÇÃO ABAIXO FAZ A VERIFICAÇÃO DE HORAS E MINUTOS
	function VerificarHM(hm,campo){
		if (hm != "") {
			// verificar tamanho do campo
			tm = hm.length;
			var contE = 0;
			if (tm != 5) contE++;
			// verificar dois pontos
			h = hm.split(':')[0].toString();
			m = hm.split(':')[1].toString();
			// verificar regras para dia, mês e ano
			if (h > 24) contE++;
			if (m > 59) contE++;
			// verificar se aconteceu algum erro
			if (contE > 0) {
				alert("Horário inválido!");
				campo.value = "";
				campo.focus();
			}
		}
	}
