/*******************************************************

HISTORY: 

July-26-2010: initial code for IE 6 campatibility by David. 
July-29-2010: IE 6+ compatible.

AutoSuggest - a javascript automatic text input completion component
Copyright (C) 2005 Joe Kepley, The Sling & Rock Design Group, Inc.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*******************************************************

Please send any useful modifications or improvements via 
email to joekepley at yahoo (dot) com

*******************************************************/

/********************************************************
 The AutoSuggest class binds to a text input field
 and creates an automatic suggestion dropdown in the style
 of the "IntelliSense" and "AutoComplete" features of some
 desktop apps. 
 Parameters: 
 elem: A DOM element for an INPUT TYPE="text" form field
 suggestions: an array of strings to be used as suggestions
              when someone's typing.

 Example usage: 
 
 Please enter the name of a fruit.
 <input type="text" id="fruit" name="fruit" />
 <script language="Javascript">
 var fruits=new Array("apple","orange","grape","kiwi","cumquat","banana");
 new AutoSuggest(document.getElementById("fruit",fruits));
 </script>

 Requirements: 

 Unfortunately the AutoSuggest class doesn't seem to work 
 well with dynamically-created DIVs. So, somewhere in your 
 HTML, you'll need to add this: 
 <div id="autosuggest"><ul></ul></div>

 Here's a default set of style rules that you'll also want to 
 add to your CSS: 

 .suggestion_list
 {
 background: white;
 border: 1px solid;
 padding: 4px;
 }

 .suggestion_list ul
 {
 padding: 0;
 margin: 0;
 list-style-type: none;
 }

 .suggestion_list a
 {
 text-decoration: none;
 color: navy;
 }

 .suggestion_list .selected
 {
 background: navy;
 color: white;
 }

 .suggestion_list .selected a
 {
 color: white;
 }

 #autosuggest
 {
 display: none;
 }
*********************************************************/
function populateCities(c)
{
c.add("ABZ", "GB", "", "Aberdeen, Dyce", false);
c.add("ABJ", "CI", "", "Abidjan", false);
c.add("BQN", "PR", "", "Aguadilla, Rafael Hernandez", true);
c.add("ALB", "US", "NY", "Albany", true);
c.add("ABQ", "US", "NM", "Albuquerque, Albuquerque Int'l", true);
c.add("ALG", "DZ", "", "Algiers, Houari Boumedienne ", false);
c.add("ALC", "ES", "", "Alicante", false);
c.add("ABE", "US", "PA", "Allentown/Bethlehem", true);
c.add("AMM", "JO", "", "Amman, Queen Alia Int'l ", false);
c.add("AMS", "NL", "", "Amsterdam, Amsterdam-Schiphol ", false);
c.add("ANC", "US", "AK", "Anchorage, Ted Stevens Anchorage Int'l ", true);
c.add("ANU", "AG", "", "Antigua, V. C. Bird Intl ", false, "");
c.add("AUA", "AW", "", "Aruba, Reina Beatrix", false, "");
c.add("ATH", "GR", "", "Athens, E. Venizelos", false);
c.add("ATL", "US", "GA", "Atlanta, Hartsfield-Jackson Atlanta Int'l ", true);
c.add("AKL", "NZ", "", "Auckland", false);
c.add("AUS", "US", "TX", "Austin, Austin-Bergstrom Int'l ", true);
c.add("YBG", "CA", "QC", "Bagotville", true);
c.add("YBC", "CA", "QC", "Baie Comeau", true);
c.add("BWI", "US", "MD", "Baltimore, International Thurgood Marshall Airport", true);
c.add("BLR", "IN", "", "Bengaluru", false);
c.add("BKK", "TH", "", "Bangkok, Suvarnabhumi Int'l ", false);
c.add("BCN", "ES", "", "Barcelona", false);
c.add("BSL", "CH", "", "Basel, EuroAirport Basel Mulhouse-Freiburg", false);
c.add("ZBF", "CA", "NB", "Bathurst, Bathurst Regional", true);
c.add("PEK", "CN", "", "Beijing", false);
c.add("BHD", "GB", "", "Belfast", false);
c.add("BEG", "RS", "", "Belgrade", false);
c.add("TXL", "DE", "", "Berlin, Tegel", false);
c.add("BDA", "BM", "", "Bermuda", false);
c.add("BIO", "ES", "", "Bilbao", false);
c.add("BIL", "US", "MT", "Billings", true);
c.add("BHM", "US", "AL", "Birmingham", true);
c.add("BOG", "CO", "", "Bogota, Eldorado", false);
c.add("BOI", "US", "ID", "Boise, Boise Air Term. (Gowen Field)", true);
c.add("BOS", "US", "MA", "Boston, Logan Int'l ", true);
c.add("BRE", "DE", "", "Bremen", false);
c.add("BGI", "BB", "", "Bridgetown, Grantley Adams Int'l ", false);
c.add("BRU", "BE", "", "Brussels, Luchthaven Brussel", false);
c.add("OTP", "RO", "", "Bucharest, Henri Coanda Int'l ", false);
c.add("BUD", "HU", "", "Budapest, Ferihegy", false);
c.add("EZE", "AR", "", "Buenos Aires, Ministro Pistarini", false);
c.add("BUF", "US", "NY", "Buffalo, Buffalo Niagara Int'l ", true);
c.add("BUR", "US", "CA", "Burbank, Bob Hope ", true);
c.add("BTV", "US", "VT", "Burlington", true);
c.add("YYC", "CA", "AB", "Calgary", true);
c.add("CLO", "CO", "", "Cali, Alfonso B. Aragon", false);
c.add("YBL", "CA", "BC", "Campbell River", true);
c.add("CUN", "MX", "", "Cancun", false, "");
c.add("CCS", "VE", "", "Caracas, Simon Bolivar  Int'l", false);
c.add("CTG", "CO", "", "Cartagena, Rafael Nunez", false);
c.add("YCG", "CA", "BC", "Castlegar", true);
c.add("CTA", "IT", "", "Catania, Fontanarossa", false);
c.add("CCC", "CU", "", "Cayo Coco", false, "");
c.add("CYO", "CU", "", "Cayo Largo del Sur", false, "");
c.add("CID", "US", "IA", "Cedar Rapids", true);
c.add("CHS", "US", "SC", "Charleston, Charleston Int'l", true);
c.add("CLT", "US", "NC", "Charlotte, Charlotte Douglas ", true);
c.add("YYG", "CA", "PE", "Charlottetown", true);
c.add("YMT", "CA", "QC", "Chibougamau", true);
c.add("ORD", "US", "IL", "Chicago, O'Hare Int'l", true);
c.add("CHC", "NZ", "", "Christchurch", false);
c.add("CVG", "US", "OH", "Cincinnati/Northern Kentucky", true);
c.add("CLE", "US", "OH", "Cleveland, Hopkins Int'l", true);
c.add("CGN", "DE", "", "Cologne, Cologne Bonn ", false);
c.add("COS", "US", "CO", "Colorado Springs", true);
c.add("CAE", "US", "SC", "Columbia", true);
c.add("CMH", "US", "OH", "Columbus, Port Columbus Int'l ", true);
c.add("YQQ", "CA", "BC", "Comox, Comox Valley Airport", true);
c.add("CPH", "DK", "", "Copenhagen", false);
c.add("CZM", "MX", "", "Cozumel", false);
c.add("YXC", "CA", "BC", "Cranbrook", true);
c.add("DFW", "US", "TX", "Dallas, Dallas Ft Worth", true);
c.add("DMM", "SA", "", "Dammam, King Fahd International Airport", false);
c.add("DAY", "US", "OH", "Dayton, James Cox Dayton Int'l", true);
c.add("YDF", "CA", "NL", "Deer Lake", true);
c.add("DEL", "IN", "", "Delhi, Indira Gandhi Int'l", false);
c.add("DEN", "US", "CO", "Denver", true);
c.add("DSM", "US", "IA", "Des Moines", true);
c.add("DTW", "US", "MI", "Detroit, Detroit Metropolitan Wayne County ", true);
c.add("DLA", "CM", "", "Douala", false);
c.add("DRS", "DE", "", "Dresden", false);
c.add("DXB", "AE", "", "Dubai", false);
c.add("DUB", "IE", "", "Dublin", false);
c.add("DUS", "DE", "", "D黶seldorf", false);
c.add("EDI", "GB", "", "Edinburgh", false);
c.add("YEG", "CA", "AB", "Edmonton", true);
c.add("EUG", "US", "OR", "Eugene", true);
c.add("FDF", "MQ", "", "Fort De France, Lamentin Airport", false);
c.add("FLL", "US", "FL", "Fort Lauderdale", true);
c.add("YMM", "CA", "AB", "Fort McMurray", true);
c.add("RSW", "US", "FL", "Fort Myers, Southwest Florida Int'l", true);
c.add("YXJ", "CA", "BC", "Fort St John", true);
c.add("FRA", "DE", "", "Frankfurt", false);
c.add("YFC", "CA", "NB", "Fredericton", true);
c.add("FAT", "US", "CA", "Fresno", true);
c.add("FUK", "JP", "", "Fukuoka", false);
c.add("YQX", "CA", "NL", "Gander", true);
c.add("YGP", "CA", "QC", "Gaspe", true);
c.add("GDN", "PL", "", "Gdansk, Rebiechowo", false);
c.add("GVA", "CH", "", "Geneva, Geneve-Cointrin ", false);
c.add("GGT", "BS", "", "George Town, Exuma Int'l", false);
c.add("GLA", "GB", "", "Glasgow", false);
c.add("YYR", "CA", "NL", "Goose Bay", true);
c.add("GOT", "SE", "", "Gothenburg, G鰐eborg-Landvetter", false);
c.add("GCM", "KY", "", "Grand Cayman, Owen Roberts Int'l", false);
c.add("GRR", "US", "MI", "Grand Rapids, Gerald R. Ford Int'l Airport", true);
c.add("YQU", "CA", "AB", "Grande Prairie", true);
c.add("GRZ", "AT", "", "Graz, Thalerhof", false);
c.add("GSO", "US", "NC", "Greensboro/High Point, Piedmont Triad Int'l", true);
c.add("GSP", "US", "SC", "Greenville", true);
c.add("GND", "GD", "", "Grenada, Point Saline Int'l ", false);
c.add("YHZ", "CA", "NS", "Halifax", true);
c.add("HAM", "DE", "", "Hamburg, Fuhlsbuettel", false);
c.add("HAJ", "DE", "", "Hannover", false);
c.add("MDT", "US", "PA", "Harrisburg", true);
c.add("BDL", "US", "CT", "Hartford, Bradley Int'l ", true);
c.add("HAV", "CU", "", "Havana, Jose Marti Int'l ", false);
c.add("HEL", "FI", "", "Helsinki, Helsinki-Vantaa ", false);
c.add("SGN", "VN", "", "Ho Chi Minh City, Tan Son Nhat Int'l", false);
c.add("HOG", "CU", "", "Holguin, Frank Pais", false);
c.add("HKG", "HK", "", "Hong Kong", false);
c.add("IAH", "US", "TX", "Houston, G.Bush Intercon", true);
c.add("YGR", "CA", "QC", "Iles de la Madeleine", true);
c.add("IND", "US", "IN", "Indianapolis", true);
c.add("INN", "AT", "", "Innsbruck, Kranebitten", false);
c.add("INV", "GB", "", "Inverness", false);
c.add("YFB", "CA", "NU", "Iqaluit", true);
c.add("ZIH", "MX", "", "Ixtapa/Zihuatanejo", false);
c.add("JAX", "US", "FL", "Jacksonville", true);
c.add("CGK", "ID", "", "Jakarta, Soekarno-Hatta Int'l", false);
c.add("JER", "GB", "", "Jersey", false);
c.add("YKA", "CA", "BC", "Kamloops", true);
c.add("MCI", "US", "MO", "Kansas City", true);
c.add("YLW", "CA", "BC", "Kelowna", true);
c.add("KBP", "UA", "", "Kiev, Borispol ", false);
c.add("YGK", "CA", "ON", "Kingston", true);
c.add("KIN", "JM", "", "Kingston", false);
c.add("KLU", "AT", "", "Klagenfurt, Alpe Adria ", false);
c.add("TYS", "US", "TN", "Knoxville", true);
c.add("KOA", "US", "HI", "Kona/Kailua, Keahole", true);
c.add("KRK", "PL", "", "Krakow, J. Paul II  Balice Int'l ", false);
c.add("KUL", "MY", "", "Kuala Lumpur", false);
c.add("SUF", "IT", "", "Lamezia Terme, S Eufemia", false);
c.add("LRM", "DO", "", "La Romana, Casa de Campo International", false);
c.add("LAS", "US", "NV", "Las Vegas, Mc Carran Int'l", true);
c.add("LBA", "GB", "", "Leeds, Leeds/Bradford ", false);
c.add("LEJ", "DE", "", "Leipzig, Halle", false);
c.add("YQL", "CA", "AB", "Lethbridge", true);
c.add("LIR", "CR", "", "Liberia", false);
c.add("LIM", "PE", "", "Lima, Jorge Chavez Int'l", false);
c.add("LNZ", "AT", "", "Linz, Blue Danube ", false);
c.add("PNQ", "IN", "", "Lohegaon, Poona", false);
c.add("SDF", "US", "KY", "Louisville", true);
c.add("LHR", "GB", "", "London, Heathrow", false);
c.add("YXU", "CA", "ON", "London, London Ontario Airport", true);
c.add("LAX", "US", "CA", "Los Angeles", true);
c.add("MAD", "ES", "", "Madrid, Barajas ", false);
c.add("MGA", "NI", "", "Managua, Augusto C Sandino", false);
c.add("MAN", "GB", "", "Manchester", false);
c.add("MHT", "US", "NH", "Manchester", true);
c.add("OGG", "US", "HI", "Maui/Kahului", true);
c.add("MDE", "CO", "", "Medellin, Jose Maria Cordova", false);
c.add("YXH", "CA", "AB", "Medicine Hat", true);
c.add("MEM", "US", "TN", "Memphis", true);
c.add("MEX", "MX", "", "Mexico City, Benito Juarez", false);
c.add("MIA", "US", "FL", "Miami", true);
c.add("MXP", "IT", "", "Milan, Malpensa", false);
c.add("MKE", "US", "WI", "Milwaukee, General Mitchell Int'l", true);
c.add("MSP", "US", "MN", "Minneapolis, St. Paul Int'l", true);
c.add("YQM", "CA", "NB", "Moncton", true);
c.add("YYY", "CA", "QC", "Mont Joli", true);
c.add("MBJ", "JM", "", "Montego Bay, Sangster Int'l", false);
c.add("MRY", "US", "CA", "Monterey", true);
c.add("YUL", "CA", "QC", "Montreal, P. -E.-Trudeau Int'l", true);
c.add("DME", "RU", "", "Moscow, Domodedovo", false);
c.add("BOM", "IN", "", "Mumbai, Chhatrapati Shivaji Int'l ", false);
c.add("MUC", "DE", "", "Munich, Franz Josef Strauss ", false);
c.add("NGO", "JP", "", "Nagoya, Centrair (Central Japan Int'l)", false);
c.add("YCD", "CA", "BC", "Nanaimo", true);
c.add("BNA", "US", "TN", "Nashville", true);
c.add("NAS", "BS", "", "Nassau", false);
c.add("MSY", "US", "LA", "New Orleans", true);
c.add("LGA", "US", "NY", "New York, LaGuardia", true);
c.add("EWR", "US", "NJ", "New York, Newark", true);
c.add("HPN", "US", "NY", "New York, Westchester County", true);
c.add("ORF", "US", "VA", "Norfolk", true);
c.add("YYB", "CA", "ON", "North Bay", true);
c.add("NUE", "DE", "", "Nuremberg", false);
c.add("HNL", "US", "HI", "Oahu/Honolulu", true);
c.add("OAK", "US", "CA", "Oakland, Metropolitan Oak Int'l", true);
c.add("OKA", "JP", "", "Okinawa, Naha", false);
c.add("OKC", "US", "OK", "Oklahoma City, Will Rogers World", true);
c.add("OMA", "US", "NE", "Omaha, Eppley Airfield", true);
c.add("ONT", "US", "CA", "Ontario", true);
c.add("MCO", "US", "FL", "Orlando", true);
c.add("ITM", "JP", "", "Osaka, Itami Int'l", false);
c.add("KIX", "JP", "", "Osaka, Kansai Int'l", false);
c.add("OSL", "NO", "", "Oslo", false);
c.add("YOW", "CA", "ON", "Ottawa", true);
c.add("PMO", "IT", "", "Palermo, Punta Raisi", false);
c.add("PSP", "US", "CA", "Palm Springs", true);
c.add("PMI", "ES", "", "Palma, Palma Mallorca", false);
c.add("CDG", "FR", "", "Paris, Charles De Gaulle", false);
c.add("ORY", "FR", "", "Paris, Orly", false);
c.add("YYF", "CA", "BC", "Penticton", true);
c.add("PHL", "US", "PA", "Philadelphia", true);
c.add("PHX", "US", "AZ", "Phoenix, Sky Harbor Int'l", true);
c.add("PIT", "US", "PA", "Pittsburgh", true);
c.add("PTP", "GP", "", "Pointe-?Pitre, Pole Caraibes", false);
c.add("PAP", "HT", "", "Port Au Prince, Mais Gate", false);
c.add("PDX", "US", "OR", "Portland", true);
c.add("PWM", "US", "ME", "Portland", true);
c.add("POA", "BR", "", "Porto Alegre", false);
c.add("POZ", "PL", "", "Poznan", false);
c.add("PRG", "CZ", "", "Prague, Ruzyne", false);
c.add("YXS", "CA", "BC", "Prince George", true);
c.add("YPR", "CA", "BC", "Prince Rupert, Digby Island", true);
c.add("PVD", "US", "RI", "Providence, Theodore Francis", true);
c.add("PLS", "TC", "", "Providenciales", false);
c.add("POP", "DO", "", "Puerto Plata, La Union", false);
c.add("PVR", "MX", "", "Puerto Vallarta, Ordaz", false);
c.add("PUJ", "DO", "", "Punta Cana", false);
c.add("YQB", "CA", "QC", "Quebec City, Jean Lesage Int'l", true);
c.add("YQZ", "CA", "BC", "Quesnel", true);
c.add("RDU", "US", "NC", "Raleigh/Durham", true);
c.add("YRT", "CA", "NU", "Rankin Inlet", true);
c.add("YQR", "CA", "SK", "Regina", true);
c.add("RNO", "US", "NV", "Reno, Tahoe Int'l", true);
c.add("RIC", "US", "VA", "Richmond", true);
c.add("GIG", "BR", "", "Rio de Janeiro", false);
c.add("ROA", "US", "VA", "Roanoke ", true);
c.add("ROC", "US", "NY", "Rochester, Monroe County", true);
c.add("FCO", "IT", "", "Rome, Leonardo da Vinci Int'l (Fiumicino)", false);
c.add("YUY", "CA", "QC", "Rouyn-Noranda", true);
c.add("SMF", "US", "CA", "Sacramento", true);
c.add("YSJ", "CA", "NB", "Saint John", true);
c.add("SLC", "US", "UT", "Salt Lake City", true);
c.add("SSA", "BR", "", "Salvador", false);
c.add("SZG", "AT", "", "Salzburg, W.A. Mozart", false);
c.add("AZS", "DO", "", "Saman?El Catey Int'l", false);
c.add("SAT", "US", "TX", "San Antonio", true);
c.add("SAN", "US", "CA", "San Diego, Lindbergh Field S. Diego", true);
c.add("SFO", "US", "CA", "San Francisco", true);
c.add("SJC", "US", "CA", "San Jose, Mineta San Jose Int'l", true);
c.add("SJO", "CR", "", "San Jos? Juan Santamar韆 Int'l", false);
c.add("SJD", "MX", "", "San Jose Del Cabo, Los Cabos Int'l", false);
c.add("SJU", "PR", "", "San Juan, Luis Munoz Marin Int'l", false);
c.add("SAL", "SV", "", "San Salvador, Comalapa Int'l", false);
c.add("YZP", "CA", "BC", "Sandspit", true);
c.add("SNA", "US", "CA", "Orange County", true);
c.add("SBA", "US", "CA", "Santa Barbara", true);
c.add("SNU", "CU", "", "Santa Clara", false);
c.add("SCL", "CL", "", "Santiago, Arturo Merino Benitez", false);
c.add("GRU", "BR", "", "Sao Paulo, Guarulhos Int'l", false);
c.add("CTS", "JP", "", "Sapporo, New Chitose Airport", false);
c.add("SRQ", "US", "FL", "Sarasota", true);
c.add("YZR", "CA", "ON", "Sarnia", true);
c.add("YXE", "CA", "SK", "Saskatoon, J.G. Diefenbaker Int'l", true);
c.add("YAM", "CA", "ON", "Sault Ste. Marie", true);
c.add("SAV", "US", "GA", "Savannah", true);
c.add("SEA", "US", "WA", "Seattle, Seattle/Tacoma Int'l", true);
c.add("ICN", "KR", "", "Seoul, Incheon Int'l", false);
c.add("YZV", "CA", "QC", "Sept-蝜es", true);
c.add("PVG", "CN", "", "Shanghai, Pu Dong", false);
c.add("SIN", "SG", "", "Singapore, Changi", false);
c.add("YYD", "CA", "BC", "Smithers", true);
c.add("GEG", "US", "WA", "Spokane", true);
c.add("YYT", "CA", "NL", "St John's", true);
c.add("STL", "US", "MO", "St Louis, Lambert-St Louis Int'l", true);
c.add("UVF", "LC", "", "St Lucia, Hewanorra Int'l", false);
c.add("SXM", "AN", "", "St Maarten, Princess Juliana Int'l", false);
c.add("LED", "RU", "", "St Petersburg, Pulkovo", false);
c.add("STT", "VI", "", "St Thomas, Cyril E King", true);
c.add("SVG", "NO", "", "Stavanger, Sola", false);
c.add("ARN", "SE", "", "Stockholm, Arlanda", false);
c.add("STR", "DE", "", "Stuttgart, Echterdingen", false);
c.add("YSB", "CA", "ON", "Sudbury", true);
c.add("YQY", "CA", "NS", "Sydney", true);
c.add("SYD", "AU", "", "Sydney, Kingsford Smith", false);
c.add("SYR", "US", "NY", "Syracuse, Hancock Int'l", true);
c.add("TPE", "TW", "", "Taipei, Taiwan Taoyuan Intl.", false);
c.add("TPA", "US", "FL", "Tampa", true);
c.add("MME", "GB", "", "Teesside, Durham Tees Valley", false);
c.add("TLV", "IL", "", "Tel Aviv, Ben Gurion Int'l", false);
c.add("YXT", "CA", "BC", "Terrace", true);
c.add("YQT", "CA", "ON", "Thunder Bay", true);
c.add("YTS", "CA", "ON", "Timmins", true);
c.add("NRT", "JP", "", "Tokyo, Narita", false);
c.add("YYZ", "CA", "ON", "Toronto, Pearson Int'l", true);
c.add("TUS", "US", "AZ", "Tucson", true);
c.add("TUL", "US", "OK", "Tulsa", true);
c.add("TRN", "IT", "", "Turin", false);
c.add("YVO", "CA", "QC", "Val d'Or", true);
c.add("VLC", "ES", "", "Valencia", false);
c.add("YVR", "CA", "BC", "Vancouver", true);
c.add("VRA", "CU", "", "Varadero, Juan Gualberto Gomez", false);
c.add("VCE", "IT", "", "Venice, Marco Polo", false);
c.add("YYJ", "CA", "BC", "Victoria", true);
c.add("VIE", "AT", "", "Vienna, Schwechat Intl.", false);
c.add("VSA", "MX", "", "Villahermosa", false);
c.add("YWK", "CA", "NL", "Wabush", true);
c.add("WAW", "PL", "", "Warsaw, F. Chopin", false);
c.add("IAD", "US", "DC", "Washington, Dulles", true);
c.add("DCA", "US", "DC", "Washington, R.Reagan National", true);
c.add("WLG", "NZ", "", "Wellington", false);
c.add("PBI", "US", "FL", "West Palm Beach", true);
c.add("YXY", "CA", "YT", "Whitehorse", true);
c.add("ICT", "US", "KS", "Wichita, Mid-Continent", true);
c.add("YWL", "CA", "BC", "Williams Lake", true);
c.add("YQG", "CA", "ON", "Windsor", true);
c.add("YWG", "CA", "MB", "Winnipeg", true);
c.add("WRO", "PL", "", "Wroclaw, Strachowice", false);
c.add("YZF", "CA", "NT", "Yellowknife", true);
c.add("ZAG", "HR", "", "Zagreb", false);
c.add("ZRH", "CH", "", "Zurich, Flughafen Z黵ich-Kloten", false);

c.add("MEL", "AU", "", "Melbourne", false);
c.add("BNE", "AU", "", "Brisbane", false);
c.add("ADL", "AU", "", "Adelaide", false);
c.add("PER", "AU", "", "Perth", false);
c.add("CNS", "AU", "", "Cairns", false);
c.add("HBA", "AU", "", "Hobart", false);
c.add("ABX", "AU", "", "Albury", false);
c.add("ARM", "AU", "", "Armidale", false);
c.add("AYQ", "AU", "", "Ayers Rock", false);
c.add("CFS", "AU", "", "Coffs Harbour", false);
c.add("DRW", "AU", "", "Darwin", false);
c.add("DBO", "AU", "", "Dubbo", false);
c.add("OOL", "AU", "", "Gold Coast", false);
c.add("MRZ", "AU", "", "Moree", false);
c.add("NTL", "AU", "", "Newcastle", false);
c.add("PQQ", "AU", "", "Port Macquarie", false);
c.add("TMW", "AU", "", "Tamworth", false);
c.add("WGA", "AU", "", "WaggaWagga", false);

c.add("AAL", "DK", "", "Aalborg", false);
c.add("AUH", "AE", "", "Abu Dhabi", false);
c.add("BAH", "BH", "", "Bahrain", false);
c.add("BEY", "LB", "", "Beirut", false);
c.add("CAI", "EG", "", "Cairo", false);
c.add("CCU", "IN", "", "Kolkata", false);
c.add("CGQ", "CN", "", "Changchun", false);
c.add("CMN", "MA", "", "Casablanca", false);
c.add("CPT", "ZA", "", "Cape Town", false);
c.add("DOH", "QA", "", "Doha", false);
c.add("ESB", "TR", "", "Ankara", false);
c.add("FMO", "DE", "", "Muenster", false);
c.add("HYD", "IN", "", "Hyderabad", false);
c.add("IST", "TR", "", "Istanbul", false);
c.add("JNB", "ZA", "", "Johannesburg", false);
c.add("KWI", "KW", "", "Kuwait City", false);
c.add("LIS", "PT", "", "Lisbon", false);
c.add("LOS", "NG", "", "Lagos", false);
c.add("LYS", "FR", "", "Lyon", false);
c.add("MAA", "IN", "", "Chennai", false);
c.add("MNL", "PH", "", "Manila", false);
c.add("MRS", "FR", "", "Marseille", false);
c.add("NBO", "KE", "", "Nairobi", false);
c.add("NCE", "FR", "", "Nice", false);
c.add("NCL", "UK", "", "Newcastle", false);
c.add("OPO", "PT", "", "Oporto", false);
c.add("SOF", "BG", "", "Sofia", false);

c.add("ACA", "MX", "", "Acapulco", false);
c.add("ADD", "ET", "", "Addis Abeba", false);
c.add("ASP", "AU", "", "Alice Springs", false);
c.add("ALP", "SY", "", "Aleppo", false);
c.add("ALA", "KZ", "", "Almaty", false);
c.add("ACC", "GH", "", "Accra", false);
c.add("AOI", "IT", "", "Ancona", false);
c.add("GYD", "AZ", "", "Baku", false);
c.add("BRI", "IT", "", "Bari", false);
c.add("BAQ", "CO", "", "Barranquilla", false);
c.add("BGO", "NO", "", "Bergen", false);
c.add("BRN", "CH", "", "Berne", false);
c.add("BLL", "DK", "", "Billund", false);
c.add("FRU", "KG", "", "Bishkek", false);
c.add("BLQ", "IT", "", "Bologna", false);
c.add("BOD", "FR", "", "Bordeaux", false);
c.add("BTS", "SK", "", "Bratislava", false);
c.add("BES", "FR", "", "Brest", false);
c.add("BGA", "CO", "", "Bucaramanga", false);
c.add("BJM", "BI", "", "Bujumbura", false);
c.add("CBR", "AU", "", "Canberra", false);
c.add("CTU", "CN", "", "Chengdu", false);
c.add("CKG", "CN", "", "Chongqing", false);
c.add("CKY", "GN", "", "Conakry", false);
c.add("DKR", "SN", "", "Dakar", false);
c.add("DAC", "BD", "", "Dhaka, Zia International Airport", false);
c.add("DLC", "CN", "", "Dalian", false);
c.add("DAM", "SY", "", "Damascus", false);
c.add("DAR", "TZ", "", "Dar Es Salaam", false);
c.add("DOK", "UA", "", "Donetsk", false);
c.add("DGO", "MX", "", "Durango, Guadalupe Victoria", false);
c.add("SVX", "RU", "", "Ekaterinburg", false);
c.add("EBB", "UG", "", "Entebbe", false);
c.add("FAO", "PT", "", "Faro", false);
c.add("FLR", "IT", "", "Florence", false);
c.add("FNA", "SL", "", "Freetown", false);
c.add("FDH", "DE", "", "Friedrichshafen", false);
c.add("FOC", "CN", "", "Fuzhou", false);
c.add("GOA", "IT", "", "Genoa", false);
c.add("GDL", "MX", "", "Guadalajara", false);
c.add("CAN", "CN", "", "Guangzhou", false);
c.add("GYE", "EC", "", "Guayaquil", false);
c.add("HGH", "CN", "", "Hangzhou", false);
c.add("HRB", "CN", "", "Harbin", false);
c.add("HOQ", "DE", "", "Hof", false);
c.add("HET", "CN", "", "Hohhot", false);
c.add("HUX", "MX", "", "Huatulco", false);
c.add("JED", "SA", "", "Jeddah", false);
c.add("KRT", "SD", "", "Khartoum", false);
c.add("FIH", "CD", "", "Kinshasa", false);
c.add("KMG", "CN", "", "Kunming", false);
c.add("LFW", "TG", "", "Lome", false);
c.add("LAD", "AO", "", "Luanda", false);
c.add("LUG", "CH", "", "Lugano/Agno", false);
c.add("LUX", "LU", "", "Luxembourg", false);
c.add("AGP", "ES", "", "Malaga", false);
c.add("MZT", "MX", "", "Mazatlan", false);
c.add("MID", "MX", "", "Merida", false);
c.add("LIN", "IT", "", "Milan, Linate", false);
c.add("MTY", "MX", "", "Monterrey", false);
c.add("MPL", "FR", "", "Montpellier", false);
c.add("SVO", "RU", "", "Moscow, Sheremetyevo", false);
c.add("MCT", "OM", "", "Muscat", false);
c.add("NKG", "CN", "", "Nanjing", false);
c.add("NTE", "FR", "", "Nantes", false);
c.add("NAP", "IT", "", "Naples", false);
c.add("OAX", "MX", "", "Oaxaca", false);
c.add("OUA", "BF", "", "Ouagadougou", false);
c.add("PAD", "DE", "", "Paderborn", false);
c.add("PTY", "PA", "", "Panama city, Tocumen International Airport", false);
c.add("PUF", "FR", "", "Pau", false);
c.add("PSA", "IT", "", "Pisa", false);
c.add("TAO", "CN", "", "Qingdao", false);
c.add("UIO", "EC", "", "Quito", false);
c.add("REG", "IT", "", "Reggio Calabria", false);
c.add("RUH", "SA", "", "Riyadh", false);
c.add("SHE", "CN", "", "Shenyang", false);
c.add("SZX", "CN", "", "Shenzhen", false);
c.add("SBZ", "RO", "", "Sibiu", false);
c.add("SXB", "FR", "", "Strasbourg", false);
c.add("TBS", "GE", "", "Tbilisi, Novo Alexeyevka", false);
c.add("IKA", "IR", "", "Tehran", false);
c.add("TIA", "AL", "", "Tirana", false);
c.add("TLS", "FR", "", "Toulouse", false);
c.add("TRS", "IT", "", "Trieste", false);
c.add("TUN", "TN", "", "Tunis", false);
c.add("VER", "MX", "", "Veracruz", false);
c.add("VRN", "IT", "", "Verona", false);
c.add("WNZ", "CN", "", "Wenzhou", false);
c.add("WUH", "CN", "", "Wuhan", false);
c.add("YNT", "CN", "", "Yantai", false);
c.add("EVN", "AM", "", "Yerevan", false);
c.add("XIY", "CN", "", "Xi'an", false);
c.add("XMN", "CN", "", "Xiamen", false);

c.add("HAN", "VN", "", "Hanoi, Noibai International", false);
c.add("HIJ", "JP", "", "Hiroshima International", false);
c.add("MYJ", "JP", "", "Matsuyama", false);
c.add("KMI", "JP", "", "Miyazaki", false);
c.add("PUS", "KR", "", "Busan, Gimhae", false);
c.add("TAK", "JP", "", "Takamatsu", false);

c.add("HSV", "US", "AL", "Huntsville", true);
c.add("MOB", "US", "AL", "Mobile", true);
c.add("LIT", "US", "AR", "Little Rock", true);
c.add("XNA", "US", "AR", "Fayetteville, Arkansas Airport", true);
c.add("PNS", "US", "FL", "Pensacola", true);
c.add("VPS", "US", "FL", "Walton Beach", true);
c.add("FWA", "US", "IN", "Fort Wayne", true);
c.add("SBN", "US", "IN", "South Bend", true);
c.add("MLU", "US", "LA", "Monroe", true);
c.add("SHV", "US", "LA", "Shreveport", true);
c.add("AEX", "US", "LA", "Alexandria", true);
c.add("BTR", "US", "LA", "Baton Rouge", true);
c.add("LCH", "US", "LA", "Lake Charles", true);
c.add("LFT", "US", "LA", "Lafayette", true);
c.add("FNT", "US", "MI", "Flint", true);
c.add("GPT", "US", "MS", "Gulfport", true);
c.add("JAN", "US", "MS", "Jackson", true);
c.add("AVL", "US", "NC", "Asheville", true);
c.add("JHW", "US", "NY", "Jamestown", true);
c.add("ITH", "US", "NY", "Ithaca Tompkins", true);
c.add("SYR", "US", "NY", "Syracuse", true);
c.add("BFD", "US", "PA", "Bradford", true);
c.add("FKL", "US", "PA", "Franklin", true);
c.add("AVP", "US", "PA", "Wilkes Barre", true);
c.add("DUJ", "US", "PA", "Dubois", true);
c.add("ERI", "US", "PA", "Erie", true);
c.add("MYR", "US", "SC", "Myrtle Beach", true);
c.add("AMA", "US", "TX", "Amarillo", true);
c.add("ELP", "US", "TX", "El Paso", true);
c.add("GRK", "US", "TX", "Ile Killeen, Gray Army Air Field", true);
c.add("MAF", "US", "TX", "Midland Odessa", true);
c.add("ACT", "US", "TX", "Waco", true);
c.add("BPT", "US", "TX", "Beamont", true);
c.add("BRO", "US", "TX", "Brownsville", true);
c.add("CLL", "US", "TX", "College Station", true);
c.add("CRP", "US", "TX", "Corpus Christi", true);
c.add("DRT", "US", "TX", "Del Rio", true);
c.add("SAT", "US", "TX", "San Antonio", true);
c.add("HRL", "US", "TX", "Harlingen", true);
c.add("LBB", "US", "TX", "Lubbock", true);
c.add("LRD", "US", "TX", "Laredo", true);
c.add("MFE", "US", "TX", "Mcallen", true);
c.add("TYR", "US", "TX", "Tyler", true);
c.add("VCT", "US", "TX", "Victoria", true);
c.add("STT", "VI", "", "St Thomas", false);
c.add("LWB", "US", "WV", "Lewisburg", true);
}


function CountryList()
{
this.countries =
{
AD:"Andorra",
AE:"United Arab Emirates",
AF:"Afghanistan",
AG:"Antigua and Barbuda",
AI:"Anguilla",
AL:"Albania",
AM:"Armenia",
AN:"Netherlands Antilles",
AO:"Angola",
AQ:"Antarctica",
AR:"Argentina",
AS:"American Samoa",
AT:"Austria",
AU:"Australia",
AW:"Aruba",
AZ:"Azerbaijan",
BA:"Bosnia-Herzegovina",
BB:"Barbados",
BD:"Bangladesh",
BE:"Belgium",
BF:"Burkina Faso",
BG:"Bulgaria",
BH:"Bahrain",
BI:"Burundi",
BJ:"Benin",
BM:"Bermuda",
BN:"Brunei",
BO:"Bolivia",
BR:"Brazil",
BS:"Bahamas",
BT:"Bhutan",
BV:"Bouvet Islands",
BW:"Botswana",
BY:"Belarus",
BZ:"Belize",
CA:"Canada",
CC:"Cocos (Keeling) Island",
CD:"Democratic Republic of Congo",
CF:"Central African Republic",
CG:"Congo",
CH:"Switzerland",
CI:"Ivory coast",
CK:"Cook Islands",
CL:"Chile",
CM:"Cameroon",
CN:"China",
CO:"Colombia",
CR:"Costa Rica",
CU:"Cuba",
CV:"Cape Verde",
CX:"Christmas Island (Indian Ocean)",
CY:"Cyprus",
CZ:"Czech Republic",
DE:"Germany",
DJ:"Djibouti",
DK:"Denmark",
DM:"Dominica",
DO:"Dominican Republic",
DZ:"Algeria",
EC:"Ecuador",
EE:"Estonia",
EG:"Egypt",
ER:"Eritrea",
ES:"Spain",
ET:"Ethiopia",
FI:"Finland",
FJ:"Fiji",
FK:"Falkland Islands",
FM:"Micronesia",
FO:"Faroe Islands",
FR:"France",
GA:"Gabon",
GB:"United Kingdom",
GD:"Grenada",
GE:"Georgia",
GF:"French Guyana",
GH:"Ghana",
GI:"Gibraltar",
GL:"Greenland",
GM:"Gambia",
GN:"Guinea",
GP:"Guadeloupe",
GQ:"Equatorial Guinea",
GR:"Greece",
GS:"South Georgia & Sandwich Islands",
GT:"Guatemala",
GU:"Guam",
GW:"Guinea Bissau",
GY:"Guyana",
HK:"Hong kong",
HM:"Heard And McDonald Islands",
HN:"Honduras",
HR:"Croatia",
HT:"Haiti",
HU:"Hungary",
ID:"Indonesia",
IE:"Ireland",
IL:"Israel",
IN:"India",
IO:"British Indian Ocean Territory",
IQ:"Iraq",
IR:"Islamic Republic Of Iran",
IS:"Iceland",
IT:"Italy",
JM:"Jamaica",
JO:"Jordan",
JP:"Japan",
KE:"Kenya",
KG:"Kyrgyzstan",
KH:"Cambodia",
KI:"Kiribati",
KM:"Comoros",
KN:"St. Kitts and Nevis",
KP:"Dem.People's Rep.(North Korea)",
KR:"Republic of Korea (South Korea)",
KW:"Kuwait",
KY:"Cayman Islands",
KZ:"Kazakhstan",
LA:"Laos",
LB:"Lebanon",
LC:"Saint Lucia",
LI:"Liechtenstein",
LK:"Sri Lanka",
LR:"Liberia",
LS:"Lesotho",
LT:"Lithuania",
LU:"Luxemburg",
LV:"Latvia",
LY:"Libya",
MA:"Morroco",
MC:"Monaco",
MD:"Moldova",
MG:"Madagascar",
MH:"Marshall Islands",
MK:"Macedonia",
ML:"Mali",
MM:"Myanmar",
MN:"Mongolia",
MO:"Macau",
MP:"Northern Mariana Islands",
MQ:"Martinique",
MR:"Mauritania",
MS:"Montserrat",
MT:"Malta",
MU:"Mauritius",
MV:"Maldives",
MW:"Malawi",
MX:"Mexico",
MY:"Malaysia",
MZ:"Mozambique",
NA:"Namibia",
NC:"New caledonia",
NE:"Niger",
NF:"Norfolk Island",
NG:"Nigeria",
NI:"Nicaragua",
NL:"Netherlands",
NO:"Norway",
NP:"Nepal",
NR:"Nauru",
NU:"Niue",
NZ:"New Zealand",
OM:"Oman",
PA:"Panama",
PE:"Peru",
PF:"French Polynesia",
PG:"Papua New Guinea",
PH:"Philippines",
PK:"Pakistan",
PL:"Poland",
PM:"St. Pierre and Miquelon",
PN:"Pitcairn Island",
PR:"Puerto Rico",
PT:"Portugal",
PW:"Palau",
PY:"Paraguay",
QA:"Qatar",
RE:"Reunion Island",
RO:"Romania",
RS:"Serbia",
RU:"Russia",
RW:"Rwanda",
SA:"Saudi Arabia",
SB:"Solomon Islands",
SC:"Seychelles",
SD:"Sudan",
SE:"Sweden",
SG:"Singapore",
SH:"St. Helena",
SI:"Slovenia",
SJ:"Svalbard & Jan Mayen Island",
SK:"Slovakia",
SL:"Sierra Leone",
SM:"San Marino",
SN:"Senegal",
SO:"Somalia",
SR:"Suriname",
ST:"Sao Tome and Principe",
SV:"El Salvador",
SY:"Syrian Arab Republic",
SZ:"Swaziland",
TC:"Turks And Caicos Islands",
TD:"Chad",
TF:"French Southern Territories",
TG:"Togo",
TH:"Thailand",
TJ:"Tajikistan",
TK:"Tokelau",
TM:"Turkmenistan",
TN:"Tunisia",
TO:"Tonga",
TP:"East Timor",
TR:"Turkey",
TT:"Trinidad And Tobago",
TV:"Tuvalu",
TW:"Taiwan",
TZ:"Tanzania",
UA:"Ukraine",
UG:"Uganda",
UK:"United Kingdom",
UM:"United States Minor Outlying Island",
US:"Usa",
UY:"Uruguay",
UZ:"Uzbekistan",
VA:"Vatican City State",
VC:"St. Vincent and the Grenadines",
VE:"Venezuela",
VG:"British Virgin Islands",
VI:"Us Virgin Islands",
VN:"Vietnam",
VU:"Vanuatu",
WS:"Samoa",
YT:"Mayotte",
ZA:"South Africa"

};
}


function StateList()
{
this.states =
{
AB:"Alberta",
AK:"Alaska",
AL:"Alabama",
AR:"Arkansas",
AZ:"Arizona",
BC:"British Columbia",
CA:"California",
CO:"Colorado",
CT:"Connecticut",
DC:"Washington, DC",
DE:"Delaware",
FL:"Florida",
GA:"Georgia",
HI:"Hawaii",
IA:"Iowa",
ID:"Idaho",
IL:"Illinois",
IN:"Indiana",
KS:"Kansas",
KY:"Kentucky",
LA:"Louisiana",
MA:"Massachusetts",
MB:"Manitoba",
MD:"Maryland",
ME:"Maine",
MI:"Michigan",
MN:"Minnesota",
MO:"Missouri",
MS:"Mississippi",
MT:"Montana",
NB:"New Brunswick",
NC:"North Carolina",
ND:"North Dakota",
NE:"Nebraska",
NH:"New Hampshire",
NJ:"New Jersey",
NL:"Newfoundland",
NM:"New Mexico",
NS:"Nova Scotia",
NT:"Northwest Territories",
NU:"Nunavut",
NV:"Nevada",
NY:"New York",
OH:"Ohio",
OK:"Oklahoma",
ON:"Ontario",
OR:"Oregon",
PA:"Pennsylvania",
PE:"Prince Edward Is.",
QC:"Quebec",
RI:"Rhode Island",
SC:"South Carolina",
SD:"South Dakota",
SK:"Saskatchewan",
TN:"Tennessee",
TX:"Texas",
UT:"Utah",
VA:"Virginia",
VT:"Vermont",
WA:"Washington",
WI:"Wisconsin",
WV:"West Virginia",
WY:"Wyoming",
YT:"Yukon"

};
}

// global variables 
var cityList = null;


function CityList()
{
	this.cities = new Array();
	this.countryList = new CountryList();
	this.stateList = new StateList();
    
	this.populate();
}

var cP = CityList.prototype;

cP.populate = function(){
    populateCities(this);
}

cP.add = function(ac,co,st,n,f,err,start,end){
    var airport = new Airport(ac,co,st,n,f,err,start,end);
	this.cities.push(airport);
}

function Airport(ac,co,st,n,f,err,start,end)
{
	this.aircode = ac;
	this.country = co;
	this.state = st;
	this.name = n;
	this.flag = f;
	this.cleanName = "";
	this.value = ac;
    this.errMsg = err;
	this.startDate = start;
	this.endDate = end;
}


function bindEvents()
{
	//Find all of the INPUT tags
	/*var tags = document.getElementsByTagName('INPUT');
	for (i in tags)
	{
		var tag = tags[i];
		//If it's a text tag, attach an AutoSuggest object.
		if(tag.type && tag.type.toLowerCase() == "text")
		{
			new AutoSuggest(tag,fruits);
		}
	}*/
   

	if (cityList == null){
       cityList = new CityList();
	}

	var tag = document.getElementById('air_b_location_id');	
	new AutoSuggest(tag, cityList);
    tag = document.getElementById('air_e_location_id');	
	new AutoSuggest(tag, cityList);
	tag = document.getElementById('car_b_location_id');	
	new AutoSuggest(tag, cityList);
	tag = document.getElementById('car_e_location_id');	
	new AutoSuggest(tag, cityList);

}


window.onload = bindEvents;


function AutoSuggest(elem, cityList)
{

	//The 'me' variable allow you to access the AutoSuggest object
	//from the elem's event handlers defined below.
	var me = this;

    this.cities = cityList.cities;
	this.countries = cityList.countryList.countries;

    this.states = cityList.stateList.states;

	//A reference to the element we're binding the list to.
	this.elem = elem;

	this.suggestions = "";

	//Arrow to store a subset of eligible suggestions that match the user's input
	this.eligible = new Array();
	

	//The text input by the user.
	this.inputText = null;

	//A pointer to the index of the highlighted eligible item. -1 means nothing highlighted.
	this.highlighted = -1;

	//A div to use to create the dropdown.
	this.div = document.getElementById("autosuggest");


	//Do you want to remember what keycode means what? Me neither.
	var TAB = 9;
	var ESC = 27;
	var KEYUP = 38;
	var KEYDN = 40;
    var ENTER = 13;


	//The browsers' own autocomplete feature can be problematic, since it will 
	//be making suggestions from the users' past input.
	//Setting this attribute should turn it off.
	elem.setAttribute("autocomplete","off");

	//We need to be able to reference the elem by id. If it doesn't have an id, set one.
	if(!elem.id)
	{
		var id = "autosuggest" + idCounter;
		idCounter++;

		elem.id = id;
	}
    elem.onblur = function(ev)
	{
	   me.useSuggestion();
       me.hideDiv();
	}

	/********************************************************
	onkeydown event handler for the input elem.
	Tab key = use the highlighted suggestion, if there is one.
	Esc key = get rid of the autosuggest dropdown
	Up/down arrows = Move the highlight up and down in the suggestions.
	********************************************************/
	elem.onkeydown = function(ev)
	{
		var key = me.getKeyCode(ev);

		switch(key)
		{
			case TAB:
			me.useSuggestion();
			break;

			case ESC:
			me.hideDiv();
			break;

			case KEYUP:
			if (me.highlighted > 0)
			{
				me.highlighted--;
			}
			me.changeHighlight(key);
			break;

			case KEYDN:
			if (me.highlighted < (me.eligible.length - 1))
			{
				me.highlighted++;
			}
			me.changeHighlight(key);
			break;
			
			case ENTER:
			me.useSuggestion();
			me.hideDiv();
			me.cancelEvent(ev);
			return false;
			break;
		}
	};

	/********************************************************
	onkeyup handler for the elem
	If the text is of sufficient length, and has been changed, 
	then display a list of eligible suggestions.
	********************************************************/
	elem.onkeyup = function(ev) 
	{
		var key = me.getKeyCode(ev);
		switch(key)
		{
		//The control keys were already handled by onkeydown, so do nothing.
		case TAB:
		case ESC:
		case KEYUP:
		case KEYDN:
		case ENTER:
			return;
		default:

			if (this.value != me.inputText && this.value.length > 0)
			{
				me.inputText = this.value;
				me.getEligible();
				me.createDiv();
				me.positionDiv();
				me.showDiv();
			}
			else
			{
				me.hideDiv();
			}
		}
	};


	/********************************************************
	Insert the highlighted suggestion into the input box, and 
	remove the suggestion dropdown.
	********************************************************/
	this.useSuggestion = function()
	{
		if (this.highlighted > -1)
		{
			this.elem.value = this.eligible[this.highlighted].aircode;
			this.hideDiv();
			//It's impossible to cancel the Tab key's default behavior. 
			//So this undoes it by moving the focus back to our field right after
			//the event completes.
			setTimeout("document.getElementById('" + this.elem.id + "').focus()",0);
		}
	};

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function checkVersion()
{
  //var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver == 6.0 ) 
      return true;
	else
	  return false;
    
  }
  else{
	  return false;
  }
}
	/********************************************************
	Display the dropdown. Pretty straightforward.
	********************************************************/
	this.showDiv = function()
	{
		this.div.style.display = 'block';

		// for IE 6, hidden select box

		//Find all of the INPUT tags
		//var isMSIE = /*@cc_on!@*/false;
		var isMSIE = checkVersion(); 
		if (isMSIE != false)
        {
	      /*var tags = document.getElementsByTagName('select');
	      for (i in tags)
	      {
		    var tag = tags[i];
		    //If it's a text tag, attach an AutoSuggest object.
		    if(tag.style != null)
			  tag.style.visibility = 'hidden';
		  }*/
		  $('iframe.ui-autosuggest-cover').remove();
		  $('#autosuggest').prepend('<iframe src="javascript:false;" class="ui-autosuggest-cover" frameborder="0" width="300" height="200"></iframe>');
		  $('iframe.ui-autosuggest-cover').height(this.eligible.length * 25+8);
		}
        

	};

	/********************************************************
	Hide the dropdown and clear any highlight.
	********************************************************/
	this.hideDiv = function()
	{
		this.div.style.display = 'none';
		this.highlighted = -1;
        // for IE 6
		//var isMSIE = /*@cc_on!@*/false;
		var isMSIE = checkVersion();
		if (isMSIE != false)
        {
		  //Find all of the INPUT tags
	      /*var tags = document.getElementsByTagName('select');
	      for (i in tags)
	      {
		    var tag = tags[i];
		    //If it's a text tag, attach an AutoSuggest object.
		    if(tag.style != null){
			  tag.style.visibility = 'visible';
		    }
		  }*/
          $('iframe.ui-autosuggest-cover').remove();
		}
   
	};

	/********************************************************
	Modify the HTML in the dropdown to move the highlight.
	********************************************************/
	this.changeHighlight = function()
	{
		var lis = this.div.getElementsByTagName('LI');
		for (i in lis)
		{
			var li = lis[i];

			if (this.highlighted == i)
			{
				li.className = "selected";
			}
			else
			{
				li.className = "";
			}
		}
	};

	/********************************************************
	Position the dropdown div below the input text field.
	********************************************************/
	this.positionDiv = function()
	{
		var el = this.elem;
		var x = 0;
		var y = el.offsetHeight;
	
		//Walk up the DOM and add up all of the offset positions.
		while (el.offsetParent && el.tagName.toUpperCase() != 'BODY')
		{
			x += el.offsetLeft;
			y += el.offsetTop;
			el = el.offsetParent;
		}

		x += el.offsetLeft;
		y += el.offsetTop;

		this.div.style.left = x + 'px';
		this.div.style.top = y + 'px';
	};

	/********************************************************
	Build the HTML for the dropdown div
	********************************************************/
	this.createDiv = function()
	{
		var i;
		var ul = document.createElement('ul');
	
		//Create an array of LI's for the words.
		for (i=0; i < this.eligible.length; i++)
		{

			var state ="";
			if (this.eligible[i].state != "")
			{
               state = this.states[this.eligible[i].state]
			}
			var word;
			if(state == "")
			  word = this.eligible[i].aircode + " | " + this.eligible[i].name + ', ' + this.countries[this.eligible[i].country];
			else
              word = this.eligible[i].aircode + " | " + this.eligible[i].name + ', ' + state +', ' + this.countries[this.eligible[i].country];
	
			var li = document.createElement('li');
			var a = document.createElement('a');
			a.href="javascript:false";
			a.innerHTML = word;
			li.appendChild(a);
	
			if (me.highlighted == i)
			{
				li.className = "selected";
			}
	
			ul.appendChild(li);
		}
		// for IE 6
	    $('iframe.ui-autosuggest-cover').remove();
		this.div.replaceChild(ul,this.div.childNodes[0]);
	

		/********************************************************
		mouseover handler for the dropdown ul
		move the highlighted suggestion with the mouse
		********************************************************/
		ul.onmouseover = function(ev)
		{
			//Walk up from target until you find the LI.
			var target = me.getEventSource(ev);
			while (target.parentNode && target.tagName.toUpperCase() != 'LI')
			{
				target = target.parentNode;
			}
		
			var lis = me.div.getElementsByTagName('LI');
			
	
			for (i in lis)
			{
				var li = lis[i];
				if(li == target)
				{
					me.highlighted = i;
					break;
				}
			}
			me.changeHighlight();
		};

		/********************************************************
		click handler for the dropdown ul
		insert the clicked suggestion into the input
		********************************************************/
		ul.onclick = function(ev)
		{
			me.useSuggestion();
			me.hideDiv();
			me.cancelEvent(ev);
			return false;
		};
	
		this.div.className="suggestion_list";
		this.div.style.position = 'absolute';



	};

	/********************************************************
	determine which of the suggestions matches the input
	********************************************************/
	this.getEligible = function()
	{
		if(this.inputText.length >= "3"){
		  this.eligible = new Array();
		  for (i in this.cities)
		  {
			var suggestion = this.cities[i].name;
			var airport = this.cities[i];
			var str = "\\b"+this.inputText.toLowerCase();
			
			var pattern = new RegExp(str);
            if(suggestion != null){  // for IE 7 and 8
				var tmp = suggestion.toLowerCase().match(pattern);
				if( tmp != null)
				{
					//alert(airport);
					this.eligible[this.eligible.length] = airport;
				}
			}
		  }
		}
	};

	/********************************************************
	Helper function to determine the keycode pressed in a 
	browser-independent manner.
	********************************************************/
	this.getKeyCode = function(ev)
	{
		if(ev)			//Moz
		{
			return ev.keyCode;
		}
		if(window.event)	//IE
		{
			return window.event.keyCode;
		}
	};

	/********************************************************
	Helper function to determine the event source element in a 
	browser-independent manner.
	********************************************************/
	this.getEventSource = function(ev)
	{
		if(ev)			//Moz
		{
			return ev.target;
		}
	
		if(window.event)	//IE
		{
			return window.event.srcElement;
		}
	};

	/********************************************************
	Helper function to cancel an event in a 
	browser-independent manner.
	(Returning false helps too).
	********************************************************/
	this.cancelEvent = function(ev)
	{
		if(ev)			//Moz
		{
			ev.preventDefault();
			ev.stopPropagation();
		}
		if(window.event)	//IE
		{
			window.event.returnValue = false;
		}
	}
}

//counter to help create unique ID's
var idCounter = 0;

