function getAjax(url,update) {
	var xmlHttp;
	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp = new XMLHttpRequest();
	}
	
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
 		catch (e) {
    		try {
      			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      		}
    		catch (e)
      		{
     			alert("Your browser does not support AJAX!");
      			return false;
      		}
    	}
	}
	
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4 ) {
			
			document.getElementById(update).innerHTML = xmlHttp.responseText;
		
		} else {
			
			document.getElementById(update).innerHTML = 'carregando...';
			
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function updateLista(query,acao,reacao,cod_pessoa)
{
	getAjax(query+"/controllers/"+acao+".php?reacao="+reacao+"&COD_PESSOA="+cod_pessoa,"lista_"+acao);
	btnMenu = window.setTimeout(function(){
			SqueezeBox.close();
	},1000);
}

function checaCPFeEmail(cpf,email)
{
	var valido = true;
	var xmlHttp;
	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp = new XMLHttpRequest();
	}
	
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
 		catch (e) {
    		try {
      			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      		}
    		catch (e)
      		{
     			alert("Your browser does not support AJAX!");
      			return false;
      		}
    	}
	}
	
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4 ) {
			cpfemail = xmlHttp.responseText;
			cpfemail = cpfemail.split(";;");
			ccpf = cpfemail[0];
			cemail = cpfemail[1];
			if(ccpf > 0){
				$('erro_cpf').innerHTML = "O CPF informado j&aacute; est&aacute; cadastrado.";
				valido = false;
			} else {
				$('erro_cpf').innerHTML = "";
			}
			
			if(cemail > 0){
				$('erro_email').innerHTML = "O EMAIL informado j&aacute; est&aacute; cadastrado.";
				valido = false;
			} else {
				$('erro_email').innerHTML = "";
			}
			
			if(valido == true)
			{
				document.formCadastro.submit();
			}
		}
	}
	xmlHttp.open("GET","components/com_cadastro/helpers/cpfemail.php?cpf="+cpf+"&email="+email,true);
	xmlHttp.send(null);
}
