var xmlHttp;
var DIV_nome;
var numCampo;

function carregaSelectCidades (v_url,parametros,campo) {

   numCampo = campo;
   var url = v_url + "?rnd=" + Math.random() + parametros;
   xmlHttp=GetXmlHttpObject(stateChangedCidades);
   xmlHttp.open("GET", url , true);
   xmlHttp.send(null);	

}



function carregaSelectEstadosProcureMedico (v_url,parametros) {

   var url = v_url + "?rnd=" + Math.random() + parametros;

   xmlHttp=GetXmlHttpObject(stateChangedEstadosProcureMedico);

   xmlHttp.open("GET", url , true);

   xmlHttp.send(null);	

}



function carregaSelectCidadesProcureMedico (v_url,parametros) {

   var url = v_url + "?rnd=" + Math.random() + parametros;

   xmlHttp=GetXmlHttpObject(stateChangedCidadesProcureMedico);

   xmlHttp.open("GET", url , true);

   xmlHttp.send(null);	

}



function carregaMedicosProcureMedico (v_url,parametros) {

   var url = v_url + "?rnd=" + Math.random() + parametros;

   xmlHttp=GetXmlHttpObject(stateChangedMedicosProcureMedico);

   xmlHttp.open("GET", url , true);

   xmlHttp.send(null);	

}



function existeCpfNoCadastro (v_url,parametros) {

   var url = v_url + "?rnd=" + Math.random() + parametros;

   xmlHttp=GetXmlHttpObject(stateChangedCPF);

   xmlHttp.open("GET", url , true);

   xmlHttp.send(null);	

}



function existeCpfDuplicadoNoCadastro (v_url,parametros) {

   var url = v_url + "?rnd=" + Math.random() + parametros;

   xmlHttp=GetXmlHttpObject(stateChangedCPFDuplicado);

   xmlHttp.open("GET", url , true);

   xmlHttp.send(null);	

}



function existeCpfAtivoNoCadastro (v_url,parametros) {

   var url = v_url + "?rnd=" + Math.random() + parametros;

   xmlHttp=GetXmlHttpObject(stateChangedCPFAtivo);

   xmlHttp.open("GET", url , true);

   xmlHttp.send(null);	

}



function stateChangedMedicosProcureMedico() { 



	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   document.getElementById("MembrosResultado").innerHTML = xmlHttp.responseText;

	} 

	

} 



function stateChangedCidades() { 

	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   document.getElementById("divCidades" + numCampo).innerHTML = xmlHttp.responseText;

	} 

	

} 



function stateChangedEstadosProcureMedico() { 



	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   document.getElementById("divEstados").innerHTML = xmlHttp.responseText;

	   document.TheFormProcureMedico.txtEstado.disabled = false;

	} 

	

} 



function stateChangedCidadesProcureMedico() { 



	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   document.getElementById("divCidades").innerHTML = xmlHttp.responseText;

	   document.TheFormProcureMedico.txtCidade.disabled = false;

	} 

	

} 



function stateChangedCPF() { 



	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   if ( xmlHttp.responseText == 1 ){

	      resposta = confirm("Atenção, esse CPF já consta em nosso cadastro, não será possível efetuar um novo cadastro utilizando esse CPF. Se você perdeu a sua senha e deseja recuperá-la clique em OK."); 	   

		  if (resposta) {

			 self.location.href = 'membros_recuperar_senha_pre.php?cpf=' + document.TheFormCadastro.txtCPF.value;

		  }else{

		     document.TheFormCadastro.txtCPF.value = "";

		     document.TheFormCadastro.txtCPF.focus();

	      }

	   }

	} 

	

} 





function stateChangedCPFDuplicado() { 



	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   if ( xmlHttp.responseText > 0 ){

		 alert("Atenção, esse CPF já consta em nosso cadastro, não será possível alterar o seu cadastro."); 	   

		 document.TheFormCadastro.txtCPF.value = "";

		 document.TheFormCadastro.txtCPF.focus();

	   }

	} 

	

} 









function stateChangedCPFAtivo() { 



	if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) { 

	   if ( xmlHttp.responseText == 1 ){

	      self.location.href = 'membros_recuperar_senha_pre.php?cpf=' + document.TheFormLogin.txtCPF.value;

	   }else if ( xmlHttp.responseText == 2 ){

		  resposta = confirm ("Atenção, esse CPF se encontra bloqueado para acessar a área restrita. Entre em contato pelo nosso telefone ou mande uma mensagem para SBCBM. Deseja enviar uma mensagem agora ?"); 

          if ( resposta ) {

		     self.location.href = 'contato_fale_conosco.php';       	  

		  }

	   }else{

		  alert("Atenção, esse CPF não consta em nosso cadastro, não será possível reenviar a sua senha. Operação cancelada."); 

	   }

	} 

	

} 

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

}

} 