function objAjax(){
	var xmlhttp=false;
 	try {
 		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} catch (e) {
 		try {
 			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 		} catch (E) {
 			xmlhttp = false;
 		}
  	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function sLocalidades(sDiv,sLista){	//Genera directorio
	var iComp;	
	iCompania=document.getElementById(sLista).value;
	divResultado = document.getElementById(sDiv);
	ajax=objAjax();
	ajax.open ('GET', 'listaloc.php?r='+iCompania, true);
	ajax.onreadystatechange = function() {
		if (ajax.readyState==1){
			divResultado.innerHTML="Procesando...";
		}
		else if (ajax.readyState==4){
			if(ajax.status==200){
				document.getElementById(sDiv).innerHTML=ajax.responseText; 
			}
			else if(ajax.status==404){
				divResultado.innerHTML = "No se encuentra";
			}
			else{
				divResultado.innerHTML = "Error: ".ajax.status;
			}
		}
	}
	ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	ajax.send(null);
	return
}