﻿
function EnviaAeropuerto(descripcion)
{        
    var control=document.getElementById('hcontrol').value;
    if (control!=null)
    {
        if(descripcion!='')
        {
            if (control=='origen')
                document.getElementById('origen').value=descripcion;             
            if (control=='destino')
                document.getElementById('destino').value=descripcion;
            if (control=='origenofertas')
                document.getElementById('origenofertas').value=descripcion;             
            if (control=='destinofertas')
                document.getElementById('destinofertas').value=descripcion;
            if (control=='origenalertas')
                document.getElementById('origenalertas').value=descripcion;             
            if (control=='destinoalertas')
                document.getElementById('destinoalertas').value=descripcion;
        }
        document.getElementById('listado-aeropuertos').style.display='none';
        document.getElementById('tipodestinos').innerHTML='Destinos frecuentes:';
        document.getElementById('PaisesLetra').style.display='none';
        document.getElementById('AeropuertosPais').style.display='none';
        document.getElementById('lista-aeropuertos-nacionales1').style.display='block';
        document.getElementById('lista-aeropuertos-nacionales2').style.display='block';
    }
}

function Carga_Paises_Letra(letra)
{
    if (window.XMLHttpRequest) //Non-IE Browsers
		GlobalAjaxObjectVal = new XMLHttpRequest(); //Global Variable
	else if(window.ActiveXObject) //IE Browsers
		GlobalAjaxObjectVal = new ActiveXObject("Msxml2.XMLHTTP");  //Global Variable
	else 
	{ //Your browsers is not compatible with AJAX
		alert('Your browser is not supported.')
		return; //exit
	}
	//Initialized the Ajax object to access the URL
    url = "Paises_Letra.aspx?letra=" + letra;

	var url_encode= encodeURI(url);
	
	GlobalAjaxObjectVal.open("GET", url_encode );
	//GlobalAjaxObject.open("POST", document.formulariohome);
	//Sets the function that is run many times.
    GlobalAjaxObjectVal.onreadystatechange = mostrar_paises_letra;
	//Executes the request
	GlobalAjaxObjectVal.send(null);
}

function mostrar_paises_letra()
{
    if(GlobalAjaxObjectVal.readyState == 4)
	{
		if(GlobalAjaxObjectVal.status == 200)
		{ //200 = success
			text = GlobalAjaxObjectVal.responseText;
			var element = document.getElementById('PaisesLetra');
			element.innerHTML=text;
			document.getElementById('tipodestinos').innerHTML='Destinos por paises';
			document.getElementById('PaisesLetra').style.display='block';
			document.getElementById('lista-aeropuertos-nacionales1').style.display='none';
			document.getElementById('lista-aeropuertos-nacionales2').style.display='none';
			document.getElementById('AeropuertosPais').style.display='none';
	    }
	}
}

function Carga_Aeropuertos_Pais(pais)
{
    if (window.XMLHttpRequest) //Non-IE Browsers
		GlobalAjaxObjectVal = new XMLHttpRequest(); //Global Variable
	else if(window.ActiveXObject) //IE Browsers
		GlobalAjaxObjectVal = new ActiveXObject("Msxml2.XMLHTTP");  //Global Variable
	else 
	{ //Your browsers is not compatible with AJAX
		alert('Your browser is not supported.')
		return; //exit
	}
	
	document.getElementById('tipodestinos').innerHTML='destinos por paises - ' + pais;
	
	//Initialized the Ajax object to access the URL
    url="Aeropuertos_Pais.aspx?pais=" + pais;

	var url_encode= encodeURI(url);
	
	GlobalAjaxObjectVal.open("GET", url_encode );
	//GlobalAjaxObject.open("POST", document.formulariohome);
	//Sets the function that is run many times.
    GlobalAjaxObjectVal.onreadystatechange = mostrar_aeropuertos_pais;
	//Executes the request
	GlobalAjaxObjectVal.send(null);
}

function mostrar_aeropuertos_pais()
{
    if(GlobalAjaxObjectVal.readyState == 4)
	{
		if(GlobalAjaxObjectVal.status == 200)
		{ //200 = success
			text = GlobalAjaxObjectVal.responseText;
			var element = document.getElementById('AeropuertosPais');
			element.innerHTML=text;
			document.getElementById('AeropuertosPais').style.display='block';
	    }
	}
}
