﻿// JScript File

/* ------------------------------------------------------------------------
---------------------------------------------------------------------------
--------------------  Airport Lookup AutoComplete  ------------------------
--------------------  Coder: Abbey Gwayambadde     ------------------------
--------------------  Copyright: nPorta 2006       ------------------------
--------------------  Date:  10/31/2006            ------------------------
--------------------  Version: 1.0.0               ------------------------
-------------------   Date:  12/02/2006            ------------------------
--------------------  Versoin: 1.2.0               ------------------------ 
---------------------------------------------------------------------------
Summary:
Used for IATA Airport Code lookup AutoComplete for FareQuest 2.0
-------------------------------------------------------------------------*/



// -------------- Global IATA Airport Code AutoComplete Variables -------------- 
var IATAACTargetControl = null;  //The control that is currently active
var IATAACAirportResults = new Array(); //The retrieved results from the last webservice call
var IATAACWebserviceFailed = false;   //If the webservice failed the last call
var IATAACWebServiceFilter = false;   //if the webservice oncomplete should filter
var directMatch = null;  //any airport that is an exact match on the Airport code
var filteredAirports = new Array();  //holds all the airports that match the filtering text
var IATAACValidateAirportControl = null;  //holds the airport to/from field to reference in multishow
var IATAACValidateAirportKeyword = null;  //holds the airport to/from keyword to reference in multishow
var IATAACValidateAirportAutoPop = false; //holds weather the airport lookup was automatically poped up vs user




// ------------- Global IATA Airport Code AutoComplete Methods -------------


//returns a boolean that indicates
//if an error is being displayed or not
function IATAACAutoCompHasError()
{
    return global_HasError;
}

//returns access to the TargetControl element
function IATAACActiveControl()
{
    return IATAACTargetControl;
}

//temporary function to check if the airport is correct
function IATAACIsValidAirport(airportname)
{
    if(airportname.indexOf("[") < 0 && airportname.length != 3 && airportname.length > 0)
    {
        return false;
    }
}

//returns a boolean indicating if filtering can happen or not
function IATAACCanFilter(refControl)
{
    return (refControl.value.length > 2)? true : false;
}



//returns a boolean indicating if the webservice can be called
function IATAACCanCall(refControl)
{
    var boolCan = false;
    if(refControl != null)
    {
        //if the control's value length is 1, then call webservice
        if(refControl.value.length == 1)
        {
            boolCan = true;
        }
        //if the webservice failed before, call again
        if(IATAACWebserviceFailed == true)
        {
            boolCan = true;
        }
    }
    return boolCan;
}


//Shows the results of the Airport Search
function IATAACDisplayShowResults()
{  
    //display the display block
    IATAACAirportsDisplayDiv().style.display = "block";
}


//hides the results panel
function IATAACDisplayHideResults()
{
    //reset and manually hide both result display of them
    document.getElementById("AirportcompletionList1").innerHTML = "";
    document.getElementById("AirportcompletionList1").style.display = "none";
    document.getElementById("AirportcompletionList2").innerHTML = "";
    document.getElementById("AirportcompletionList2").style.display = "none";  
}

//hide the select input boxes
function IATAACDisplayHideSelects()
{
    //disable the input boxes
    document.getElementById("LeaveTime").style.display = "none";
    document.getElementById("ReturnTime").style.display = "none";
    //document.getElementById("Travelers").style.display = "none";
}

//show the select input boxes
function IATAACDisplayShowSelects()
{
    //disable the input boxes
    document.getElementById("LeaveTime").style.display = "inline";
    document.getElementById("ReturnTime").style.display = "inline";
    //document.getElementById("Travelers").style.display = "inline";
}


//returns access to the Airports display div of the respective control
function IATAACAirportsDisplayDiv()
{
    if(IATAACActiveControl() != null)
    {
        //variables to hold table information
        var divTag = null;
        var iFrameTag = null;
        var tableTag = null;
        
        //disable the select buttons
        IATAACDisplayHideSelects();
        
        //From Field
        if(IATAACActiveControl().id == "FromField")
        {
            divTag = document.getElementById("AirportcompletionList1");
            
            //attempt to adjust for ie placement offset
            if(document.all && divTag != null) //IE
            {
                divTag.style.top = (IATAACAutoCompHasError() == true) ? 259 : 235;
                divTag.style.left = 21;
            }
            else
            {
                divTag.style.top = (IATAACAutoCompHasError() == true) ? 252 : 232;
            }
        }
        
        
         //To Field
        if(IATAACActiveControl().id == "ToField")
        {
            divTag = document.getElementById("AirportcompletionList2");
            
            //attempt to adjust for ie placement offset
            if(document.all && divTag != null) //IE
            {
                divTag.style.top = (IATAACAutoCompHasError() == true) ? 310 : 288;
                divTag.style.left = 21;
            }
             else
            {
                divTag.style.top = (IATAACAutoCompHasError() == true) ? 296 : 276;
            }
        }
        
        //return the associated div
        return divTag;
    }
}



//displays the results of the Webservice
function IATAACFilterAirports()
{
    //reset the filtered Airports
    filteredAirports = new Array();
    directMatch = null;
    
    //temporary storage of retrieved airports
    var myArray = IATAACAirportResults;
    
    //see if there are any resutls
    if(myArray != null && myArray.length > 0)
    {
        //clear out the previous results
        IATAACAirportsDisplayDiv().innerHTML = "";
        
        //display the results
        IATAACDisplayShowResults();
        
        //find all the airports that match the search string
        for(i=0; i < myArray.length; i++)
        {
           window.status = i;
            if(myArray[i].toLowerCase().indexOf(IATAACActiveControl().value.toLowerCase()) > -1)
            {   
                //store the matched array
                filteredAirports.push(myArray[i]);
               
                //look to see if it contains the airport code, if so
                //record its index level
                var compstring = "[" + IATAACActiveControl().value.toLowerCase().substring(0,3) + "]";
                if(myArray[i].toLowerCase().indexOf(compstring) > -1)
                {
                    directMatch = myArray[i];
                }
            }
        } //end i for loop from results array
        
         //sort the airports
        filteredAirports.sort();
        
        var strLink = "<b>Narrow your search to see additional airports</b><br/>";
        //make the first item an item that matches the airport code
        if(directMatch != null)
        {
            strLink += '<a href="" class="autocompxxlinkstyle" ';
            strLink +='onclick="IATAACOnSelectAirport(this.title);return false;"';
            strLink += 'title="' + directMatch + '">';
            strLink +='<img src="app_themes/default/images/airport_sign.gif" alt="Airport" border="0" width="13px" height="13px" />&nbsp;'
            strLink += directMatch;
            strLink += '</a>';
            strLink += "<br/>";
        }
        
        if(filteredAirports.length > 0)
        {
            //display all the airports that were found
            for(j=0; j < filteredAirports.length; j++)
            {   
                //make sure to not display the first airport again
                if(filteredAirports[j] != directMatch)
                {
                    strLink += '<a href="" class="autocompxxlinkstyle" ';
                    strLink +='onclick="IATAACOnSelectAirport(this.title);return false;"';
                    strLink += 'title="' + filteredAirports[j] + '">';
                    strLink +='<img src="app_themes/default/images/airport_sign.gif" alt="Airport" border="0" width="13px" height="13px" />&nbsp;'
                    strLink += filteredAirports[j];
                    strLink += '</a>';
                    strLink += "<br/>";
                }
            }
            //display the airports
            IATAACAirportsDisplayDiv().innerHTML += strLink;
        }
        else
        {
            //no items found so hide the results
            IATAACDisplayHideResults();
            //set the webservice to allow filtering
            IATAACWebServiceFilter = true;
        }
        
    } //end myArray results Array is not empty if statement
}




//displays the results of the Webservice
function IATAACAirports(myArray)
{
    //see if there are any resutls
    if(myArray != null && myArray.length > 0)
    {
        //display the results
        IATAACDisplayShowResults();
        for(i=0; i < myArray.length; i++)
        {
            var strLink = '<a href="" class="autocompxxlinkstyle" ';
            strLink +='onclick="return false;"';
            strLink += 'title="' + myArray[i] + '">';
            strLink +='<img src="app_themes/default/images/airport_sign.gif" alt="Airport" border="0" width="13px" height="13px" />&nbsp;'
            strLink += myArray[i];
            strLink += '</a>';
            strLink += "<br/>";
            IATAACAirportsDisplayDiv().innerHTML += strLink;   
        }
    }
    else
    {
        //display the no results found message
    }
}


///************************************************************************
/// These functions are used to allow for Airport name lookup for FareQuest
/// Air (flight) searches
///------------------------------------------------------------------------


//Delegate to handle the Airports Validatation Airport Lookup Completion
function IATAACValidateAirportsComplete(results)
{
    //TODO:
    //if more than 1 airport was returned then displays the airport clarification window
    if(results.length != 1)
    {
        //mark as an autoClarication window pop-up;
        IATAACValidateAirportAutoPop = true;
        //open the lookup window
        AirportMFShowLookupWindow(IATAACValidateAirportControl);
        //open the "All Airports" window
        AirportMFDisplaySearchBox('INT');
        //set the airport keyword;
        document.getElementById("AirportMFIntCityKeyword").value = IATAACValidateAirportKeyword;
        //begin the search
        OnIntStatesChange(document.getElementById('AirportMFIntCityKeyword'),document.getElementById('AirportMFIntCityKeyword').value);
        
    }
    else
    {
        IATAACValidateAirportControl.value = results[0];
        //since the validation completed, attempt to validate remaining
        IATAACValidateAirports();
    }
    
}


//Delegate to handle the Airports Validation Airport Lookup Error
function IATAACValidateAirportsError(results)
{
    alert("An Error has happened. Please try again later");
}


//function to handle the Airports FROM field validation
function IATAACValidateAirportsFrom()
{
    var FromField = document.getElementById("FromField").value;
    IATAACValidateAirportControl = document.getElementById("FromField");
    IATAACValidateAirportKeyword = FromField;
    
    //if the webservice is already activated
    if(FASTWebService != null)
        {
            //call the webservice
            FASTWebService.GetAirportsStartingWith(FromField,1000,IATAACValidateAirportsComplete,IATAACValidateAirportsError);
        }
        
    //finished with FROM field, call validate function for the TO field
    //IATAACValidateAirports()
}

//function to handle the Airports To field validation
function IATAACValidateAirportsTo()
{
    var ToField = document.getElementById("ToField").value;
    IATAACValidateAirportControl = document.getElementById("ToField");
    IATAACValidateAirportKeyword = ToField;
    
    //if the webservice is already activated
    if(FASTWebService != null)
        {
            //call the webservice
            FASTWebService.GetAirportsStartingWith(ToField,1000,IATAACValidateAirportsComplete,IATAACValidateAirportsError);
        }
}


//used to validate that all airports are in exact format before validating
//used by the validateForm() function
function IATAACValidateAirports()
{
    //validate the from airport
    var FromField = document.getElementById("FromField").value;
    var ToField = document.getElementById("ToField").value;
    var BeginAirportSearch = true;
    
    //if FROM Field not an airport IATA Code, then locate airlines 
    if(IATAACIsValidAirport(FromField) == false)
    {
        BeginAirportSearch = false;
        IATAACValidateAirportsFrom();
        return;
    }
    
     //if TO Field not an airport an IATA Code, then locate airlines 
    if(IATAACIsValidAirport(ToField) == false)
    {
        BeginAirportSearch = false;
        IATAACValidateAirportsTo();
        return;
    }
    
    //decide whether to search
    if(BeginAirportSearch == true)
    {
        //validate the form for searching
        validateForm();
    }
}



///************************************************************************
/// END Airport name lookup functions
///------------------------------------------------------------------------

//retrieves the IATA Airport Codes that match the search keyword
//keyword must match either the city or airport name to return results
function IATAACFindAirports(strKeyword,intResultCont)
{
    //attempt to retrieve the results
    try
    {
        if(FASTWebService != null)
        {
            //call the webservice
            FASTWebService.GetAirportsStartingWith(strKeyword,intResultCont,IATAACOnComplete,IATAACOnError);
            //if no errors happened, then set the error property to false;
            IATAACWebserviceFailed = false;
        }
        else
        {
            //webservice was not intialized, so set error property
            IATAACWebserviceFailed = true;
        }
    }
    catch(e)
    {
        //error of some type happened, so set the error property
        IATAACWebserviceFailed = true;
        //alert the error message
        window.status = e.message;
    }
    finally
    {
        //do any code cleanup here
        //alert("Code cleaned up");
    }
}





// ------------- Global IATA Airport Code AutoComplete Event Handlers ---------


//delegate that handles the webservice's onComplete event
function IATAACOnComplete(result)
{
    //clear out the last filtered airports
    filteredAirports = new Array();
    directMatch = null;
    
    //save the search results;
    IATAACAirportResults = result;
    
//    alert(result);
//    alert(IATAACWebServiceFilter);
    
    if(!IATAACWebServiceFilter)
    {
        //remove all the airport fields
        IATAACAirportResults = new Array();
        
        //filter the airports
        IATAACFilterAirports();
    }
}


//delegate that handles the webservice's onError event
function IATAACOnError(result)
{
    //for now simply display the error
    Alert("Error happened" + result);
}


//delegate that handles the quick search form textbox onFocus event
function IATAACOnFocus(refControl)
{
    //delete all results cache
    IATAACAirportResults = new Array();
    directMatch = null;
    
    //delete the filtered results
    filteredAirports = new Array();
    
    //let the application know that the focus has changed
    //so do not filter the previous results, incase the webservice
    //has still not returned
    IATAACWebServiceFilter = false;
    
    //set the control being used
    IATAACTargetControl = refControl;
    
    //hide any previous displays
    IATAACDisplayHideResults();
}


//delegate that handles the quick search form textbox onKeyUp event
function IATAACOnKeyUp(refControl)
{
    //allow the webservice to filter
    IATAACWebServiceFilter = true;
    
    if(refControl != null)
    {
        //set the control being used
        IATAACTargetControl = refControl;
        
        //call the webservice
        window.status = IATAACCanCall(refControl);
        if(IATAACCanCall(refControl) == true)
        {
            IATAACFindAirports(refControl.value,1000);
        }
        else if(IATAACCanFilter(refControl))
        {
            //filter the airports
            IATAACFilterAirports();
        }
    }
}

/***********************************************************************
/** BEGIN OLD FASHION AIRPORT LOOKUP
/**********************************************************************/

//delegate that handles the results being submitted
function IATAAConSubmitComplete(result)
{
    alert(result);
}

//delegate that handles the results being submitted
function IATAAConSubmitError(result)
{
    alert(result);
}

//delegate that handles the submit airport lookup on cityname entry
function IATAACOnSubmitLookUp(refControl)
{
    //set the control being used
    IATAACTargetControl = refControl;
}

 
/***********************************************************************
/** END OLD FASHION AIRPORT LOOKUP
/**********************************************************************/


//delegate that handles the quick search form textbox onBlur event
function IATAACOnBlur(refControl)
{
    //the person has tabbed out, attempt to filter
    IATAACFilterAirports();
    

     if(filteredAirports != null
    && filteredAirports.length > 0
    && refControl.value.indexOf("[") < 0)
    {
        if(directMatch != null)
        {
            refControl.value = directMatch;
        }
        else
        {
            refControl.value = filteredAirports[0];
        }
        
        //change to white background, reset error
        refControl.style.backgroundColor = "white";
        refControl.style.color = "#000000";
    }
    //no results and airport not found
    //alert the user that the airport is wrong
    else
    {
        if(IATAACIsValidAirport(refControl.value) == false)
        {
            refControl.style.backgroundColor = "#ff3333";
            refControl.style.color = "#ffffff";
        }
        else
        {
            refControl.style.backgroundColor = "white";
            refControl.style.color = "#000000";
        }
    }
    
    //display select items
    IATAACDisplayShowSelects();
    
    //hide loading image
    IATAACDisplayHideResults()
    
    //reset all fields
    IATAACOnLeaveDateFocus(null);
}


//delete that handles the selection of found airports
function IATAACOnSelectAirport(airportInfo)
{
    IATAACActiveControl().value = airportInfo;
    //hide the results
    IATAACDisplayHideResults();
    //reactive the display fields
    IATAACDisplayShowSelects();
}


//delegate that handles leave date onFocu event
function IATAACOnLeaveDateFocus(refControl)
{
    //reset all the variables
    IATAACDisplayHideResults();
    IATAACDisplayShowSelects();
    IATAACTargetControl = null;  //The control that is currently active
    IATAACAirportResults = new Array(); //The retrieved results from the last webservice call
    IATAACWebserviceFailed = false;   //If the webservice failed the last call
    IATAACWebServiceFilter = false;   //if the webservice oncomplete should filter
    directMatch = null;  //any airport that is an exact match on the Airport code
    filteredAirports = new Array();  //holds all the airports that match the filtering text
    
}















/* ------------------------------------------------------------------------
---------------------------------------------------------------------------
--------------------  Manual Airport Lookup Plugin ------------------------
--------------------  Coder: Abbey Gwayambadde     ------------------------
--------------------  Date: Nov, 28 2006           ------------------------
--------------------  Copyright: nPorta 2006       ------------------------
---------------------------------------------------------------------------
-------------------------------------------------------------------------*/





// -------------- Global Manual Airport variables -------------- 
var AirportMFLastControl = null;
var AirportMFTargetControl = null;

// -------------- Global Manual Airport Functions -------------- 


//format airport display information
function AirportMFFormatText(myAirport)
{
    var stringOut = "";
    if(myAirport.State != "")
    {
        stringOut = myAirport.City + ', ' + myAirport.State + ' - ' + myAirport.Name + ' - [' + myAirport.Code + ']';
    }
    else
    {
        stringOut = myAirport.Country + ' - ' + myAirport.City + ' - ' + myAirport.Name + ' - [' + myAirport.Code + ']';
    }
    
    return stringOut;
}

//selects the selected airport
function AirportMFSelectAirport(airportName)
{
    if(AirportMFTargetControl != null)
    {
        AirportMFTargetControl.value = airportName;
    }
    //hide the search window
    AirportMFHideLookupWindow()
    
    //if the window was automatically opened by validation scripts
    //then attempt to search again
    if(IATAACValidateAirportAutoPop == true)
    {
        IATAACValidateAirports();
        //reset the autopop
        IATAACValidateAirportAutoPop = false;
    }
}


//Shows the manual airport lookup window
function AirportMFShowLookupWindow(refControl)
{
    AirportMFTargetControl = refControl;
    //show the main display object
    AirportMFGetDisplayElement().style.display = "block";
    
    //default to US Search
    AirportMFDisplaySearchBox("USA");
    
}

//Hides the manual airport lookup window
function AirportMFHideLookupWindow()
{
    AirportMFGetDisplayElement().style.display = "none";
}

//returns access to the display div for all airports
function AirportMFGetDisplayElement()
{
    return document.getElementById("AirportsMFdiv");
}

//displays the processing graphics
function AirportMFShowLoading()
{
    //state dropdown used
    if(AirportMFLastControl.id == "AirportMFUSStatesDropdown")
    {
        strHtml = "<center><br/><br/>Searching for Airports<br/><img src=\"images/loading.gif\" alt=\"Locating Airports\"></center>";
        AirportMFGetUSListDiv().innerHTML = strHtml;
    }
    
    //internation search
     if(AirportMFLastControl.id == "AirportMFIntCityKeyword")
    {
        strHtml = "<center><br/><br/>Searching for Airports<br/><img src=\"images/loading.gif\" alt=\"Locating Airports\"></center>";
        AirportMFGetIntListDiv().innerHTML = strHtml;
    }
}


 //display the USA Airports display Div
function AirportMFDisplaySearchBox(strBox)
{
    //display the selected window
    if(strBox == "USA")
    {
        //select the initial item
        document.getElementById("AirportMFUSStatesDropdown")[0].selected = true;
    
        //display and remove all content
        AirportMFGetUSDisplayElement().style.display = "block";
        AirportMFGetUSListDiv().innerHTML = "";
        
        //create the prompt text
        var usatext = document.createElement("DIV");
        usatext.setAttribute("id","AirportMFUSAirportsTextDiv");
        usatext.innerHTML = "Select a state from the dropdown above and the airports will populate below.";
        document.getElementById("AirportMFUSAirportsList").appendChild(usatext);
        
        
        //hide the international lookup
        AirportMFIntDisplayElement().style.display = "none";
    }
    
    if(strBox == "INT")
    {
        //display and remove all content
        AirportMFIntDisplayElement().style.display = "block";
        AirportMFGetIntListDiv().innerHTML = "";
        
        //create the prompt text
        var inttext = document.createElement("DIV");
        inttext.setAttribute("id","AirportMFINTtextAirportsTextDiv");
        inttext.innerHTML = "Please enter the airport name above and any found airports shall be listed below.";
        document.getElementById("AirportMFIntAirportsList").appendChild(inttext);
        
        //hide the USA lookup
        AirportMFGetUSDisplayElement().style.display = "none";
    }
}

//sorts the Airports based on the Airport name
function AirportMFSortAirportsByName(a,b)
{
    if(a.City != b.City)
    {
        return a.City > b.City ? 1 : -1
    }
    else
    {
        return 0;
    }
}



// ------- International Airport Functions -----------

//returns access to the international airports display div
function AirportMFIntDisplayElement()
{
    return document.getElementById("AirportMFIntDiv");
}

//returns access to the in Airports listing div
function AirportMFGetIntListDiv()
{
    return document.getElementById("AirportMFIntAirportsList");
}



// -------------- USA Airport Functions --------------

//returns access to the USA Airports Display Div
function AirportMFGetUSDisplayElement()
{
    return document.getElementById("AirportMFUSDiv");
}

//returns access to the USA airports display div
function AirportMFGetUSListDiv()
{
    return document.getElementById("AirportMFUSAirportsList");
}


// -------------- US Airports States List Event handlers --------------

function OnUSAirportsComplete(result)
{
    AirportMFGetUSListDiv().innerHTML = "";
    myAirports =  result;
    
    //sort the returned results
    myAirports.sort(AirportMFSortAirportsByName);
    
    //start creating the radio buttons
    var strLink = '';
    
    for(i=0; i < myAirports.length; i++)
    {
        //generate the radio button lists   
        strLink += '<input type=radio name=USAirportsButtons ';
        strLink += 'value="' + AirportMFFormatText(myAirports[i]) + '" ';
        strLink += 'onclick="AirportMFSelectAirport(this.value);return false;">';
        strLink += AirportMFFormatText(myAirports[i]);
        strLink += '<br/>'; 
    }
        //display the airport radio buttons
        AirportMFGetUSListDiv().innerHTML += strLink;
}

function OnError(result)
{
    alert(result);
}


//handles the onchange event for the state selection list
function OnUSStatesChange(controlRef,stateAbbrev)
{
    //mark the last control used
    AirportMFLastControl = controlRef;
    
    
    //attempt to retrieve the state airports
    try
    {
        AirportMFShowLoading();
        FASTWebService.FindAirportsByState(stateAbbrev, OnUSAirportsComplete,OnError);
    }
    catch(e)
    {
        alert(e);
    }
    finally
    {
    }
}










// -------------- Int Airports States List Event handlers --------------

function OnIntAirportsComplete(result)
{
    AirportMFGetIntListDiv().innerHTML = "";
    myAirports =  result;
    
    //sort the returned results
    myAirports.sort(AirportMFSortAirportsByName);
    
    //display the message here if the auto clarification control is populated:
    if(IATAACValidateAirportControl != null)
    {
        var inttext = document.createElement("DIV");
        inttext.setAttribute("id","AirportMFINTtextAirportsTextDiv");
        if(result.length > 0)
        {
            inttext.innerHTML = "We found more than one airport for your entry. Please select an airport from the list below.";
        }
        else
        {
            inttext.innerHTML = "We did not find any airports matching your keyword. Please try an alternate spelling of the keyword or a different keyword.";
        }
        document.getElementById("AirportMFIntAirportsList").appendChild(inttext);
    }
        
    
    //start creating the radio buttons
    var strLink = '';
    
    for(i=0; i < myAirports.length; i++)
    {
        //generate the radio button lists   
        strLink += '<input type=radio name=INTAirportsButtons ';
        strLink += 'value="' + AirportMFFormatText(myAirports[i]) + '" ';
        strLink += 'onclick="AirportMFSelectAirport(this.value);return false;">';
        strLink += AirportMFFormatText(myAirports[i]);
        strLink += '<br/>'; 
    }
        //display the airport radio buttons
        AirportMFGetIntListDiv().innerHTML += strLink;
}

function OnError(result)
{
    alert(result);
}


//handles the onchange event for the state selection list
function OnIntStatesChange(controlRef,stateAbbrev)
{
    //mark the last control used
    AirportMFLastControl = controlRef;
    
    //attempt to retrieve the state airports
    try
    {
        AirportMFShowLoading();
        FASTWebService.FindAirportsStartingWith(stateAbbrev,1000,OnIntAirportsComplete,OnError);
        //FASTWebService.FindAirportsByState(stateAbbrev, OnIntAirportsComplete,OnError);
    }
    catch(e)
    {
        alert(e);
    }
    finally
    {
    }
}





///These methods are used for crossbrowser compatibility:
///They are not part of the AutoComplete nor the plugin
//used if the user clicks anywhere else
<!--
function CaptureClick(z)
{
    //hide the airports
    if(IATAACTargetControl != null || AirportMFGetDisplayElement().style.display == "block")
    {
        if(AirportMFGetDisplayElement().style.display != "block")
        {
            //hide the Airport Lookup
            AirportMFHideLookupWindow();
        }
        
        //hide the autocomplete results
        IATAACDisplayHideResults();
    }
}
 
 
//captures mouseup events
if (document.layers)
{
    document.captureEvents(Event.MOUSEUP);
}

//trap all the mouseup event for Firefox
//and pass them over to the delegate
document.onmouseup = CaptureClick;
// -->
