var divtarget2;

function GetXmlHttpObject(handler)
{
    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
    return objXMLHttp
}

function stateChanged()
{
	
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
            document.getElementById(divtarget2).innerHTML= xmlHttp.responseText;
    }
    else {
            //alert(xmlHttp.status);
    }
}

// Will populate data based on input
function htmlData(url,divname,qStr)
{
    if (url.length==0)
    {
        document.getElementById(divname).innerHTML=""; 
        return;
    }
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    }
	document.getElementById(divname).style.visibility = "visible";
    url=url+"?"+qStr; 
    url=url+"&sid="+Math.random();
	divtarget2=divname;
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function changeairport(divid,tagid,hiddenid,showairport,valueairport){
	document.getElementById(tagid).value = showairport;
	document.getElementById(hiddenid).value = valueairport;
	document.getElementById(divid).innerHTML="";
	document.getElementById(divid).style.visibility = "hidden";
	
	if (hiddenid=="flytofromid"){document.getElementById('r1to').value="";document.getElementById('flytotoid').value="";}
	if (hiddenid=="flytotoid"){
		document.getElementById('r2from').value=document.getElementById('r1to').value;
		document.getElementById('flybackfromid').value=document.getElementById('flytotoid').value;
		}
}

function closeairport(divid){
	document.getElementById(divid).innerHTML="";
	document.getElementById(divid).style.visibility = "hidden";
}