function objetoAjax(){
	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 AJAXCrearObjeto_verificar_url(){ 
 var obj; 
 if(window.XMLHttpRequest) { // no es IE o IE7
 obj = new XMLHttpRequest(); 
 } else { // Es IE o no tiene el objeto 
 try { 
 obj = new ActiveXObject("Microsoft.XMLHTTP"); 
 } 
 catch (e) { 
 alert('El navegador utilizado no está soportado'); 
 } 
 } 
 return obj; 
} 

function VerEntidades(dir, grupo_id, entidad)
{
	var array_grupo_id = grupo_id.split("-");
	var id_tipo=array_grupo_id[0];
	var id=array_grupo_id[1];
	var frm=document.formregistroalta;

	if (id==0) {
		document.getElementById('l_enti').style.display="none";		
		document.getElementById('ep').style.display="";
		document.getElementById('txt-ep').innerHTML="Otra entidad";
		frm.compania.disabled=false;
		frm.compania.value='';
	}
	else {
		document.getElementById('ep').style.display="none";
		document.getElementById('l_enti').style.display="";
		frm.compania.disabled=false;
	}
	
	divResultado1 = document.getElementById('enti');
	ajax1=objetoAjax();
	ajax1.open("GET", dir+'scripts/ajax/ajax_lista_enti.php?id='+id+'&entidad='+entidad);
	ajax1.onreadystatechange=function() {
		if (ajax1.readyState==4) {
			divResultado1.innerHTML = ajax1.responseText;
		}
	}
	ajax1.send(null);

	frm.entidad.value=entidad;
}

function asignar_entidad(id_entidad)
{
	var frm=document.formregistroalta;
	frm.entidad.value=id_entidad;
}

function VerCiudad(dir, id, ciudad)
{
	e = document.getElementById('tr_ciu');
	if(id!=0)
	{
		e.style.display = '';

		if (ciudad=='' || ciudad==0) document.getElementById('d_nom_ciudad').style.display="";
		else document.getElementById('d_nom_ciudad').style.display="none";

		divResultado = document.getElementById('d_ciudad');
		ajax=objetoAjax();
		ajax.open("GET", dir+'scripts/ajax/ajax_lista_ciudad.php?id='+id+'&ciudad='+ciudad);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				divResultado.innerHTML = ajax.responseText;
			}
		}
		ajax.send(null);

		var frm=document.formregistroalta;
		frm.ciudad.value=ciudad;
	}
	else e.style.display = 'none';
}

function asignar_ciudad(ciudad)
{
	var frm=document.formregistroalta;
	frm.ciudad.value=ciudad;
	if (ciudad==0) document.getElementById('d_nom_ciudad').style.display="";
	else document.getElementById('d_nom_ciudad').style.display="none";	
}
