// JavaScript Document
try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function getRepresentante(representante){
	var textoXml = document.getElementById("textoXml");
	//textoXml.innerHTML = "<img src='ajax-loader.gif' />";
	var representante = document.getElementById("representante");
	if(xmlhttp){
		xmlhttp.open("POST", "retorno.php", true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		var dados = "representante=getRepresentante&representante="+representante.value;
		xmlhttp.send(dados);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4){
				//document.getElementById("loading").style.visibility = "hidden";
				var retorno=xmlhttp.responseText;
				retorno=retorno.replace(/\+/g," ");
				retorno=unescape(retorno);
				if(retorno == 'ERRO'){
					//response.write('nenhum convenio no momento'); 
					//alert('Não há representante disponível para esta localidade no momento. Entre em contato com a nossa central para maiores informações');
					textoXml.innerHTML ="<br>Não há representantes para essa localidade.<br>Solicite informações através do e-mail comercial@kriakoisas.com.br ";
					
				}else{
					textoXml.innerHTML = retorno;
				}
			}
		}
	}
}
