function gera_ajax(){
try{ ajax=new XMLHttpRequest(); }
catch(ee){
    try{ ajax=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e){
        try{ ajax=new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(E){ ajax=false;}}} return ajax; }

function trim(str){return str.replace(/^\s+|\s+$/g,"");}

function numeros(e){
		if(window.event){
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode; }
		else if(e.which){
		// netscape
		key = e.which;}
		
		//if (key!=44 ||key!=46 ||key!=8 || key < 48 || key > 57) return (((key > 47) && (key < 58)) || (key==8) || (key==46) || (key==44));
		if (key!=46 ||key!=8 || key < 48 || key > 57) return (((key > 47) && (key < 58)) || (key==8) || (key==46));
		{
		return true; }
}

//################################### FUNCAO CONTRA LETRAS #########################################################
function teste(e){
	if(window.event){
	// for IE, e.keyCode or window.event.keyCode can be used
	key = e.keyCode; }
	else if(e.which){
	// netscape
	key = e.which;}
						
	if (key!=8 || key < 48 || key > 57) return (((key > 47) && (key < 58)) || (key==8));
	{
	return true; }
	}
//################################### FIM FUNCAO CONTRA LETRAS #########################################################


//if (window != top) top.location.href = location.href;

//function click() {
//if (event.button==2) { alert('ACISJC 2008.'); }
//}
//document.onmousedown=click;



function checa_login(login){
		n=Math.random();
		var ajax=gera_ajax();
		ajax.open("GET","cursos_query.php?operacao=2&login="+login+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ 
				retorno=unescape(ajax.responseText);
				if(retorno==1){ document.getElementById('txtl').style.backgroundColor='B8F5B1'; document.frm_cursos.ok_cursos.value="1"; }
				if(retorno==0){ document.getElementById('txtl').style.backgroundColor='FF9F9F'; document.frm_cursos.ok_cursos.value="0"; } }
			else{}}
		ajax.send(null); }
    
	
function valida_cursos(){
	if(document.frm_cursos.txtcnpj.value==""){ alert('Digite o CPF.'); return false; }
	if(document.frm_cursos.txtnome.value==""){ alert('Digite o Nome.'); return false; }
	if(document.frm_cursos.txtendereco.value==""){ alert('Digite o endereço.'); return false; }
	if(document.frm_cursos.txtbairro.value==""){ alert('Digite o bairro.'); return false; }
	if(document.frm_cursos.txtcidade.value==""){ alert('Digite a cidade.'); return false; }
	if(document.frm_cursos.cboestados.value==""){ alert('Escolha um estado.'); return false; }
	if(document.frm_cursos.txtl.value==""){ alert('Informe o login.'); return false; }
	if(document.frm_cursos.txts.value==""){ alert('Informe a senha.'); return false; }
	if(document.frm_cursos.txtscs.value==""){ alert('Informe confirme a senha.'); return false; }
	if(document.frm_cursos.txts.value!=document.frm_cursos.txtscs.value){ alert('As senhas digitadas não são as mesmas.'); return false; }
	if(document.frm_cursos.ok_cursos.value=="0"){ alert("Atenção! O login informado já está sendo utilizado."); return false; }
return true;	}

function valida_cadastro(){
	if(document.frm_cadastro.txtcodigo.value==""){ alert('Digite o código.'); return false; }
	if(document.frm_cadastro.txtrazao.value==""){ alert('Digite a Razão Social.'); return false; }
	if(document.frm_cadastro.txtnome.value==""){ alert('Digite o Nome Fantasia.'); return false; }
	if(document.frm_cadastro.txtendereco.value==""){ alert('Digite o endereço.'); return false; }
	if(document.frm_cadastro.txtbairro.value==""){ alert('Digite o bairro.'); return false; }
	if(document.frm_cadastro.txtcidade.value==""){ alert('Digite a cidade.'); return false; }
	if(document.frm_cadastro.cboestados.value==""){ alert('Escolha um estado.'); return false; }
return true;
}

function cor(i,caixa){ if(i=="1"){ document.getElementById(caixa).style.backgroundColor='#C0C0C0'; }
else{ document.getElementById(caixa).style.backgroundColor='#FFFFFF'; } }

function valida_login_cursos(){
	a=1;
	if(document.getElementById("txtlogin").value==""){ alert("Informe seu login!"); a=0; return false;}
	if(document.getElementById("txts").value==""){ alert("Informe sua senha!"); a=0; return false;}
	if(a==1){ login_cursos(document.getElementById("txtlogin").value,document.getElementById("txts").value); }
	}

function valida_senha_cursos(){
	a=1;
	if(document.getElementById("txtlogin").value==""){ alert("Informe seu login!"); a=0; return false;}
	if(document.getElementById("txtemail").value==""){ alert("Informe seu email!"); a=0; return false;}
	if(a==1){ senha_cursos(document.getElementById("txtlogin").value,document.getElementById("txtemail").value); }
	}


function controle_downs(socio,pesquisa){
		n=Math.random();
		var ajax=gera_ajax();
		ajax.open("GET","pesquisas_down.php?socio="+socio+"&pesquisa="+pesquisa+"&n="+n,true);
		ajax.onreadystatechange=function(){ if(ajax.readyState==4 && ajax.status==200){ }}
		ajax.send(null); }


function login_cursos(l,s){
		n=Math.random();
		var id=document.getElementById('indicador').value;
		var conteudo=document.getElementById('conteudo'); 
		var ajax=gera_ajax();
		ajax.open("GET","cursos_query.php?operacao=1&login="+l+"&senha="+s+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><!--<img src='icone.gif' align='absmiddle'>--><b>Carregando Informações...</b></font></center>";	}}
		ajax.send(null); }

function senha_cursos(l,e){
		n=Math.random();
		var id=document.getElementById('indicador').value;
		var conteudo=document.getElementById('conteudo'); 
		var ajax=gera_ajax();
		ajax.open("GET","cursos_query.php?operacao=3&login="+l+"&email="+e+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><!--<img src='icone.gif' align='absmiddle'>--><b>Enviando Informações...</b></font></center>";	}}
		ajax.send(null); }


function voto(escolha){
		n=Math.random();
		var conteudo=document.getElementById('div_eh'); 
		document.getElementById('div_ehbtn').innerHTML=""; 
		var ajax=gera_ajax();
		ajax.open("GET","voto_query.php?opcao="+escolha+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><!--<img src='icone.gif' align='absmiddle'>--><b>Enviando sua escolha, aguarde...</b></font></center>";	}}
		ajax.send(null); }


function quadros(quadro){
	var q=document.getElementById('quadro'); q.innerHTML="";		
	if(quadro=="empreender"){ url="quadro_empreender.php"; }
	if(quadro=="noticias"){ url="quadro_noticias.php"; }
	if(quadro=="exporta"){ url="quadro_exporta.php"; }
	if(quadro=="pae"){ url="quadro_pae.php"; }
	if(quadro=="camara"){ url="quadro_camara.php"; }
	var ajax=gera_ajax();
	ajax.open("GET",url,true);
	ajax.onreadystatechange=function(){
	if(ajax.readyState==4 && ajax.status==200){ q.innerHTML=unescape(ajax.responseText); }
	else{ q.innerHTML="<font class='texto' color='#006600'><!--<img src='icone.gif' align='absmiddle'>--><b>CARREGANDO...</b></font>";	}}
	ajax.send(null); }



function carregar(esconde,pagina){
		esconde=eval(esconde);
		n=Math.random();
		if(document.frm_indicador.videos.value!=""){ vv=document.frm_indicador.videos.value; } else{vv=""; }
		if(esconde==1 || esconde==3){ var quadro=document.getElementById('quadro'); quadro.innerHTML=""; }
		var id=document.getElementById('indicador').value;
		
		if(esconde!=3){
			if(id!=""){ if(pagina=="noticia"){ document.getElementById('indicador').value=""; url="acisjc_query.php?pagina="+pagina+"&id="+id+"&n="+n; }}
			else{ url="acisjc_query.php?pagina="+pagina+"&vv="+vv+"&n="+n; } }
		else{
			url="acisjc_consultas.php?id="+pagina+"&n="+n;
		}
		
		var conteudo=document.getElementById('conteudo'); 
		var ajax=gera_ajax();
		ajax.open("GET",url,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><!--<img src='icone.gif' align='absmiddle'>--><b>Carregando Informações...</b></font></center>";	}}
		ajax.send(null); }


function carregar_oscursos(esconde,i){
		esconde=eval(esconde);
		n=Math.random();
		if(esconde==1){ var quadro=document.getElementById('quadro'); quadro.innerHTML=""; }
		var id=document.getElementById('indicador').value;
		/*if(id!=""){ if(pagina=="noticia"){ document.getElementById('indicador').value=""; url="acisjc_query.php?pagina="+pagina+"&id="+id+"&n="+n; }}
		else{ url="acisjc_query.php?pagina="+pagina+"&vv="+vv+"&n="+n; }*/		
		var conteudo=document.getElementById('conteudo'); 
		var ajax=gera_ajax();
		ajax.open("GET","cursos.php?id="+i+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><b>Carregando Informações...</b></font></center>";	}}
		ajax.send(null); }



		
function valida_exporta(){
	if(document.frm_exporta.txt1.value==""){ alert('Informe o nome.'); document.frm_exporta.txt1.focus(); return false; }
	if(document.frm_exporta.txt2.value==""){ alert('Informe a razão social.'); document.frm_exporta.txt2.focus(); return false; }
	if(document.frm_exporta.txt3.value==""){ alert('Informe o endereço.'); document.frm_exporta.txt3.focus(); return false; }
	if(document.frm_exporta.txt4.value==""){ alert('Informe o bairro.'); document.frm_exporta.txt4.focus(); return false; }
	if(document.frm_exporta.txt5.value==""){ alert('Informe a cidade.'); document.frm_exporta.txt5.focus(); return false; }
	if(document.frm_exporta.txt6.value==""){ alert('Informe o estado/uf.'); document.frm_exporta.txt6.focus(); return false; }
	if(document.frm_exporta.txt11.value==""){ alert('Informe o email.'); document.frm_exporta.txt11.focus(); return false; }
return true; }


function checa(documento){
	var resposta=document.getElementById('cnpj'); 		
	var n=Math.random();
	var ajax=gera_ajax();
	ajax.open("GET","camara_ccci_cnpj.php?tipo=pj&cnpj="+documento+"&cpf=pf&n="+n,true);
	ajax.onreadystatechange=function(){
	if(ajax.readyState==4 && ajax.status==200){ 
		r=unescape(ajax.responseText);
		if(r=="0"){ resposta.innerHTML="<b><font color='FF0000'>CNPJ/CPF Invalido.</font></b>"; document.frm.aux.value="0"; }
		if(r=="1"){ resposta.innerHTML="<b><font color='FF0000'>CNPJ/CPF Invalido.</font></b>"; document.frm.aux.value="0";}
		if(r=="2"){ resposta.innerHTML="<b><font color='0000FF'>CNPJ/CPF valido.</font></b>"; document.frm.aux.value="1";}
		if(r=="3"){ resposta.innerHTML="<b><font color='FF0000'>CNPJ/CPF já cadastrado.</font></b>"; document.frm.aux.value="0";}}
	else{ resposta.innerHTML="<font class='texto' color='#000000'>Validando...</b></font>";	}}
	ajax.send(null); }
	

	
	function checarcpf(tipo){
		var cnpj=document.getElementById('txtcnpj').value; 
		var status=document.getElementById('status'); 
		var n=Math.random();
		var ajax=gera_ajax();
		if(cnpj.length>=11){
			ajax.open("GET","camara_ccci_cnpj.php?cnpj="+cnpj+"&tipo=pf&n="+n,true);
			ajax.onreadystatechange=function(){
				if(ajax.readyState==4 && ajax.status==200){ 
					retorno=unescape(ajax.responseText); 
					if(retorno=="2"){ status.innerHTML="VALIDADO"; document.frm2.ok.value="1"; }
					if(retorno=="1" || retorno=="0"){ status.innerHTML="INVALIDO"; document.frm2.ok.value="0"; }
					if(retorno=="3" || retorno=="0"){ status.innerHTML="EXISTENTE"; document.frm2.ok.value="0"; }}
				else{ status.innerHTML="<center><font color='#000000'><b>Validando...</b></font></center>";	}}
			ajax.send(null); }
			else{ status.innerHTML="<center><b>NUMERO INCONRRETO</b></center>"; }		
			}	
			
	function localiza_empresa(){
		n=Math.random();
		var empresa=document.getElementById('txtempresa').value;
		if(empresa!=""){ 
		var conteudo=document.getElementById('div_emp'); 
		var ajax=gera_ajax();
		ajax.open("GET","empresa_query.php?empresa="+empresa+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){
				retorno=unescape(ajax.responseText); 
				if(retorno!="1"){ conteudo.innerHTML=unescape(ajax.responseText);document.frm_cursos.ok_emp.value=empresa; }
				if(retorno=="1"){ conteudo.innerHTML="Empresa não localizada, o código a ser inserido é o numero de milhão utilizado para efetuar os serviços de consultas no sistema next. Caso não tenha este código solicite-o com o responsável da empresa ou entre em contato pelo telefone (12) 3904-4016.";document.frm_cursos.ok_emp.value="0"; }}
				
			else{ conteudo.innerHTML="<center><font color='#FF0000'><b>Localizando...</b></font></center>";	}}
		    ajax.send(null); }}


	function eleicoes_empresas(letra){
		n=Math.random();
		var conteudo=document.getElementById('divresultadoempresas'); 
		var ajax=gera_ajax();
		ajax.open("GET","eleicoes_query.php?letra="+letra+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){	conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><b>Carregando empresas...</b></font></center>";	}}
		    ajax.send(null); }

function valida_eleicoes(){
	codigos="";
	if(document.frm_eleicoes.lstempresas.options.length<27){ alert('Atenção! Você deve escolhe 27 empresas.'); return false; }
	else{ for(x=0;x<=document.frm_eleicoes.lstempresas.options.length-1;x++){ codigos=codigos+document.frm_eleicoes.lstempresas.options[x].value+"@"; }
	document.frm_eleicoes.empresas.value=codigos; }
}

function valida_varejo(){
	if(document.frm_varejo.txtnome.value==""){ alert('Informe seu nome!'); return false; }
	if(document.frm_varejo.txtempresa.value==""){ alert('Informe o nome da sua empresa!'); return false; }
	if(document.frm_varejo.txtemail.value==""){ alert('Informe seu email para receber a resposta!'); return false; }
	if(document.frm_varejo.txtpergunta.value==""){ alert('Digite sua pergunta!'); return false; }
}

	/*function localiza_empresa(){
		n=Math.random();
		var empresa=document.getElementById('txtempresa').value;
		if(empresa==""){  }else{
		var conteudo=document.getElementById('div_emp'); 
		var ajax=gera_ajax();
		ajax.open("GET","empresa_query.php?empresa="+empresa+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText);document.frm_cursos.ok_emp.value=empresa; }
			else{ conteudo.innerHTML="<center><font color='#FF0000'><b>Localizando...</b></font></center>";	}}
		    ajax.send(null); }}*/
				