var xmlHttp
//Fila de conexões
fila=[]
ifila=0

//grava boleto
//	 	 GravaBoleto('Excluir', Form.status1.value, Form.chave.value, Form.ano.value, Form.valor.value, Form.exibir.value);
function GravaBoleto(sApagar, sStatus, sChave, sAno, sValor, sExibir, sData)
{ 
if (sStatus != "")
{ 
//Carregando...
//alert(sStatus);
document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
document.getElementById('EnquantoGravaUsuario').style.display = "inline";
document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"

var url="../../funcoes/funcao_associado.asp?sid=" + Math.random() + "&apagar=" + sApagar + "&status1=" + sStatus +  "&chave=" + sChave  + "&ano=" + sAno + "&valor=" + sValor + "&exibir=" + sExibir + "&data=" + sData + "&boleto=sim" 
//alert(url);
xmlHttp=GetXmlHttpObject(stateGBoleto)
xmlHttp.open("GET", url , true)
xmlHttp.send(null) 
} 
else
{ 
	alert("Informações inválidas."); 
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
	document.getElementById('ano').value ="";
	document.getElementById('valor').value ="";
	document.getElementById('data').value ="";
	document.getElementById('exibir').value ="N";
} 
} 


function stateGBoleto() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	alert(t);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
	document.getElementById('ano').value ="";
	document.getElementById('valor').value ="";
	document.getElementById('exibir').value ="N";
	document.getElementById('data').value ="";
	parent.location.href="boleto.asp";
} 
} 


//grava especializacao
function GravaEspecializacao(sApagar, sStatus, sChave, sNome)
{ 
if (sStatus != "")
{ 
//Carregando...
//alert(sStatus);
document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
document.getElementById('EnquantoGravaUsuario').style.display = "inline";
document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"

var url="../../funcoes/funcao_associado.asp?sid=" + Math.random() + "&apagar=" + sApagar + "&status1=" + sStatus +  "&chave=" + sChave  + "&nome=" + sNome + "&especializacao=sim" 
//alert(url);
xmlHttp=GetXmlHttpObject(stateGEspecia)
xmlHttp.open("GET", url , true)
xmlHttp.send(null) 
} 
else
{ 
	alert("Informações inválidas."); 
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
	document.getElementById('nome').value ="";
} 
} 


function stateGEspecia() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	alert(t);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
	document.getElementById('nome').value ="";
	parent.location.href="especializacao.asp";
} 
} 

//grava grau de formação
function GravaFormacao(sApagar, sStatus, sChave, sNome)
{ 
if (sStatus != "")
{ 
//Carregando...
//alert(sStatus);
document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
document.getElementById('EnquantoGravaUsuario').style.display = "inline";
document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"

var url="../../funcoes/funcao_associado.asp?sid=" + Math.random() + "&apagar=" + sApagar + "&status1=" + sStatus +  "&chave=" + sChave  + "&nome=" + sNome + "&formacao=sim" 
//alert(url);
xmlHttp=GetXmlHttpObject(stateGFormacao)
xmlHttp.open("GET", url , true)
xmlHttp.send(null) 
} 
else
{ 
	alert("Informações inválidas."); 
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
	document.getElementById('nome').value ="";
} 
} 


function stateGFormacao() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	alert(t);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
	document.getElementById('nome').value ="";
	parent.location.href="grau_formacao.asp";
} 
} 

//associado********************
function GravaSenhaAssociado(sChave, sSenhaOld, sSenhaNova)
{
	if (sChave != "")
	{ 	
		document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
		document.getElementById('EnquantoGravaUsuario').style.display = "inline";
		document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"

		var url="../funcoes/funcao_associado.asp?sid=" + Math.random() 

		var dados_a_enviar= "status1=alteracao&chave=" + escape(sChave)  + "&senhaOld=" + escape(sSenhaOld) + "&senhNova=" + escape(sSenhaNova) +"&associado=sim"
		//alert(url+dados_a_enviar);
		xmlHttp=GetXmlHttpObject(stateGAssociadoSenha)
		xmlHttp.open("POST", url, true);
		//Definimos os Headers de nossa solicitação.
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; iso-8859-1");
		xmlHttp.setRequestHeader("CharSet", "iso-8859-1")
		xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		xmlHttp.setRequestHeader("Pragma", "no-cache");
		xmlHttp.send(dados_a_enviar);
		} 
		else
		{ 
			alert("Informações inválidas."); 
			document.getElementById('chave').value ="";
			document.getElementById('status1').value ="inclusao";
	} 
}

function stateGAssociadoSenha() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	//alert(t);
	alert(t);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	//document.getElementById('chave').value ="";
	//document.getElementById('status1').value ="inclusao";
	parent.location.href="default.asp";
} 
} 

//recupera semha
function RecuperaSenhaAssociado(sEmail)
{
	if (sEmail != "")
	{ 	
		var url="../funcoes/funcao_associado.asp?sid=" + Math.random() 

		var dados_a_enviar= "status1=recupera&email=" + escape(sEmail) +"&associado=sim"
		//alert(url+dados_a_enviar);
		xmlHttp=GetXmlHttpObject(stateRAssociadoSenha)
		xmlHttp.open("POST", url, true);
		//Definimos os Headers de nossa solicitação.
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; iso-8859-1");
		xmlHttp.setRequestHeader("CharSet", "iso-8859-1")
		xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		xmlHttp.setRequestHeader("Pragma", "no-cache");
		xmlHttp.send(dados_a_enviar);
		} 
		else
		{ 
			alert("Informações inválidas."); 
			document.getElementById('login').value ="";
	} 
}

function stateRAssociadoSenha() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	//alert(t);
	alert(t);
	document.getElementById('login').value ="";
	document.getElementById("loginSenha").innerHTML="Login:";
	//document.getElementById('status1').value ="inclusao";
	//parent.location.href="default.asp";
} 
} 

function GravaAssociado(sStatus, sChave, sNome, sEmail, sData, sEstado2, sCRMV, sCPF, sLogin, sEspecializacao, sGrauFormacao, sInstituicao, sCEP, sEndereco, sNumero, sComplemento, sBairro, sCidade, sEstado, sDdd, sTelefone, sDddFax, sFax, sDddCelular, sCelular, sDestaque, sEnviaEmail, sSenha, sArea, sTitulo, sAno)
{ 
if (sStatus != "")
{ 
//Carregando...
//alert(sStatus);
document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
document.getElementById('EnquantoGravaUsuario').style.display = "inline";
document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"
if (sStatus == "iii") {
	sStatus = "inclusao"
	var url="funcoes/funcao_associado.asp?sid=" + Math.random() + "&boleto=sim" 
} else if (sStatus == "aaa") {
	sStatus = "alteracao"
	var url="../funcoes/funcao_associado.asp?sid=" + Math.random() 
} else {
	var url="../../funcoes/funcao_associado.asp?sid=" + Math.random() 	
}

var dados_a_enviar= "status1=" + escape(sStatus) +  "&chave=" + escape(sChave)  + "&nome=" + escape(sNome) + "&email=" + escape(sEmail) + "&data=" + (sData) + "&estado2=" + escape(sEstado2) + "&crmv=" + escape(sCRMV) + "&cpf=" + escape(sCPF) + "&login=" + escape(sLogin) + "&especializacao=" + escape(sEspecializacao) + "&formacao=" + escape(sGrauFormacao) + "&instituicao=" + escape(sInstituicao) + "&cep=" + escape(sCEP) + "&endereco=" + escape(sEndereco) + "&numero=" + escape(sNumero) + "&complemento=" + escape(sComplemento) + "&bairro=" + escape(sBairro) + "&cidade=" + escape(sCidade) + "&estado=" + escape(sEstado) + "&ddd=" + escape(sDdd) + "&telefone=" + escape(sTelefone) + "&ddd_fax=" + escape(sDddFax) + "&fax=" + escape(sFax) + "&ddd_celular=" + escape(sDddCelular) + "&celular=" + escape(sCelular)+ "&autoriza=" + escape(sDestaque)+"&enviaEmail="+sEnviaEmail+"&senha="+sSenha+"&area="+escape(sArea)+"&associado=sim"+"&titulo="+escape(sTitulo)+"&ano="+escape(sAno)
//alert(url+dados_a_enviar);
xmlHttp=GetXmlHttpObject(stateGAssociado)
xmlHttp.open("POST", url, true);
//Definimos os Headers de nossa solicitação.
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; iso-8859-1");
xmlHttp.setRequestHeader("CharSet", "iso-8859-1")
xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
xmlHttp.setRequestHeader("Pragma", "no-cache");
xmlHttp.send(dados_a_enviar);
} 
else
{ 
	alert("Informações inválidas."); 
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
} 
} 


function stateGAssociado() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	//alert(t);
	alert(t);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	//document.getElementById('chave').value ="";
	//document.getElementById('status1').value ="inclusao";
	//parent.location.href="cadastro_associado.asp";
} 
} 

function GravaAviso(sStatus, sChave, sChaveAss, sTexto)
{ 
if (sChaveAss != "")
{ 
//Carregando...
//alert(sStatus);
document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
document.getElementById('EnquantoGravaUsuario').style.display = "inline";
document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"

var url="../../funcoes/funcao_associado.asp?sid=" + Math.random() 
var dados_a_enviar= "status1=" + escape(sStatus) +  "&chave=" + escape(sChave)  + "&chaveAss=" + escape(sChaveAss) + "&texto=" + escape(sTexto) + "&aviso=sim"
//alert(url+dados_a_enviar);
xmlHttp=GetXmlHttpObject(stateGAssAviso)
xmlHttp.open("POST", url, true);
//Definimos os Headers de nossa solicitação.
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; iso-8859-1");
xmlHttp.setRequestHeader("CharSet", "iso-8859-1")
xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
xmlHttp.setRequestHeader("Pragma", "no-cache");
xmlHttp.send(dados_a_enviar);
} 
else
{ 
	alert("Informações inválidas."); 
	document.getElementById('chave').value ="";
	document.getElementById('texto').value ="";
	document.getElementById('status1').value ="inclusao";
} 
} 


function stateGAssAviso() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	//alert(t);
	var arr=t.split('|');
	alert(arr[0]);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	//document.getElementById('chave').value ="";
	//document.getElementById('texto').value ="";
	//document.getElementById('status1').value ="inclusao";
	//parent.location.href="associado_aviso.asp?chaveAss="+arr[1];
	parent.location.reload(false);
} 
} 
//extrato
function GravaExtrato(sStatus, sChave, sChaveAss, sAno, sPagamento, sValor, sTagStatus, sNome)
{ 
if (sChaveAss != "")
{ 
//Carregando...
//alert(sStatus);
document.getElementById('EnquantoGravaUsuario').style.visibility = "visible";
document.getElementById('EnquantoGravaUsuario').style.display = "inline";
document.getElementById("EnquantoGravaUsuario").innerHTML="<b>Aguarde enquanto o sistema grava as informações!</b>"

var url="../../funcoes/funcao_associado.asp?sid=" + Math.random() 
var dados_a_enviar= "status1=" + escape(sStatus) +  "&chave=" + escape(sChave)  + "&chaveAss=" + escape(sChaveAss) + "&ano=" + escape(sAno) + "&pagamento=" + escape(sPagamento) + "&valor=" + escape(sValor) + "&tag_status=" + escape(sTagStatus)  + "&nome=" + escape(sNome) + "&extrato=sim"
//alert(url+dados_a_enviar);
xmlHttp=GetXmlHttpObject(stateGAssExtrato)
xmlHttp.open("POST", url, true);
//Definimos os Headers de nossa solicitação.
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; iso-8859-1");
xmlHttp.setRequestHeader("CharSet", "iso-8859-1")
xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
xmlHttp.setRequestHeader("Pragma", "no-cache");
xmlHttp.send(dados_a_enviar);
} 
else
{ 
	alert("Informações inválidas."); 
	document.getElementById('chave').value ="";
	document.getElementById('status1').value ="inclusao";
} 
} 


function stateGAssExtrato() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//t=troca_acento(t);
	//alert(t);
	var arr=t.split('|');
	alert(arr[0]);
	document.getElementById('EnquantoGravaUsuario').style.visibility = "hidden";
	document.getElementById('EnquantoGravaUsuario').style.display = "none";
	//document.getElementById('chave').value ="";
	//document.getElementById('texto').value ="";
	//document.getElementById('status1').value ="inclusao";
	//parent.location.href="associado_aviso.asp?chaveAss="+arr[1];
	parent.location.reload(false);
} 
} 
function BuscaCep(str)
{ 
if (str.length > 0)
{ 
//Carregando...
document.getElementById("endereco").value="Carregando..."

var url="../../funcoes/funcao_cep_ajax.asp?sid=" + Math.random() + "&q=" + str
//alert(url);
xmlHttp=GetXmlHttpObject(stateChanged)
xmlHttp.open("GET", url , true)
xmlHttp.send(null) 
} 
else
{ 
document.getElementById("endereco").value=""
document.getElementById("bairro").value=""
document.getElementById("cidade").value=""
document.getElementById("estado").value=""
} 
} 


function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	//Obtém o retorno
	t=xmlHttp.responseText 
	//Transforma em objeto
	ceps=eval("t")
	//alert(ceps);
	//Preenche o select
	var arr=ceps.split('|');
	document.getElementById("endereco").value = arr[0];
	document.getElementById("bairro").value = arr[1];
	document.getElementById("cidade").value = arr[2];
	document.getElementById("estado").value = arr[3]; 

} 
} 

/****rotina comum *************/

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 


