var custom_array = ['Abadan,ABD-Iran-Abadan',
'Abidjan,ABJ-Cote D Ivoi-Felix Houphouet Boigny',
'Abu Dhabi,AUH-United Arab-Abu Dhabi International',
'Abuja,ABV-Nigeria-International',
'Acapulco,ACA-Mexico-General Juan N. Alvarez International',
'Accra,ACC-Ghana-Kotoka',
'Addis Ababa,ADD-Ethiopia-Bole',
'Adelaide International,ADL-Australia-Adelaide',
'Aden,ADE-Yemen-International',
'Al Ain,AAN-United-Arab-Al Ain',
'Algiers,ALG-Algeria-Houari Boumediene',
'Alice Springs,ASP-Australia-Alice Springs',
'Almaty,ALA-Kazakhstan-Almaty',
'Amman,AMM-Jordan-Queen Alia Intl',
'Amsterdam,AMS-Netherland-Amsterdam Schiphol',
'Anchorage,ANC-USA-Ted-Stevens Anchorage Intl',
'Ankara,ANK-Turkey-Etimesgut',
'Antananarivo,TNR-Madagascar-Antananarivo',
'Antigua,ANU-Antigua-An V. C. Bird Intl',
'Antofagasta,ANF-Chile-Cerro Moreno',
'Ashgabat,ASB-Turkmenistan-Ashgabat',
'Asmara,ASM-Eritrea-Asmara International',
'Asuncion,ASU-Paraguay-Silvio Pettirossi',
'Aswan,ASW-Egypt-Aswan',
'Athens,ATH-Greece-Eleftherios Venizelos',
'ATLANTA,ATL-USA-Hartsfield Jackson Atlanta International',
'Auckland,AKL-New Zealand-Auckland International',
'Baghdad,BGW-Iraq-Al Muthana',
'Baghdad,SDA-Iraq-Baghdad International',
'Baku,BAK-Azerbaijan-Heydar Aliyev International',
'BALTIMORE,BWI-USA-Baltimore/Washington International Thurgood Marshall Ai',
'Bamako,BKO-Mali-Bamako',
'Bandar Seri Begawan,BWN-Brunei-Dar Brunei International',
'Bangkok,BKK-Thailand-Suvarnabhumi International',
'Bangui,BGF-Central African Republic-Bangui',
'Banjul,BJL-Gambia-Yundum International',
'Barcelona,BCN-Spain El Prat De Llobregat',
'Barranquilla,BAQ-Colombia-E Cortissoz',
'Basra,BSR-Iraq-International',
'Beijing,PEK-China-Capital',
'Beira,BEW-Mozambique-Beira',
'Beirut,BEY-Lebanon-Beirut Rafic Hariri International Airport',
'Belfast,BFS-UK-Belfast International Airport',
'Belgrade,BEG-Serbia And Nikola-Tesla',
'Belize City,BZE-Belize-Philip S.W.Goldson Int',
'Belmopan,BCV-Belize-Belmopan',
'Bergen,BGO-Norway-Bergen Airport Flesland',
'Berlin,BER-Germany-Berlin Metropolitan Area',
'Berlin,SXF-Germany-Schoenefeld',
'Berlin,TXL-Germany-Berlin tegel/Otto Lilienthal',
'Berlin,THF-Germany-Tempelhof',
'Bermuda,BDA-Bermuda-Bermuda International',
'Berne,BRN-Switzerland-Belp',
'Birmingham,BHX-UK-Birmingham International Airport',
'Bishkek,FRU-Kyrgyzstan-Manas [Bishkek]',
'Blantyre,BLZ-Malawi-Chileka',
'Bogota,BOG-Colombia-Eldorado',
'Bordeaux,BOD-France-Bordeaux Airport',
'BOSTON,BOS-USA-Logan International',
'Brasilia,BSB-Brazil-Presidente Juscelino Kubitschek',
'Bratislava,BTS-Slovakia M R tenika',
'Brazzaville,BZV-Congo-Maya Maya',
'Bridgetown,BGI-Barbados-Grantley Adams International',
'Brisbane,BNE-Australia-Brisbane International',
'Brussels,BRU-Belgium-Brussels Airport',
'Bucharest,OTP-Romania-Henri Coanda International',
'Budapest,BUD-Hungary-Ferihegy',
'Buenos Aires,AEP-Argentina-Arpt. Jorge Newbery',
'Buenos Aires,EZE-Argentina-Ezeiza Ministro Pistarini',
'Bujumbura,BJM-Burundi-International',
'Buochs,BXO-Guinea-BisBuochs',
'Busan,PUS-Korea-SouGimhae',
'Cairns,CNS-Australia-Cairns',
'Cairo,CAI-Egypt-Cairo International',
'Calgary,YYC-Canada-Calgary International Airport',
'Campinas (sao Paulo),VCP-Brazil-Intl. Airpt. Viracopos',
'Canberra,CBR-Australia-Canberra',
'Cape-Town,CPT-South Africa-Cape Town International',
'Casablanca,CAS-Morocco-Anfa',
'Casablanca,CMN-Morocco-Mohamed V',
'Cayenne,CAY-French-Gui Rochambeau',
'Cebu,CEB-Philippines-Mactan International',
'Charlotte Amalie St Th,STT-Virgin Island-Cyril E King',
'Chicago,CHI-USA-Chicago FSS',
'Chicago,MDW-USA-Midway',
'CHICAGO,ORD-USA-O Hare International',
'Chisinau,KIV-Moldova-Chisinau',
'Christchurch,CHC-New Zealand-Christchurch International',
'Cleveland,CLE-USA-Hopkins International',
'Cologne,CGN-Germany-Cologne/bonn',
'Colombo,CMB-Sri Lanka-Bandaranayake',
'Columbus,CMH-USA-Port Columbus Intl',
'Conakry,CKY-Guinea-Conakry',
'Copenhagen,CPH-Denmark-Copenhagen Airport Kastrup',
'Cordoba,COR-Argentina-Pajas Blancas',
'Cotonou,COO-Benin-Cotonou',
'Curacao,CUR-Netherland-Hato International Airport',
'Dakar,DKR-Senegal-Yoff',
'Dallas,DFW-USA-Dallas/ft Worth Intl',
'Damascus,DAM-Syria-International',
'Dammam,DMM-Saudi Arab-King Fahd International Airport',
'Dammam,DMS-Saudi Arab-DAMMAM',
'Dar Es Salaam,DAR-Tanzania-International',
'Darwin,DRW-Australia-Darwin',
'Denpasar Bali,DPS-Indonesia-Ngurah Rai International',
'Denver,DEN-USA-Denver International',
'Detroit MI,DTW-USA-Detroit Metropolitan Wayne County',
'Dhaka,DAC-Bangladesh-Zia International',
'Dili,DIL-East Timor-Presidente Nicolau Lobato International Airport',
'Djibouti,JIB-Djibouti-Ambouli',
'Dodoma,DOD-Tanzania-Dodoma',
'Doha,DOH-Qatar-Doha',
'Douala,DLA-Cameroon-Douala',
'Dubai,DXB-United Arab Emirates-Dubai',
'Dublin,DUB-Ireland-Dublin',
'DULLES,IAD-USA-Washington Dulles International',
'Durban,DUR-South Africa-Durban International',
'Dushanbe,DYU-Tajikistan-Dushanbe',
'Dusseldorf,DUS-Germany-Dusseldorf International Airport [Rhein-Ruhr]',
'Edinburgh,EDI-UK-Turnhouse',
'Edmonton,YEG-Canada-Edmonton International',
'Entebbe,EBB-Uganda-Entebbe',
'Fairbanks,FAI-USA-Fairbanks International Airport',
'Fort De France,FDF-Martinique-Lamentin',
'Frankfurt,FRA-Germany-Rhein Main International',
'Freeport,FPO-Bahamas-Grand Bahama International',
'Freetown,FNA-Sierra-LeonLungi International',
'Gaborone,GBE-Botswana-Sir Seretse Khama International',
'Gainesville,GNV-USA-Gainesville Regional',
'Geneva,GVA-Switzerland-Geneve Cointrin',
'Genova,GOA-Italy-Cristoforo Colombo',
'Georgetown,GCM-Cayman Is-Owen Roberts International',
'Georgetown,GEO-Guyana-Cheddi Jagan International',
'Gibraltar,GIB-Gibraltar-North Front',
'Glasgow,GLA-UK-Glasgow International',
'Gothenburg,GOT-Sweden-Landvetter',
'Guadalajara,GDL-Mexico-Miguel Hidalgo International Airport',
'Guangzhou,CAN-China-New Baiyun',
'Guarulhos,GRU-Brazil-Guarulhos International Airport',
'Guatemala City,GUA-Guatemala-La Aurora',
'Guayaquil,GYE-Ecuador-Simon Bolivar',
'Gudja,MLA-Malta-Malta International',
'Halifax,YHZ-Canada-Halifax International',
'Hamburg,HAM-Germany-Hamburg',
'Hanoi,HAN-Viet Nam-Noibai International',
'Hanover,HAJ-Germany-Hannover',
'Harare,HRE-Zimbabwe-Harare',
'Havana,HAV-Cuba-Jose Marti Intl',
'Ho Chi Minh City,SGN-Viet Nam-Tan Son Nhat International',
'Hobart,HBA-Australia-Hobart',
'Hong Kong,HKG-China-Hong Kong International',
'Honolulu,HNL-USA-Honolulu International',
'Houston,IAH-USA-George Bush Intercontinental',
'Houston,HOU-USA-Hobby',
'Islamabad,ISB-Pakistan-Islamabad International',
'Istanbul,IST-Turkey-Ataturk',
'Jakarta,JKT-Indonesia-Soekarno hatta Intl',
'Jakarta,CGK-Indonesia-Soekarno Hatta International',
'Jeddah,JED-Saudi Arab-King Abdulaziz International',
'Jerusalem,JRS-Israel-Jerusalem',
'Johannesburg,JNB-South Africa-Johannesburg International',
'Kabul,KBL-AfghanistanKhwaja Rawash',
'Kano,KAN-Nigeria-Aminu Kano Intl Apt',
'Kansas City,MCI-USA-Kansas City International Airport',
'Karachi,KHI-Pakistan-Quaid E Azam Intl',
'Kathmandu,KTM-Nepal-Tribhuvan',
'Khartoum,KRT-Sudan-Civil',
'Kiev,KBP-Ukraine-Borispol',
'Kiev,IEV-Ukraine-Zhulhany',
'Kigali,KGL-Rwanda-Gregoire Kayibanda',
'Kingston,KIN-Jamaica-Norman Manley',
'Kinshasa,FIH-DR Congos- N Djili Airport',
'Knoxville,TYS-USA-Mc Ghee Tyson',
'Kuala Lumpur,KUL-Malaysia-Kuala Lumpur International Airport [klia]',
'Kuwait City,KWI-Kuwait-Kuwait International',
'La Paz,LPB-Bolivia-El Alto',
'Lagos,LOS-Nigeria-Murtala Muhammed',
'Lahore,LHE-Pakistan-Alama Iqbal International',
'Larnaca,LCA-Cyprus-Larnaca International Airport',
'Las Palmas,LPA-Spain-Gran Canaria',
'Las Vegas,LAS-USA-Mc Carran Intl',
'Libreville,LBV-Gabon-Libreville',
'Lilongwe,LLW-Malawi-Lilongwe International',
'Lima,LIM-Peru-Jorge Chavez International',
'Lisbon,LIS-Portugal-Portela',
'Ljubljana,LJU-Slovenia-Brnik',
'Lome,LFW-Togo-Lome',
'London,LGW-UK-Gatwick',
'London,LHR-UK-Heathrow',
'London,LCY-UK-London City Airport',
'London,LTN-UK-Luton Airport',
'London,STN-UK-Stansted',
'LOS ANGELES,LAX-USA-Los Angeles International',
'Luanda,LAD-Angola-4 de Fevereiro',
'Lubumbashi,FBM-Zaire-Luano',
'Lusaka,LUN-Zambia-Lusaka',
'Luxembourg,LUX-Luxembourg-Findel',
'Luxor,LXR-Egypt-Luxor',
'Lyon,LYS-France-Lyon Saint Exupéry',
'Macau,MFM-Macau-Macau',
'Madrid,MAD-Spain-Barajas',
'Mahe Island,SEZ-Seychelles-Seychelles International Airport',
'Maiquetia,CCS-Venezuela-Simon Bolivar International',
'Malabo,SSG-Equatorial-Santa Isabel',
'Malaga,AGP-Spain-Malaga',
'Male,MLE-Maldives-Male International',
'Managua,MGA-Nicaragua-Augusto C Sandino',
'Manama,BAH-Bahrain-Bahrain International',
'Manaus,MAO-Brazil-Eduardo Gomes Intl',
'Manchester,MAN-UK-Manchester',
'Manila,MNL-Philippines-Ninoy Aquino Intl',
'Maputo,MPM-Mozambique-Maputo International',
'Maracaibo,MAR-Venezuela-La Chinita',
'Marseille,MRS-France-Marseille Provence Airport',
'Maseru,MSU-Lesotho-Moshoeshoe Intl',
'Medan,MES-Indonesia-Polonia',
'Medellin,MDE-Colombia-Jose Maria Cordova',
'Melbourne,MEL-Australia-Tullamarine',
'Mexico City,MEX-Mexico-Benito Juarez International Airport',
'MIAMI,MIA-USA-Miami International Airport',
'Milan,LIN-Italy-Linate',
'Milan,MXP-Italy-Malpensa',
'Minneapolis,MSP-USA-Minneapolis-St. Paul Intl',
'Minsk,MSQ-Belarus-Minsk International',
'Mogadishu,MGQ-Somalia-International',
'Mombasa,MBA-Kenya-Moi International',
'Monrovia,MLW-Liberia-Sprigg Payne',
'Montego Bay,MBJ-Jamaica-Sangster International',
'Monterrey,MTY-Mexico-Gen Mariano Escobedo',
'Montevideo,MVD-Uruguay-Carrasco International',
'Montreal,YMX-Canada-Mirabel',
'Montreal,YUL-Canada-Pierre Elliott Trudeau International Airport',
'Moroni,YVA-Comoros-Iconi',
'Moscow,MOW-Russian-FeMOSCOW',
'Moscow,DME-Russian-FeDomodedovo',
'Moscow,SVO-Russian-FeSheremetyevo',
'Munich,MUC-Germany-Franz Josef Strauss',
'Muscat,MCT-Oman-Seeb',
'Nagoya,NGO-Japan-Central Japan International',
'Nairobi,NBO-Kenya-Jomo Kenyatta International',
'Naples,NAP-Italy-Capodichino',
'Nassau,NAS-Bahamas-Nassau International',
'Ndjamena,NDJ-Chad-Ndjamena',
'Ndola,NLA-Zambia-Ndola',
'Nevis,NEV-Saint Kitts-Newcastle',
'New Orleans,MSY-USA-Louis Armstrong New Orleans International Airport',
'NEW YORK,JFK-USA-John F Kennedy Intl',
'New York,LGA-USA-La Guardia',
'NEWARK,EWR-USA-Newark Liberty International',
'Newcastle,BEO-Australia-Belmont',
'Newcastle,NTL-Australia-Williamtown',
'Newcastle,NCS-South Africa-Newcastle',
'Newcastle,NCL-UK-Newcastle Airport',
'Newcastle,ECS-USA-Mondell',
'Niamey,NIM-Niger-Niamey',
'Nice,NCE-France-Cote Dazur International Airport',
'Nicosia,NIC-Cyprus-Nicosia International',
'Nouakchott,NKC-Mauritania-Nouakchott',
'Nuremberg,NUE-Germany-Nuremberg',
'Oran,ORN-Algeria-Es Senia',
'Osaka,KIX-Japan-Kansai International',
'Oslo,OSL-Norway-Oslo Airport Gardermoen',
'Ottawa,YOW-Canada-Ottawa International',
'Ouagadougou,OUA-Burkina-Fa Ouagadougou',
'Palermo,PMO-Italy-Punta Raisi',
'Palma Mallorca,PMI-Spain-Son Sant Joan Airport',
'Panama City,PTY-Panama-Tocumen International',
'Paramaribo,PBM-Suriname-Zanderij Intl',
'Paris,CDG-France-Charles De Gaulle',
'Paris,ORY-France-Orly',
'Penang,PEN-Malaysia-Penang International',
'Perth,PER-Australia-Perth International',
'Peshawar,PEW-Pakistan-Peshawar',
'PHILADELPHIA,PHL-USA-Philadelphia International',
'Phnom Penh,PNH-Cambodia-Phnom Penh International',
'Phoenix,PHX-USA-Sky Harbor Intl',
'Phuket,HKT-Thailand-Phuket International',
'Piarco,POS-Trinidad-AnPiarco International',
'Pittsburgh,PIT-USA-Pittsburgh International Airport',
'Plaisance,MRU-Mauritius-Sir Seewoosagur Ramgoolam Int',
'Pointe a pitre,PTP-Guadeloup-Le Raizet',
'Port Au Prince,PAP-Haiti-Mais Gate',
'Port Elizabeth,PLZ-South Africa-Port Elizabeth',
'Portland,PDX-USA-Portland International',
'Prague,PRG-Czech-RepRuzyne',
'Praia,RAI-Cape Verde-Francisco Mendes',
'Pretoria,PRY-South Africa-Wonderboom Apt.',
'Pyongyang,FNJ-Korea-Nor Sunan International',
'Quito,UIO-Ecuador-Mariscal Sucre',
'Rabat,RBA-Morocco-Sale',
'Raleigh/Durham,RDU-USA-Raleigh Durham International Airport',
'Recife,REC-Brazil-Guararapes Intl',
'Reykjavik,KEF-Iceland-Keflavik International',
'Riga,RIX-Latvia-Riga International',
'Rio De Janeiro,GIG-Brazil-Galeao antonio Carlos Jobim International',
'Riyadh,RUH-Saudi Arab-King Khaled Intl',
'Rockhampton,ROK-Australia-Rockhampton',
'Rome,FCO-Italy-Leonardo Da Vinci Fiumicino',
'Rosario,ROS-Argentina-Fisherton',
'Rotterdam,RTM-Netherland-Rotterdam Zestienhoven',
'SAN FRANCISCO,SFO-USA-San Francisco International',
'San Jose,SJO-Costa Rica-Juan Santamaria Intl',
'San Juan,SJU-Puerto Rico-Luis Munoz Marin Intl',
'San Salvador,SAL-El Salvado-Comalapa International',
'Sanaa,SAH-Yemen-El Rahaba Airport [Sanaa Intenational]',
'Santiago,SCL-Chile-Arturo Merino Benitez',
'Santo Domingo,SDQ-Dominican-Las Americas Airport',
'Sao Paulo,CGH-Brazil-Congonhas',
'Sao Tome Is,TMS-Sao Tome-Sao Tome Is',
'Sarajevo,SJJ-Bosnia and Herzegovina-Butmir',
'SEATTLE,SEA-USA-Seattle/tacoma International',
'Seoul,ICN-Korea-Sou Incheon International',
'Sevilla,SVQ-Spain-San Pablo',
'Shanghai,SHA-China-Hongqiao',
'Shanghai,PVG-China-Pu Dong',
'Sharjah,SHJ-United Arab-Sharjah',
'Siem Reap,REP-Cambodia-Siem Reap',
'Singapore,SIN-Singapore-Changi',
'Skopje,SKP-Macedonia-Petrovec',
'Sofia,SOF-Bulgaria-Sofia',
'St Croix Island,STX-Virgind-IslanAlex Hamilton',
'St Denis de la Reunion,RUN-Reunion-Gillot',
'St Louis,STL-USA-Lambert-St Louis Intl',
'St Lucia,SLU-Saint-LuciaVigie',
'St Petersburg,LED-Russian-FePulkovo',
'Stavanger,SVG-Norway-Sola',
'Stockholm,ARN-Sweden-Arlanda',
'Stuttgart,STR-Germany-STUTTGART',
'Sydney,SYD-Australia-Kingsford Smith',
'Taipei,TPE-Taiwan-Chiang Kai Shek',
'Tallinn,TLL-Estonia-Ulemiste',
'Tampa,TPA-USA-Tampa International',
'Tangier,TNG-Morocco-Boukhalef',
'Tashkent,TAS-Uzbekistan-Yuzhny',
'Tbilisi,TBS-Georgia-Novo Alexeyevka',
'Tegucigalpa,TGU-Honduras-Toncontin',
'Tehran,IKA-Iran-Imam Khomeini International Airport',
'Tel Aviv Yafo,TLV-Israel-Ben Gurion Intl',
'Thessaloniki,SKG-Greece-Macedonia International',
'Tirana,TIA-Albania-Rinas',
'Tokyo,HND-Japan-Haneda',
'Tokyo,NRT-Japan-Narita International Airport',
'Toronto,YTO-Canada-Metropolitan Area',
'Toronto,YYZ-Canada-Lester B. Pearson International',
'Tripoli,TIP-Libya-International',
'Tunis,TUN-Tunisia-Carthage',
'Turin,TRN-Italy-Sandro Pertini [caselle]',
'Ulaanbaatar,ULN-Mongolia-Chinggis Khaan International',
'Valencia,VLC-Spain-Manises Airport',
'Vancouver,YVR-Canada-Vancouver',
'Vantaa,HEL-Finland Helsinki-Vantaa',
'Venice,VCE-Italy-Marco Polo',
'Vienna,VIE-Austria-Schwechat International',
'Vientiane,VTE-Laos-Wattay',
'Vilnius,VNO-Lithuania-Vilnius',
'Warsaw,WAW-Poland-Frederic Chopin',
'WASHINGTON DC,DCA-USA-Ronald Reagan National',
'Wellington,WLG-New Zealand-Wellington International',
'Windhoek,WDH-Namibia-Hosea Kutako International Airport',
'Winnipeg,YWG-Canada-Winnipeg',
'Xiamen,XMN-China-Xiamen',
'Yamoussoukro,ASK-Cote DIvoire-Yamoussoukro',
'Yangon,RGN-Myanmar-Mingaladon',
'Yaounde,YAO-Cameroon-Yaounde Airport',
'Yerevan,EVN-Armenia-Zvartnots',
'Zagreb,ZAG-Croatia-HrvPleso',
'Zurich,ZRH-Switzerland-Zurich Airport',
'Agartala,IXA-India-Singerbhil',//START INDIA CIYT FROM HERE
'Agatti Island,AGX-India-Agatti Island',
'Agra,AGR-India-Kheria',
'AHMEDABAD,AMD-India-Ahmedabad',
'Aizawl,AJL-India-Aizawl',
'Akola,AKD-India-Akola',
'Allahabad,IXD-India-Bamrauli',
'Along,IXV-India-Along',
'AMRITSAR,ATQ-India-Raja Sansi',
'ANYWHERE IN INDIA,999-India-Any City of India',
'Aurangabad,IXU-India-Chikkalthana',
'Bagdogra,IXB-India-Bagdogra',
'Balurghat,RGH-India-Balurghat',
'BANGALORE,BLR-India-Bangalore International Airport',
'Bareli,BEK-India-Bareli',
'Belgaum,IXG-India-Sambre',
'Bellary,BEP-India-Bellary',
'Bhatinda,BUP-India-Bhatinda',
'Bhavnagar,BHU-India-Bhavnagar',
'Bhopal,BHO-India-Bhopal',
'Bhubaneswar,BBI-India-Bhubaneswar',
'Bhuj,BHJ-India-Rudra Mata',
'Bhuntar,KUU-India-Kullu Manali',
'Bikaner,BKB-India-Bikaner',
'Bilaspur,PAB-India-Bilaspur',
'Car Nicobar,CBD-India-Car Nicobar',
'Chandigarh,IXC-India-Chandigarh',
'CHENNAI,MAA-India-Madras International (Meenambakkam)',
'Coimbatore,CJB-India-Peelamedu',
'Cooch Behar,COH-India-Cooch Behar',
'Cuddapah,CDP-India-Cuddapah',
'Daman,NMB-India-Daman',
'Daparizo,DAE-India-Daparizo',
'Darjeeling,DAI-India-Darjeeling',
'Dehra Dun,DED-India-Dehra Dun',
'Deparizo,DEP-India-Deparizo',
'Dhanbad,DBD-India-Dhanbad',
'Dharamsala,DHM-India-Gaggal Airport',
'Dibrugarh,DIB-India-Dibrugarh',
'Dimapur,DMU-India-Dimapur',
'Diu,DIU-India-Diu',
'Gawahati,GAU-India-Borjhar',
'Gaya,GAY-India-Gaya',
'Goa,GOI-India-Dabolim',
'Gorakhpur,GOP-India-Gorakhpur',
'Guna,GUX-India-Guna',
'Gwalior,GWL-India-Gwalior',
'Hissar,HSS-India-Hissar',
'Hubli,HBX-India-Hubli',
'HYDERABAD,HYD-India-Rajiv Gandhi Airport',
'Imphal,IMF-India-Municipal',
'Indore,IDR-India-Devi Ahilyabai Holkar',
'Jabalpur,JLR-India-Jabalpur',
'Jagdalpur,JGB-India-Jagdalpur',
'Jaipur,JAI-India-Sanganeer',
'Jaisalmer,JSA-India-Jaisalmer',
'Jammu,IXJ-India-Satwari',
'Jamnagar,JGA-India-Govardhanpur',
'Jamshedpur,IXW-India-Sonari',
'Jeypore,PYB-India-Jeypore',
'Jodhpur,JDH-India-Jodhpur',
'Jorhat,JRH-India-Rowriah',
'Kailashahar,IXH-India-Kailashahar',
'Kamalpur,IXQ-India-Kamalpur',
'Kandla,IXY-India-Kandla',
'Kanpur,KNU-India-Kanpur',
'Keshod,IXK-India-Keshod',
'Khajuraho,HJR-India-Khajuraho',
'Khowai,IXN-India-Khowai',
'KOCHI,COK-India-Kochi',
'Kolhapur,KLH-India-Kolhapur',
'KOLKATA,CCU-India-Netaji Subhas Chandra',
'Kota,KTU-India-Kota',
'Kozhikode,CCJ-India-Kozhikode Airport',
'Leh,IXL-India-Bakula Rimpoche',
'Lilabari,IXI-India-Lilabari',
'Lucknow,LKO-India-Amausi',
'Ludhiana,LUH-India-Ludhiana',
'Madurai,IXM-India-Madurai',
'Malda,LDA-India-Malda',
'Mangalore,IXE-India-Manalore',
'Mohanbari,MOH-India-Mohanbari',
'MUMBAI,BOM-India-Chhatrapati Shivaji International',
'Muzaffarnagar,MZA-India-Muzaffarnagar',
'Muzaffarpur,MZU-India-Muzaffarpur',
'Mysore,MYQ-India-Mysore',
'Nagpur,NAG-India-Sonegaon',
'Nanded,NDC-India-Nanded',
'Nasik,ISK-India-Gandhinagar Arpt',
'NEW DELHI,DEL-India-Indira Gandhi Intl',
'Neyveli,NVY-India-Neyveli',
'Osmanabad,OMN-India-Osmanabad',
'Pantnagar,PGH-India-Pantnagar',
'Pasighat,IXT-India-Pasighat',
'Pathankot,IXP-India-Pathankot',
'Patna,PAT-India-Patna',
'Pondicherry,PNY-India-Pondicherry',
'Porbandar,PBD-India-Porbandar',
'Port Blair,IXZ-India-Port Blair',
'Pune,PNQ-India-Lohegaon',
'Puttaparthi,PUT-India-Puttaprathe',
'Raipur,RPR-India-Raipur',
'Rajahmundry,RJA-India-Rajahmundry',
'Rajkot,RAJ-India-Civil',
'Rajouri,RJI-India-Rajouri',
'Ramagundam,RMD-India-Ramagundam',
'Ranchi,IXR-India-Ranchi',
'Ratnagiri,RTC-India-Ratnagiri',
'Rewa,REW-India-Rewa',
'Rourkela,RRK-India-Rourkela',
'Rupsi,RUP-India-Rupsi',
'Salem,SXV-India-Salem',
'Satna,TNI-India-Satna',
'Shillong,SHL-India-Shillong',
'Sholapur,SSE-India-Sholapur',
'Silchar,IXS-India-Kumbhirgram',
'Simla,SLV-India-Simla',
'Srinagar,SXR-India-Srinagar',
'Surat,STV-India-Surat',
'Tezpur,TEZ-India-Salonibari',
'Tezu,TEI-India-Tezu',
'Thanjavur,TJV-India-Thanjavur',
'Tiruchirapally,TRZ-India-Civil',
'Tirupati,TIR-India-Tirupati',
'Trivandrum,TRV-India-Thiruvananthapuram International',
'Tuticorin,TCR-India-Tuticorin',
'Udaipur,UDR-India-Dabok',
'Vadodara,BDQ-India-Vadodara',
'Varanasi,VNS-India-Varanasi',
'Vijayawada,VGA-India-Vijayawada',
'Vishakhapatnam,VTZ-India-Vishakhapatnam',
'Warangal,WGC-India-Warangal',
'Zero,ZER-India-Zero'
];



var suggesturl = ""; // Global link to the server-side script, that gives you the suggestion list.
                     // Used for controls that do not define their own server script urls.
var image = new Array(4);

image[0] = new Image(), image[1] = new Image(),
image[2] = new Image(), image[3] = new Image();

image[0].src = "", image[1].src = "";
image[2].src = "",   image[3].src = "";
function actb(id, ca, url)
{
	this.actb_suggesturl  = suggesturl;
	this.actb_timeOut     = -1;                  // autocomplete Timeout in ms (-1: autocomplete never time out)
	this.actb_response    = 500;                 // time, in milliseconds, between the last char typed and the actual query
	this.actb_lim         = 10;                  // number of elements autocomplete will show

	this.actb_firstText   = false;                // should the auto complete be limited to the beginning of keyword?
	this.actb_firstMatch  = true;                // if previous is false, should the exact matches be displayed first?
	this.actb_fullRefresh = true;               // should the script re-send the AJAX request after each entered character?

	this.actb_useIFrame   = true;                // should the control use an IFrame element to fix suggestion list positioning (MS IE only)?
	this.actb_useScroll   = true;               // should the control use a scroll bar (true) or a up/down buttons (false)?
	this.actb_mouse       = true;                // enable mouse support
	this.actb_noDefault   = false;               // should the control omit selecting the 1st item in a suggestion list?
	this.actb_delimiter   = new Array(); // delimiter for multiple autocomplete. Set it to empty array for single autocomplete
	this.actb_startcheck  = 3;                   // show widget only after this number of characters is typed in.

	this.actb_selectedIndex = -1;                // index (zero-based) of the element last chosen

	// Styles:
	this.actb_arColor   = '#005897';  // background color for the "arrows"
	this.actb_bgColor   = '#FFFFFF';
	this.actb_textColor = '#666666';
	this.actb_hColor    = '#FAE5E5';//'#FAE5E5';
	this.actb_fFamily   = 'verdana';
	this.actb_arrowSize = '7px';
	this.actb_fSize     = '10px';
	this.actb_hStyle    = 'font-family:verdana,arial,helvetica;';
	// "Private" Variables:
	this.actb_delimwords = [];
	this.actb_cdelimword = 0;
	this.actb_delimchar  = [];
	this.actb_display    = false;

	this.actb_pos    = 0;
	this.actb_total  = 0;
	this.actb_rangeu = 0;
	this.actb_ranged = 0;
	this.actb_bool   = [];
	this.actb_pre    = 0;
	this.actb_toid   = 0;
	this.actb_tomake = false;

	this.cur_x = 0;
	this.cur_y = 0;
	this.cur_w = 0;
	this.cur_h = 0;

	this.actb_mouse_on_list = 0;
	this.actb_caretmove     = false;

	this.actb_base_id  = id;
	this.actb_curr     = document.getElementById(id);
	this.actb_prevterm = this.actb_curr.value;

	this.actb_keywords = [];
	this.actb_values   = [];

	this.actb_keywords_init = [];
	this.actb_values_init   = [];

	ca = ca || [];
	for(var i = 0, cl = ca.length; i < cl; i++)
	{
		if(String(typeof(ca[i])).toLowerCase() == "string")
		{
			this.actb_keywords[i] = this.actb_keywords_init[i] = ca[i];
			this.actb_values[i]   = this.actb_values_init[i]   = "";
		}
		else
		{
			this.actb_keywords[i] = this.actb_keywords_init[i] = ca[i][0];
			this.actb_values[i]   = this.actb_values_init[i]   = ca[i][1];
		}
	}

	return this.construct();
};

actb.prototype = {

	callLater: function(func, obj)
	{ return function() { func.call(obj) }; },

	construct: function()
	{
		this.actb_curr.actb = this;

		// pre-create event functions
		this.funcClick = this.actb_mouseclick;
		this.funcCheck = this.actb_checkkey;

		this.funcHighlight = this.actb_table_highlight;
		
		this.funcClear = this.callLater(this.actb_clear,    this);
		this.funcPress = this.callLater(this.actb_keypress, this);

		this.funcUp   = this.callLater(this.actb_goup,   this);
		this.funcDown = this.callLater(this.actb_godown, this);

		this.funcFocus   = this.callLater(this.actb_table_focus,   this);
		this.funcUnfocus = this.callLater(this.actb_table_unfocus, this);

		addEvent(this.actb_curr, "focus", this.callLater(this.actb_setup, this));

		return this;
	},

	actb_setup: function()
	{
		addEvent(document,       "keydown",  this.funcCheck);
		addEvent(this.actb_curr, "blur",     this.funcClear);
		addEvent(document,       "keypress", this.funcPress);
	},

	actb_clear: function()
	{
		var msie  = (document.all && !window.opera) ? true : false;
		var event = window.event;

		if(msie && event && this.cur_h)
		{
			var x = event.x, y = event.y;

			if(((x > this.cur_x) && (x < (this.cur_x + this.cur_w))) && ((y > this.cur_y) && (y < (this.cur_y + this.cur_h))))
			{
				this.actb_curr.focus();
				return;
			}
		}

		removeEvent(document,       "keydown",  this.funcCheck);
		removeEvent(this.actb_curr, "blur",     this.funcClear);
		removeEvent(document,       "keypress", this.funcPress);

		this.actb_removedisp();
	},

	actb_parse: function(n)
	{
		if(!n || !n.length) return n;

	    var t, plen;
		if(this.actb_delimiter.length > 0)
		{
			   t = this.actb_delimwords[this.actb_cdelimword].trim().addslashes();
			plen = this.actb_delimwords[this.actb_cdelimword].trim().length;
		}
		else
		{
			   t = this.actb_curr.value.addslashes();
			plen = this.actb_curr.value.length;
		}

		if(!plen) return n;

		var tobuild = '';

		var re = this.actb_firstText ? new RegExp("^" + t, "i") : new RegExp(t, "i");
		var p = n.search(re);

		tobuild = n.substr(0, p);

		tobuild += "<u><b><font style='" + (this.actb_hStyle) + "'>";

		tobuild += n.substring(p, plen + p);

		tobuild += "</font></b></u>";

		tobuild += n.substring(plen + p, n.length);

		return tobuild;
	},

	actb_generate: function()
	{
		var body = document.getElementById('tat_table_' + this.actb_base_id);
		if(body)
		{
			this.actb_display = false;
			document.body.removeChild(body);

			var helper = document.getElementById('tat_helper_' + this.actb_base_id);
			if(helper)
				document.body.removeChild(helper);
		}

		if(this.actb_total == 0)
		{
			this.actb_display = false;
			return;
		}

		var msie = (document.all && !window.opera) ? true : false;

		var bb = document.createElement('div');
		bb.id  = 'tat_table_' + this.actb_base_id;
		bb.style.position = 'absolute';
		bb.style.border = '#000000 solid 1px';
		bb.style.zIndex = 100;

		this.cur_y = eval(curTop(this.actb_curr) + this.actb_curr.offsetHeight);
		this.cur_y = this.cur_y + document.body.scrollTop;


		bb.style.top = this.cur_y + "px";

		this.cur_x = bb.style.left = curLeft(this.actb_curr);
		bb.style.left = this.cur_x + "px";

		this.cur_w = this.actb_curr.offsetWidth - (msie ? 0 : 2);
		bb.style.width = this.cur_w + "px";

		this.cur_h = 1;
		bb.style.height = "1px"

		var cc = null;
		if(msie && this.actb_useIFrame)
		{
			var cc = document.createElement('iframe');
			cc.id  = "tat_helper_" + this.actb_base_id;

			cc.src = "javascript:'<html></html>';";
			cc.scrolling = "no";
			cc.frameBorder = "no";

			cc.style.display = "block";
			cc.style.position = "absolute";

			cc.style.zIndex = 99;
			cc.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
		}

		var actb_str = "<table cellspacing='1px' cellpadding='2px' style='width:100%;background-color:" + this.actb_bgColor + "' id='tat_table2_" + this.actb_base_id + "'>";

		if(this.actb_useScroll && (this.actb_total > this.actb_lim))
		{
			this.cur_h = this.actb_lim * parseInt(this.actb_fSize);
			bb.style.height = this.cur_h + "px";

			bb.style.overflow  = "auto";
			bb.style.overflowX = "hidden";
		}

		if(cc)
		{
			document.body.appendChild(cc);

			cc.style.top  = this.cur_y + "px";
			cc.style.left = this.cur_x + "px";

			cc.style.width  = bb.offsetWidth + 2;
		}
		document.body.appendChild(bb);

		var counter = 0, first = true, j = 1;

		for(var i = 0; i < this.actb_keywords.length; i++)
		{
			if(!this.actb_useScroll && ((this.actb_keywords.length > this.actb_lim) && (this.actb_total > this.actb_lim) && !i))
			{
				actb_str += "<tr style='background-color:" + this.actb_arColor + "'>";

				actb_str += "<td style='color:" + this.actb_textColor + ";font-family:arial narrow;font-size:" + this.actb_arrowSize + ";cursor:default" + "' align='center'></td></tr>";
			}

			if(this.actb_bool[i] && (this.actb_useScroll || (counter < this.actb_lim)))
			{
				counter++;

				actb_str += "<tr style='background-color:";

				if((first && !this.actb_noDefault && !this.actb_tomake) || (this.actb_pre == i))
				{
					actb_str += this.actb_hColor;
					first = false;
				}
				else
				{
					actb_str += this.actb_bgColor;
				}
				actb_str += "' id='tat_tr_" + this.actb_base_id + String(j) + "'>";

				actb_str += "<td style='color:" + this.actb_textColor + ";font-family:" + this.actb_fFamily + ";font-size:" + this.actb_fSize + ";white-space:nowrap" + "' id='tat_td_" + this.actb_base_id + String(j) + "'>" + this.actb_parse(this.actb_keywords[i]) + "</td></tr>";

				j++;
			}
		}

		if(!this.actb_useScroll && (this.actb_total > this.actb_lim))
		{
			actb_str += "<tr style='background-color:" + this.actb_arColor + "'>";

			actb_str += "<td style='color:" + this.actb_textColor + ";font-family:arial narrow;font-size:" + this.actb_arrowSize + ";cursor:default" + "' align='center'></td></tr>";
		}

		bb.innerHTML = actb_str;

		var table = bb.firstChild, row_num = table.rows.length, counter = 0, j = 1, real_height = 0, real_width = 0;
		if(this.actb_mouse)
		{
			table.onmouseout  = this.funcUnfocus;
			table.onmouseover = this.funcFocus;
		}

		for(i = 0; i < row_num; i++)
		{
			var row  = table.rows[i];
			var cell = row.cells[0];

			if(!this.actb_useScroll && ((this.actb_keywords.length > this.actb_lim) && (this.actb_total > this.actb_lim) && !i))
			{
				replaceHTML(cell, image[3]); 

				// Up arrow:
				real_height += row.offsetHeight + 1;
			}
			else if((i == (row_num - 1)) && (!this.actb_useScroll && (this.actb_total > this.actb_lim)))
			{
				replaceHTML(cell, image[0]);

				// Down arrow:
				addEvent(cell, "click", this.funcDown);

				real_height += row.offsetHeight + 1;
			}
			else
			{
				counter++;

				// Content cells:
				cell.actb = this; 
				cell.setAttribute('pos', j);

				if(counter <= this.actb_lim)
					real_height += row.offsetHeight + 1;

				if(real_width < row.offsetWidth)
					real_width = row.offsetWidth;

				if(this.actb_mouse)
				{
					cell.style.cursor = 'pointer';
					addEvent(cell, "click", this.funcClick);
					cell.onmouseover = this.funcHighlight;
				}

				j++;
			}
		}

		real_height += (msie ? 3 : 1);
		this.cur_h = real_height;
		bb.style.height = real_height + "px";

		this.cur_w = (real_width > bb.offsetWidth ? real_width : bb.offsetWidth) + 2;
		bb.style.width  = this.cur_w + "px";

		if(cc)
		{
			this.cur_h = real_height;

			cc.style.height = bb.style.height = this.cur_h + "px";
			cc.style.width  = this.cur_w + "px";
		}

		this.actb_pos    = this.actb_noDefault ? 0 : 1;
		this.actb_rangeu = 1;
		this.actb_ranged = j - 1;
		this.actb_display = true;
	},

	actb_remake: function()
	{
		var a = document.getElementById('tat_table2_' + this.actb_base_id);

		if(this.actb_mouse)
		{
			a.onmouseout  = this.funcUnfocus;
			a.onmouseover = this.funcFocus;
		}

		var i, k = 0;
		var first = true;
		var j = 1;

		if(this.actb_total > this.actb_lim)
		{
		    var b = (this.actb_rangeu > 1);

			var r = a.rows[k++];
			r.style.backgroundColor = this.actb_arColor;

			var c = r.firstChild;
			c.style.color = this.actb_textColor;
			c.style.fontFamily = 'arial narrow';
			c.style.fontSize = this.actb_arrowSize;
			c.style.cursor = 'default';
			c.align = 'center';

			replaceHTML(c, b ? image[2] : image[3]);

			if(b)
			{
				addEvent(c, "click", this.funcUp);
				c.style.cursor = 'pointer';
			}
			else
			{
				c.style.cursor = 'default';
			}
		}

		for(var i = 0; i < this.actb_keywords.length; i++)
		{
			if(this.actb_bool[i])
			{
				if(j >= this.actb_rangeu && j <= this.actb_ranged)
				{
					var r = a.rows[k++];
					r.style.backgroundColor = this.actb_bgColor;
					r.id = 'tat_tr_' + this.actb_base_id + String(j);

					var c = r.firstChild;
					c.style.color = this.actb_textColor;
					c.style.fontFamily = this.actb_fFamily;
					c.style.fontSize = this.actb_fSize;
					c.innerHTML = this.actb_parse(this.actb_keywords[i]);
					c.id = 'tat_td_' + this.actb_base_id + String(j);
					c.setAttribute('pos', j);
					j++;
				}
				else
				{
					j++;
				}
			}

			if(j > this.actb_ranged) break;
		}

		if(this.actb_keywords.length > this.actb_lim)
		{
			var b = ((j - 1) < this.actb_total);

			var r = a.rows[k];
			r.style.backgroundColor = this.actb_arColor;

			var c = r.firstChild;
			c.style.color = this.actb_textColor;
			c.style.fontFamily = 'arial narrow';
			c.style.fontSize = this.actb_arrowSize;
			c.style.cursor = 'default';
			c.align = 'center';

			replaceHTML(c, b ? image[0] : image[1]);

			if(b)
			{
				addEvent(c, "click", this.funcDown);
				c.style.cursor = 'pointer';
			}
			else
			{
				c.style.cursor = 'default';
			}
		}

		if((document.all && !window.opera))
		{
			var helper = document.getElementById("tat_helper_" + this.actb_base_id);
			if(helper)
				helper.style.width  = a.parentNode.offsetWidth + 2;
		}
	},
 
	actb_goup: function()
	{
		this.actb_curr.focus(); 

		if(!this.actb_display) return;
		if(this.actb_pos <= 1) return;

		var t = document.getElementById('tat_tr_' + this.actb_base_id + String(this.actb_pos));
		if(t && t.style) t.style.backgroundColor = this.actb_bgColor;

		this.actb_pos--;
		t = document.getElementById('tat_tr_' + this.actb_base_id + String(this.actb_pos));

		if(this.actb_useScroll && t)
		{
			var base = document.getElementById('tat_table_' + this.actb_base_id);
			base.scrollTop = t.offsetTop;
		}
		else
		{
			if(this.actb_pos < this.actb_rangeu)
			{
				this.actb_rangeu--;
				this.actb_ranged--;
				this.actb_remake();
			}

			t = document.getElementById('tat_tr_' + this.actb_base_id + String(this.actb_pos));
		}

		if(t && t.style) t.style.backgroundColor = this.actb_hColor;

		if(this.actb_toid)
		{
			clearTimeout(this.actb_toid);
			this.actb_toid = 0;
		}

		if(this.actb_timeOut > 0)
			this.actb_toid = setTimeout(function() { this.actb_mouse_on_list = 1; this.actb_removedisp(); }, this.actb_timeOut);

		this.actb_curr.focus();
	},

	actb_godown: function()
	{
		this.actb_curr.focus(); 

		if(!this.actb_display) return;
		if(this.actb_pos == this.actb_total) return;

		if(this.actb_pos >= 1)
		{
			var t = document.getElementById('tat_tr_' + this.actb_base_id + String(this.actb_pos));
			if(t && t.style) t.style.backgroundColor = this.actb_bgColor;
		}
		else
		{
			this.actb_pos = 0;
		}

		this.actb_pos++;
		t = document.getElementById('tat_tr_' + this.actb_base_id + String(this.actb_pos));

		if(this.actb_useScroll && t)
		{
			var base = document.getElementById('tat_table_' + this.actb_base_id);
			base.scrollTop = t.offsetTop;
		}
		else
		{
			if(this.actb_pos > this.actb_ranged)
			{
				this.actb_rangeu++;
				this.actb_ranged++;
				this.actb_remake();
			}

			t = document.getElementById('tat_tr_' + this.actb_base_id + String(this.actb_pos));
		}

		if(t && t.style) t.style.backgroundColor = this.actb_hColor;

		if(this.actb_toid)
		{
			clearTimeout(this.actb_toid);
			this.actb_toid = 0;
		}

		if(this.actb_timeOut > 0)
			this.actb_toid = setTimeout(function() { this.actb_mouse_on_list = 1; this.actb_removedisp(); }, this.actb_timeOut);

		this.actb_curr.focus();
	},

	actb_mouseclick: function(event)
	{
		var elem = getTargetElement(event);
		if(!elem.id) elem = elem.parentNode;

		var obj = elem.actb;
		if(!obj)
		{
			elem = elem.parentNode;
			obj = elem.actb;
		}
		if(!obj || !obj.actb_display) return;

		obj.actb_mouse_on_list = 0;
		obj.actb_pos = elem.getAttribute('pos');
		obj.actb_penter();
	},

	actb_table_focus: function()
	{ this.actb_mouse_on_list = 1; },

	actb_table_unfocus: function()
	{
		this.actb_mouse_on_list = 0;

		if(this.actb_toid)
		{
			clearTimeout(this.actb_toid);
			this.actb_toid = 0;
		}

		if(this.actb_timeOut > 0)
			this.actb_toid = setTimeout(function() { obj.actb_mouse_on_list = 0; this.actb_removedisp(); }, this.actb_timeOut);
	},

	actb_table_highlight: function(event)
	{
		var elem = getTargetElement(event);

		var obj = elem.actb;
		if(!obj) return;

		obj.actb_mouse_on_list = 1;

		var row = document.getElementById('tat_tr_' + obj.actb_base_id + obj.actb_pos);
		if(row && row.style) row.style.backgroundColor = obj.actb_bgColor;

		obj.actb_pos = elem.getAttribute('pos');

		row = document.getElementById('tat_tr_' + obj.actb_base_id + obj.actb_pos);
		if(row && row.style)
			row.style.backgroundColor = obj.actb_hColor;

		if(obj.actb_toid)
		{
			clearTimeout(obj.actb_toid);
			obj.actb_toid = 0;
		}

		if(obj.actb_timeOut > 0)
			obj.actb_toid = setTimeout(function() { obj.actb_mouse_on_list = 0; obj.actb_removedisp(); }, obj.actb_timeOut);
	},
 
 	actb_penter: function()
	{
		if(!this.actb_display) return;
		if(this.actb_pos < 1) return;

		this.actb_selectedIndex = this.actb_pos - 1;
		this.actb_display = false;

		var word = '', c = 0;

		for(var i = 0; i < this.actb_keywords.length; i++)
		{
			if(this.actb_bool[i]) c++;

			if(c == this.actb_pos)
			{
				word = this.actb_keywords[i];
				break;
			}
		}

		this.actb_insertword(word);
	},

	actb_insertword: function(a)
	{
		if(this.actb_delimiter.length > 0)
		{
			var str = '';

			for(var i = 0; i < this.actb_delimwords.length; i++)
			{
				if(this.actb_cdelimword == i)
				{
					prespace = postspace = '';
					gotbreak = false;
					for(var j = 0; j < this.actb_delimwords[i].length; ++j)
					{
						if(this.actb_delimwords[i].charAt(j) != ' ')
						{
							gotbreak = true;
							break;
						}

						prespace += ' ';
					}

					for(j = this.actb_delimwords[i].length - 1; j >= 0; --j)
					{
						if(this.actb_delimwords[i].charAt(j) != ' ') break;
						postspace += ' ';
					}

					str += prespace;
					str += a;
					if(gotbreak) str += postspace;
				}
				else
				{
					str += this.actb_delimwords[i];
				}

				if(i != this.actb_delimwords.length - 1)
					str += this.actb_delimchar[i];
			}

			this.actb_curr.value = str;
			setCaret(this.actb_curr, this.actb_curr.value.length);
		}
		else
		{
			this.actb_curr.value = a;
		}

		this.actb_mouse_on_list = 0;
		this.actb_removedisp();
	},

	actb_removedisp: function()
	{
		if(this.actb_mouse_on_list == 0)
		{
			this.actb_display = 0;

			var base = document.getElementById('tat_table_' + this.actb_base_id);
			if(base)
			{
				var helper = document.getElementById('tat_helper_' + this.actb_base_id);
				if(helper)
					document.body.removeChild(helper);

				document.body.removeChild(base);
			}

			if(this.actb_toid)
			{
			  clearTimeout(this.actb_toid);
			  this.actb_toid = 0;
			}

			this.cur_x = 0;
			this.cur_y = 0;
			this.cur_w = 0;
			this.cur_h = 0;
		}
	},

	actb_keypress: function(event)
	{
		if(this.actb_caretmove) stopEvent(event);
		return !this.actb_caretmove;
	},

	actb_checkkey: function(event)
	{
		event = event || window.event;

		var code = event.keyCode;
		var obj = getTargetElement(event).actb; 
		obj.actb_caretmove = 0;

		var term = "";

		if(obj.actb_toid)
		{
			clearTimeout(obj.actb_toid);
			obj.actb_toid = 0;
		}

		switch(code)
		{
			// Up arrow:
			case 38:
				obj.actb_goup();
				obj.actb_caretmove = 1;
				return false;
				break;

			// Down arrow:
			case 40:
				if(!obj.actb_display)
				{
					obj.actb_toid = setTimeout(function()
					{
						obj.actb_tocomplete.call(obj, -1);
					},
					25);
				}
				else
				{
					obj.actb_godown();
					obj.actb_caretmove = 1;
				}
				return false;
				break;

			// Page up:
			case 33:
				for(var c = 0; c < obj.actb_lim; c++)
					obj.actb_goup();

				obj.actb_caretmove = 1;
				break;

			// Page down:
			case 34:
				for(var c = 0; c < obj.actb_lim; c++)
					obj.actb_godown();

				obj.actb_caretmove = 1;
				break;

			// Esc:
			case 27:
				term = obj.actb_curr.value;

				obj.actb_mouse_on_list = 0;
				obj.actb_removedisp();
				break;

			// Enter:
			case 13:
				if(obj.actb_display)
				{
					obj.actb_caretmove = 1;
					obj.actb_penter();
					return false;
				}
				break;

			// Tab:
			case 9:
				if((obj.actb_display && obj.actb_pos) || obj.actb_toid)
				{
					obj.actb_caretmove = 1;
					obj.actb_penter();

					setTimeout(function() { obj.actb_curr.focus(); }, 25);
					return false;
				}
				break;

			default:
				obj.actb_caretmove = 0;
				obj.actb_toid = setTimeout(function()
				{
					obj.actb_tocomplete.call(obj, code);
				},
				(obj.actb_response < 10 ? 10 : obj.actb_response));
				break;
		}

		if(term.length) setTimeout(function() { obj.actb_curr.value = term; }, 25);
		return true;
	},

	actb_tocomplete: function(kc)
	{
	
	//	alert(kc + ","+ this.actb_toid)
		if(this.actb_toid)
		{
			clearTimeout(this.actb_toid);
			this.actb_toid = 0;
		}
		else
		{
			return;
		}

		if(this.actb_display && (this.actb_prevterm == this.actb_curr.value)) return;
		this.actb_prevterm = this.actb_curr.value;

		if(kc == 38 || kc == 40 || kc == 13) return;

		if(this.actb_display)
		{ 
			var word = 0;
			var c = 0;

			for(var i = 0; i <= this.actb_keywords.length; i++)
			{
				if(this.actb_bool[i]) c++;

				if(c == this.actb_pos)
				{
					word = i;
					break;
				}
			}
			
			this.actb_pre = word;
		}
		else
		{
			this.actb_pre = -1;
		}
		
		if(!this.actb_curr.value.length && (kc != -1))
		{
			this.actb_mouse_on_list = 0;
			this.actb_removedisp();
		}

		var ot, t;

		if(this.actb_delimiter.length > 0)
		{
			var caret_pos_end = this.actb_curr.value.length;

			var delim_split = '';
			for(var i = 0; i < this.actb_delimiter.length; i++)
				delim_split += this.actb_delimiter[i];

		    delim_split = delim_split.addslashes();
			var delim_split_rx = new RegExp("([" + delim_split + "])");
			c = 0;
			this.actb_delimwords = [];
			this.actb_delimwords[0] = '';

			for(var i = 0, j = this.actb_curr.value.length; i < this.actb_curr.value.length; i++, j--)
			{
				if(this.actb_curr.value.substr(i, j).search(delim_split_rx) == 0)
				{
					ma = this.actb_curr.value.substr(i,j).match(delim_split_rx);
					this.actb_delimchar[c] = ma[1];
					c++;
					this.actb_delimwords[c] = '';
				}
				else
				{
					this.actb_delimwords[c] += this.actb_curr.value.charAt(i);
				}
			}

			var l = 0;
			this.actb_cdelimword = -1;
			for(i = 0; i < this.actb_delimwords.length; i++)
			{
				if((caret_pos_end >= l) && (caret_pos_end <= l + this.actb_delimwords[i].length))
					this.actb_cdelimword = i;

				l += this.actb_delimwords[i].length + 1;
			}

			ot = this.actb_delimwords[this.actb_cdelimword].trim(); 
			 t = this.actb_delimwords[this.actb_cdelimword].addslashes().trim();
		}
		else
		{
			ot = this.actb_curr.value;
			 t = this.actb_curr.value.addslashes();
		}

		if(ot.length == 0 && (kc != -1))
		{
			this.actb_mouse_on_list = 0;
			this.actb_removedisp();
		}
		else if (ot.length >=this.actb_startcheck)
		{
		
		 	if((ot.length == 1) || this.actb_fullRefresh ||
		       ((ot.length > 1) && !this.actb_keywords.length) ||
		       ((ot.length > 1) && (this.actb_keywords[0].substr(0, 1).toLowerCase() != ot.substr(0, 1).toLowerCase())))
			{
				var ot_ = ((ot.length > 1) && !this.actb_fullRefresh) ? ot.substr(0, 1) : ot;
	
				if(this.actb_suggesturl.length)
				{
					// create xmlhttprequest object:
					var http = null;
					if(typeof XMLHttpRequest != 'undefined')
					{
						try
						{
							http = new XMLHttpRequest();
						}
						catch (e) { http = null; }
					}
					else
					{
						try
						{
							http = new ActiveXObject("Msxml2.XMLHTTP") ;
						}
						catch (e)
						{
							try
							{
								http = new ActiveXObject("Microsoft.XMLHTTP") ;
							}
							catch (e) { http = null; }
						}
					}
					//alert(this.actb_suggesturl + ot_);
					//alert(this.actb_base_id);
					if(http)
					{
						// For local debugging in Mozilla/Firefox only!
						try
						{
							netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
						} catch (e) { }
	
						if(http.overrideMimeType)
							http.overrideMimeType('text/xml');
		
						var type = "&trn_type=D";
						if (this.actb_base_id == "textreturn")
							type = "&trn_type=I";
						
						
						http.open("GET", this.actb_suggesturl + ot_+type, true);
	
						var obj = this;
						http.onreadystatechange = function(n)
						{
							if(http.readyState == 4)
							{
								if((http.status == 200) || (http.status == 0))
								{
								
								
									tmpinfo = http.responseText;
									
									if(tmpinfo)
									{
										obj.actb_keywords = tmpinfo.split('|');
	
										var keyword_number = obj.actb_keywords.length;
										for(var i = 0; i < keyword_number; i++)
										{
											/*var ca = obj.actb_keywords[i], comma = ca.indexOf(",");
	
											if(comma != -1)
											{
												var ci = ca.split(',');
	
												obj.actb_keywords[i] = obj.actb_keywords_init[i] = ci[0];
												obj.actb_values[i]   = obj.actb_values_init[i]   = ci[1];
											}
											else
											{*/
												obj.actb_values[i] = obj.actb_values_init[i] = "";										
											//}
										}
	
										obj.done.call(obj, ot_, t);
									}
								}
							}
						}
	
						http.send(null);
					}
	
					// xmlhttp object creation failed
					return;
				
				}
				else
				{
					this.done(ot, t);
				}
			}
		}
		else
		{
			this.done(ot, t);
		}
	},

	done: function(ot, t)
	{
		if(ot.length < this.actb_startcheck) return;

		var re = new RegExp(((!this.actb_firstText && !this.actb_firstMatch) ? "" : "^") + t, "i");

		this.actb_total = 0;
		this.actb_tomake = false;

		var al = this.actb_keywords.length;

		for(var i = 0; i < al; i++)
		{
			this.actb_bool[i] = false;
			if(re.test(this.actb_keywords[i]))
			{
				this.actb_total++;
				this.actb_bool[i] = true;

				if(this.actb_pre == i) this.actb_tomake = true;
			}
		}

		if(!this.actb_curr.value.length)
		{
			for(i = 0; i < al; i++)
			{
				this.actb_keywords[i] = this.actb_keywords_init[i];
				this.actb_values[i] = this.actb_values_init[i];
				this.actb_bool[i] = true;
			}
		}
		else if(!this.actb_firstText && this.actb_firstMatch)
		{
			var tmp = [], tmpv = [];

			for(i = 0; i < al; i++)
			{
				if(this.actb_bool[i])
				{
					tmp[tmp.length]   = this.actb_keywords[i];
					tmpv[tmpv.length] = this.actb_values[i];
				}
			}

			re = new RegExp(t, "i");

			for(i = 0; i < al; i++)
			{
				if(re.test(this.actb_keywords[i]) && !this.actb_bool[i])
				{
					this.actb_total++;
					this.actb_bool[i] = true;

					if(this.actb_pre == i) this.actb_tomake = true;

					tmp[tmp.length]   = this.actb_keywords[i];
					tmpv[tmpv.length] = this.actb_values[i];
				}
			}

			for(i = 0; i < al; i++)
			{
				if(!this.actb_bool[i])
				{
					tmp[tmp.length]   = this.actb_keywords[i];
					tmpv[tmpv.length] = this.actb_values[i];
				}
			}

			for(i = 0; i < al; i++)
			{
				this.actb_keywords[i] = tmp[i];
				this.actb_values[i]   = tmpv[i];
			}

			for(i = 0; i < al; i++)
				this.actb_bool[i] = (i < this.actb_total) ? true : false;
		}

		if(this.actb_timeOut > 0)
		  this.actb_toid = setTimeout(function(){ this.actb_mouse_on_list = 0; this.actb_removedisp(); }, this.actb_timeOut);

		this.actb_generate();
	}
}

// Supplementary functions

// Add an event to the obj given
// event_name refers to the event trigger, without the "on", like click or mouseover
// func_name refers to the function callback when event is triggered
function addEvent(obj, event_name, func_ref)
{
	if(obj.addEventListener && !window.opera)
	{
		obj.addEventListener(event_name, func_ref, true);
	}
	else
	{
		obj["on" + event_name] = func_ref;
	}
}

// Removes an event from the object
function removeEvent(obj, event_name, func_ref)
{
	if(obj.removeEventListener && !window.opera)
	{
		obj.removeEventListener(event_name, func_ref, true);
	}
	else
	{
		obj["on" + event_name] = null;
	}
}

// Stop an event from bubbling up the event DOM
function stopEvent(event)
{
	event = event || window.event;

	if(event)
	{
		if(event.stopPropagation) event.stopPropagation();
		if(event.preventDefault) event.preventDefault();

		if(typeof event.cancelBubble != "undefined")
		{
			event.cancelBubble = true;
			event.returnValue = false;
		}
	}

	return false;
}

// Get the obj that triggers off the event
function getTargetElement(event)
{
	event = event || window.event;
	return event.srcElement || event.target;
}
   
// Sets the caret position to l in the object
function setCaret(obj, l)
{
	obj.focus();

	if(obj.setSelectionRange)
	{
		obj.setSelectionRange(l, l);
	}
	else if(obj.createTextRange)
	{
		m = obj.createTextRange();		
		m.moveStart('character', l);
		m.collapse();
		m.select();
	}
}

// String functions
String.prototype.addslashes = function() { return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1'); }

String.prototype.trim = function () { return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); };

// Offset position from top of the screen
function curTop(obj)
{
	var toreturn = 0;
	while(obj)
	{
		toreturn += obj.offsetTop - (window.opera ? 0 : obj.scrollTop);
		obj = obj.offsetParent;
	}

	return toreturn;
}

// Offset position from left of the screen
function curLeft(obj)
{
	var toreturn = 0;
	while(obj)
	{
		toreturn += obj.offsetLeft - (window.opera ? 0 : obj.scrollLeft);
		obj = obj.offsetParent;
	}

	return toreturn;
}

// Image installation
function replaceHTML(obj, oImg)
{
	var el = obj.childNodes[0];
	while(el)
	{
		obj.removeChild(el);
		el = obj.childNodes[0];
	}

	obj.appendChild(oImg);
}
