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 paginas(pg){
		var conteudo=document.getElementById('conteudo'); 
		var n=Math.random();
		var ajax=gera_ajax();
		ajax.open("GET","query.php?pagina="+pg+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<br><br><center><font color='#000000' style=\"font-family:Tahoma, Verdana, Arial; font-size:11 px;\"><b>Carregando...</b></font></center>";	}}
		ajax.send(null); }
		
function validacao_cnpj(tipo){
		var cnpj=document.getElementById('txtcpf').value; 
		var status=document.getElementById('status'); 
		var n=Math.random();
		var ajax=gera_ajax();
		if(cnpj.length>=11){
			ajax.open("GET","query_cnpj.php?cnpj="+cnpj+"&tipo="+tipo+"&n="+n,true);
			ajax.onreadystatechange=function(){
				if(ajax.readyState==4 && ajax.status==200){ 
					retorno=unescape(ajax.responseText); 
					if(retorno=="3"){ status.innerHTML="<span class='texto_contato'> <center><b>CPF Inv&aacute;lido!</b></center></span>"; document.form1.ok.value="4";  document.getElementById('txtcpf') }
					if(retorno=="2"){ status.innerHTML="<center><b>OK! CPF V&aacute;lido!</b></center>"; document.form1.ok.value="1";  document.getElementById('txtcpf').style.background="#3C6"}
					if(retorno=="1" || retorno=="0"){  status.innerHTML= "<span class='texto_contato'><center><font color='#C30'><b>CPF J&aacute; cadastrado!</b></font></center></span>"; document.form1.ok.value="2"; document.getElementById('txtcpf').style.background="#F30"  }}
				else{ status.innerHTML="<center><font color='#000000'><b>Validando...</b></font></center>";	}}
			ajax.send(null); }}	
			
function pesquisa(pg){
		var valorpesquisa=document.getElementById('txtpesquisa').value; 
		var conteudo=document.getElementById('conteudo'); 
		var n=Math.random();
		var ajax=gera_ajax();
		ajax.open("GET","query.php?valorpesquisa="+valorpesquisa+"&pesquisa="+pg+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<br><br><center><font color='#000000' style=\"font-family:Tahoma, Verdana, Arial; font-size:11 px;\"><b>Carregando...</b></font></center>";	}}
		ajax.send(null); }
		
function validacao_login(tipo){
		var login=document.getElementById('txtlogin').value; 
		var status=document.getElementById('mostra'); 
		var n=Math.random();
		var ajax=gera_ajax();
		if(login.length>=4){
			ajax.open("GET","user/curso/query_login.php?login="+login+"&tipo="+tipo+"&n="+n,true);
			ajax.onreadystatechange=function(){
				if(ajax.readyState==4 && ajax.status==200){ 
					retorno=unescape(ajax.responseText); 
					if(retorno=="3"){ status.innerHTML="<span class='texto_contato'> <center><b>Login Inv&aacute;lido!</b></center></span>"; document.form1.ol.value="4";  document.getElementById('txtlogin') }
					if(retorno=="2"){ status.innerHTML="<center><b>OK! Login V&aacute;lido!</b></center>"; document.form1.ol.value="1";  document.getElementById('txtlogin').style.background="#3C6"}
					if(retorno=="1" || retorno=="0"){  status.innerHTML= "<span class='texto_contato'><center><font color='#C30'><b>Login J&aacute; cadastrado!</b></font></center></span>"; document.form1.ol.value="2"; document.getElementById('txtlogin').style.background="#F30"  }}
				else{ status.innerHTML="<center><font color='#000000'><b>Validando ...</b></font></center>";	}}
			ajax.send(null); }}	

