/*
	Country State Drop Downs v1.1.  

	(c) Copyright 2006 by Down Home Consulting, Inc (www.DownHomeConsulting.com)

	Permission is hereby granted, free of charge, to any person obtaining a
	copy of this software and associated documentation files (the "Software"),
	to deal in the Software without restriction, including without limitation
	the rights to use, copy, modify, merge, publish, distribute, sublicense,
	and/or sell copies of the Software, and to permit persons to whom the
	Software is furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included
	in all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
	OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
	DEALINGS IN THE SOFTWARE.


	To install, add the following to the top of your page paste the html between the 
   form tags from demo2.html or demo.html into your page.

*/


// State table
// 
// To edit the list, just delete a line or add a line.  Order is important.  The order 
// displayed is the order it appears on the drop down.
//
var Address_State = '\
US:AK:Alaska|\
US:AL:Alabama|\
US:AR:Arkansas|\
US:AS:American Samoa|\
US:AZ:Arizona|\
US:CA:California|\
US:CO:Colorado|\
US:CT:Connecticut|\
US:DC:D.C.|\
US:DE:Delaware|\
US:FL:Florida|\
US:FM:Micronesia|\
US:GA:Georgia|\
US:GU:Guam|\
US:HI:Hawaii|\
US:IA:Iowa|\
US:ID:Idaho|\
US:IL:Illinois|\
US:IN:Indiana|\
US:KS:Kansas|\
US:KY:Kentucky|\
US:LA:Louisiana|\
US:MA:Massachusetts|\
US:MD:Maryland|\
US:ME:Maine|\
US:MH:Marshall Islands|\
US:MI:Michigan|\
US:MN:Minnesota|\
US:MO:Missouri|\
US:MP:Marianas|\
US:MS:Mississippi|\
US:MT:Montana|\
US:NC:North Carolina|\
US:ND:North Dakota|\
US:NE:Nebraska|\
US:NH:New Hampshire|\
US:NJ:New Jersey|\
US:NM:New Mexico|\
US:NV:Nevada|\
US:NY:New York|\
US:OH:Ohio|\
US:OK:Oklahoma|\
US:OR:Oregon|\
US:PA:Pennsylvania|\
US:PR:Puerto Rico|\
US:PW:Palau|\
US:RI:Rhode Island|\
US:SC:South Carolina|\
US:SD:South Dakota|\
US:TN:Tennessee|\
US:TX:Texas|\
US:UT:Utah|\
US:VA:Virginia|\
US:VI:Virgin Islands|\
US:VT:Vermont|\
US:WA:Washington|\
US:WI:Wisconsin|\
US:WV:West Virginia|\
US:WY:Wyoming|\
US:AA:Military Americas|\
US:AE:Military Europe/ME/Canada|\
US:AP:Military Pacific|\
CA:AB:Alberta|\
CA:MB:Manitoba|\
CA:AB:Alberta|\
CA:BC:British Columbia|\
CA:MB:Manitoba|\
CA:NB:New Brunswick|\
CA:NL:Newfoundland and Labrador|\
CA:NS:Nova Scotia|\
CA:NT:Northwest Territories|\
CA:NU:Nunavut|\
CA:ON:Ontario|\
CA:PE:Prince Edward Island|\
CA:QC:Quebec|\
CA:SK:Saskatchewan|\
CA:YT:Yukon Territory|\
AU:ACT:Australian Capital Territory|\
AU:NSW:New South Wales|\
AU:NT:Northern Territory|\
AU:QLD:Queensland|\
AU:SA:South Australia|\
AU:TAS:Tasmania|\
AU:VIC:Victoria|\
AU:WA:Western Australia|\
BR:AC:Acre|\
BR:AL:Alagoas|\
BR:AM:Amazonas|\
BR:AP:Amapa|\
BR:BA:Baia|\
BR:CE:Ceara|\
BR:DF:Distrito Federal|\
BR:ES:Espirito Santo|\
BR:FN:Fernando de Noronha|\
BR:GO:Goias|\
BR:MA:Maranhao|\
BR:MG:Minas Gerais|\
BR:MS:Mato Grosso do Sul|\
BR:MT:Mato Grosso|\
BR:PA:Para|\
BR:PB:Paraiba|\
BR:PE:Pernambuco|\
BR:PI:Piaui|\
BR:PR:Parana|\
BR:RJ:Rio de Janeiro|\
BR:RN:Rio Grande do Norte|\
BR:RO:Rondonia|\
BR:RR:Roraima|\
BR:RS:Rio Grande do Sul|\
BR:SC:Santa Catarina|\
BR:SE:Sergipe|\
BR:SP:Sao Paulo|\
BR:TO:Tocatins|\
NL:DR:Drente|\
NL:FL:Flevoland|\
NL:FR:Friesland|\
NL:GL:Gelderland|\
NL:GR:Groningen|\
NL:LB:Limburg|\
NL:NB:Noord Brabant|\
NL:NH:Noord Holland|\
NL:OV:Overijssel|\
NL:UT:Utrecht|\
NL:ZH:Zuid Holland|\
NL:ZL:Zeeland|\
UK:AVON:Avon|\
UK:BEDS:Bedfordshire|\
UK:BERKS:Berkshire|\
UK:BUCKS:Buckinghamshire|\
UK:CAMBS:Cambridgeshire|\
UK:CHESH:Cheshire|\
UK:CLEVE:Cleveland|\
UK:CORN:Cornwall|\
UK:CUMB:Cumbria|\
UK:DERBY:Derbyshire|\
UK:DEVON:Devon|\
UK:DORSET:Dorset|\
UK:DURHAM:Durham|\
UK:ESSEX:Essex|\
UK:GLOUS:Gloucestershire|\
UK:GLONDON:Greater London|\
UK:GMANCH:Greater Manchester|\
UK:HANTS:Hampshire|\
UK:HERWOR:Hereford & Worcestershire|\
UK:HERTS:Hertfordshire|\
UK:HUMBER:Humberside|\
UK:IOM:Isle of Man|\
UK:IOW:Isle of Wight|\
UK:KENT:Kent|\
UK:LANCS:Lancashire|\
UK:LEICS:Leicestershire|\
UK:LINCS:Lincolnshire|\
UK:MERSEY:Merseyside|\
UK:NORF:Norfolk|\
UK:NHANTS:Northamptonshire|\
UK:NTHUMB:Northumberland|\
UK:NOTTS:Nottinghamshire|\
UK:OXON:Oxfordshire|\
UK:SHROPS:Shropshire|\
UK:SOM:Somerset|\
UK:STAFFS:Staffordshire|\
UK:SUFF:Suffolk|\
UK:SURREY:Surrey|\
UK:SUSS:Sussex|\
UK:WARKS:Warwickshire|\
UK:WMID:West Midlands|\
UK:WILTS:Wiltshire|\
UK:YORK:Yorkshire|\
GB:Aberdeen City:Aberdeen City|\
GB:Aberdeenshire:Aberdeenshire|\
GB:Angus:Angus|\
GB:Antrim:Antrim|\
GB:Ards:Ards|\
GB:Argyll and Bute:Argyll and Bute|\
GB:Armagh:Armagh|\
GB:Ballymena:Ballymena|\
GB:Ballymoney:Ballymoney|\
GB:Banbridge:Banbridge|\
GB:Barking and Dagenham:Barking and Dagenham|\
GB:Barnet:Barnet|\
GB:Barnsley:Barnsley|\
GB:Bath and North East Somerset:Bath and North East Somerset|\
GB:Bedfordshire:Bedfordshire|\
GB:Belfast:Belfast|\
GB:Bexley:Bexley|\
GB:Birmingham:Birmingham|\
GB:Blackburn with Darwen:Blackburn with Darwen|\
GB:Blackpool:Blackpool|\
GB:Blaenau Gwent:Blaenau Gwent|\
GB:Bolton:Bolton|\
GB:Bournemouth:Bournemouth|\
GB:Bracknell Forest:Bracknell Forest|\
GB:Bradford:Bradford|\
GB:Brent:Brent|\
GB:Bridgend:Bridgend|\
GB:Brighton and Hove:Brighton and Hove|\
GB:Bristol City of:Bristol City of|\
GB:Bromley:Bromley|\
GB:Buckinghamshire:Buckinghamshire|\
GB:Bury:Bury|\
GB:Caerphilly:Caerphilly|\
GB:Calderdale:Calderdale|\
GB:Cambridgeshire:Cambridgeshire|\
GB:Camden:Camden|\
GB:Cardiff:Cardiff|\
GB:Carmarthenshire:Carmarthenshire|\
GB:Carrickfergus:Carrickfergus|\
GB:Castlereagh:Castlereagh|\
GB:Ceredigion:Ceredigion|\
GB:Cheshire:Cheshire|\
GB:Clackmannanshire:Clackmannanshire|\
GB:Coleraine:Coleraine|\
GB:Conwy:Conwy|\
GB:Cookstown:Cookstown|\
GB:Cornwall:Cornwall|\
GB:Coventry:Coventry|\
GB:Craigavon:Craigavon|\
GB:Croydon:Croydon|\
GB:Cumbria:Cumbria|\
GB:Darlington:Darlington|\
GB:Denbighshire:Denbighshire|\
GB:Derby:Derby|\
GB:Derbyshire:Derbyshire|\
GB:Derry:Derry|\
GB:Devon:Devon|\
GB:Doncaster:Doncaster|\
GB:Dorset:Dorset|\
GB:Down:Down|\
GB:Dudley:Dudley|\
GB:Dumfries and Galloway:Dumfries and Galloway|\
GB:Dundee City:Dundee City|\
GB:Dungannon:Dungannon|\
GB:Durham:Durham|\
GB:Ealing:Ealing|\
GB:East Ayrshire:East Ayrshire|\
GB:East Dunbartonshire:East Dunbartonshire|\
GB:East Lothian:East Lothian|\
GB:East Renfrewshire:East Renfrewshire|\
GB:East Riding of Yorkshire:East Riding of Yorkshire|\
GB:East Sussex:East Sussex|\
GB:Edinburgh City of:Edinburgh City of|\
GB:Eilean Siar:Eilean Siar|\
GB:Enfield:Enfield|\
GB:Essex:Essex|\
GB:Falkirk:Falkirk|\
GB:Fermanagh:Fermanagh|\
GB:Fife:Fife|\
GB:Flintshire:Flintshire|\
GB:Gateshead:Gateshead|\
GB:Glasgow City:Glasgow City|\
GB:Gloucestershire:Gloucestershire|\
GB:Greenwich:Greenwich|\
GB:Gwynedd:Gwynedd|\
GB:Hackney:Hackney|\
GB:Halton:Halton|\
GB:Hammersmith and Fulham:Hammersmith and Fulham|\
GB:Hampshire:Hampshire|\
GB:Haringey:Haringey|\
GB:Harrow:Harrow|\
GB:Hartlepool:Hartlepool|\
GB:Havering:Havering|\
GB:Herefordshire County of:Herefordshire County of|\
GB:Hertfordshire:Hertfordshire|\
GB:Highland:Highland|\
GB:Hillingdon:Hillingdon|\
GB:Hounslow:Hounslow|\
GB:Inverclyde:Inverclyde|\
GB:Isle of Anglesey:Isle of Anglesey|\
GB:Isle of Wight:Isle of Wight|\
GB:Isles of Scilly:Isles of Scilly|\
GB:Islington:Islington|\
GB:Kensington and Chelsea:Kensington and Chelsea|\
GB:Kent:Kent|\
GB:Kingston upon Hull City of:Kingston upon Hull City of|\
GB:Kingston upon Thames:Kingston upon Thames|\
GB:Kirklees:Kirklees|\
GB:Knowsley:Knowsley|\
GB:Lambeth:Lambeth|\
GB:Lancashire:Lancashire|\
GB:Larne:Larne|\
GB:Leeds:Leeds|\
GB:Leicester:Leicester|\
GB:Leicestershire:Leicestershire|\
GB:Lewisham:Lewisham|\
GB:Limavady:Limavady|\
GB:Lincolnshire:Lincolnshire|\
GB:Lisburn:Lisburn|\
GB:Liverpool:Liverpool|\
GB:London City of:London City of|\
GB:Luton:Luton|\
GB:Magherafelt:Magherafelt|\
GB:Manchester:Manchester|\
GB:Medway:Medway|\
GB:Merthyr Tydfil:Merthyr Tydfil|\
GB:Merton:Merton|\
GB:Middlesbrough:Middlesbrough|\
GB:Midlothian:Midlothian|\
GB:Milton Keynes:Milton Keynes|\
GB:Monmouthshire:Monmouthshire|\
GB:Moray:Moray|\
GB:Moyle:Moyle|\
GB:Neath Port Talbot:Neath Port Talbot|\
GB:Newcastle upon Tyne:Newcastle upon Tyne|\
GB:Newham:Newham|\
GB:Newport:Newport|\
GB:Newry and Mourne:Newry and Mourne|\
GB:Newtownabbey:Newtownabbey|\
GB:Norfolk:Norfolk|\
GB:North Ayrshire:North Ayrshire|\
GB:North Down:North Down|\
GB:North East Lincolnshire:North East Lincolnshire|\
GB:North Lanarkshire:North Lanarkshire|\
GB:North Lincolnshire:North Lincolnshire|\
GB:North Somerset:North Somerset|\
GB:North Tyneside:North Tyneside|\
GB:North Yorkshire:North Yorkshire|\
GB:Northamptonshire:Northamptonshire|\
GB:Northumberland:Northumberland|\
GB:Nottingham:Nottingham|\
GB:Nottinghamshire:Nottinghamshire|\
GB:Oldham:Oldham|\
GB:Omagh:Omagh|\
GB:Orkney Islands:Orkney Islands|\
GB:Oxfordshire:Oxfordshire|\
GB:Pembrokeshire:Pembrokeshire|\
GB:Perth and Kinross:Perth and Kinross|\
GB:Peterborough:Peterborough|\
GB:Plymouth:Plymouth|\
GB:Poole:Poole|\
GB:Portsmouth:Portsmouth|\
GB:Powys:Powys|\
GB:Reading:Reading|\
GB:Redbridge:Redbridge|\
GB:Redcar and Cleveland:Redcar and Cleveland|\
GB:Renfrewshire:Renfrewshire|\
GB:Rhondda Cynon Taff:Rhondda Cynon Taff|\
GB:Richmond upon Thames:Richmond upon Thames|\
GB:Rochdale:Rochdale|\
GB:Rotherham:Rotherham|\
GB:Rutland:Rutland|\
GB:Salford:Salford|\
GB:Sandwell:Sandwell|\
GB:Scottish Borders The:Scottish Borders The|\
GB:Sefton:Sefton|\
GB:Sheffield:Sheffield|\
GB:Shetland Islands:Shetland Islands|\
GB:Shropshire:Shropshire|\
GB:Slough:Slough|\
GB:Solihull:Solihull|\
GB:Somerset:Somerset|\
GB:South Ayrshire:South Ayrshire|\
GB:South Gloucestershire:South Gloucestershire|\
GB:South Lanarkshire:South Lanarkshire|\
GB:South Tyneside:South Tyneside|\
GB:Southampton:Southampton|\
GB:Southend-on-Sea:Southend-on-Sea|\
GB:Southwark:Southwark|\
GB:St. Helens:St. Helens|\
GB:Staffordshire:Staffordshire|\
GB:Stirling:Stirling|\
GB:Stockport:Stockport|\
GB:Stockton-on-Tees:Stockton-on-Tees|\
GB:Stoke-on-Trent:Stoke-on-Trent|\
GB:Strabane:Strabane|\
GB:Suffolk:Suffolk|\
GB:Sunderland:Sunderland|\
GB:Surrey:Surrey|\
GB:Sutton:Sutton|\
GB:Swansea:Swansea|\
GB:Swindon:Swindon|\
GB:Tameside:Tameside|\
GB:Telford and Wrekin:Telford and Wrekin|\
GB:Thurrock:Thurrock|\
GB:Torbay:Torbay|\
GB:Torfaen:Torfaen|\
GB:Tower Hamlets:Tower Hamlets|\
GB:Trafford:Trafford|\
GB:Vale of Glamorgan The:Vale of Glamorgan The|\
GB:Wakefield:Wakefield|\
GB:Walsall:Walsall|\
GB:Waltham Forest:Waltham Forest|\
GB:Wandsworth:Wandsworth|\
GB:Warrington:Warrington|\
GB:Warwickshire:Warwickshire|\
GB:West Berkshire:West Berkshire|\
GB:West Dunbartonshire:West Dunbartonshire|\
GB:West Lothian:West Lothian|\
GB:West Sussex:West Sussex|\
GB:Westminster:Westminster|\
GB:Wigan:Wigan|\
GB:Wiltshire:Wiltshire|\
GB:Windsor and Maidenhead:Windsor and Maidenhead|\
GB:Wirral:Wirral|\
GB:Wokingham:Wokingham|\
GB:Wolverhampton:Wolverhampton|\
GB:Worcestershire:Worcestershire|\
GB:Wrexham:Wrexham|\
GB:York:York|\
IE:CO ANTRIM:County Antrim|\
IE:CO ARMAGH:County Armagh|\
IE:CO DOWN:County Down|\
IE:CO FERMANAGH:County Fermanagh|\
IE:CO DERRY:County Londonderry|\
IE:CO TYRONE:County Tyrone|\
IE:CO CAVAN:County Cavan|\
IE:CO DONEGAL:County Donegal|\
IE:CO MONAGHAN:County Monaghan|\
IE:CO DUBLIN:County Dublin|\
IE:CO CARLOW:County Carlow|\
IE:CO KILDARE:County Kildare|\
IE:CO KILKENNY:County Kilkenny|\
IE:CO LAOIS:County Laois|\
IE:CO LONGFORD:County Longford|\
IE:CO LOUTH:County Louth|\
IE:CO MEATH:County Meath|\
IE:CO OFFALY:County Offaly|\
IE:CO WESTMEATH:County Westmeath|\
IE:CO WEXFORD:County Wexford|\
IE:CO WICKLOW:County Wicklow|\
IE:CO GALWAY:County Galway|\
IE:CO MAYO:County Mayo|\
IE:CO LEITRIM:County Leitrim|\
IE:CO ROSCOMMON:County Roscommon|\
IE:CO SLIGO:County Sligo|\
IE:CO CLARE:County Clare|\
IE:CO CORK:County Cork|\
IE:CO KERRY:County Kerry|\
IE:CO LIMERICK:County Limerick|\
IE:CO TIPPERARY:County Tipperary|\
IE:CO WATERFORD:County Waterford|\
IN:Andaman and Nicobar Islands Union Territory:Andaman and Nicobar Islands|\
IN:Andhra Pradesh State:Andhra Pradesh|\
IN:Assam State:Assam|\
IN:Chandigarh Union Territory:Chandigarh|\
IN:Dadra and Nagar Haveli Union Territory:Dadra and Nagar Haveli|\
IN:Delhi Union Territory:Delhi|\
IN:Gujarat State:Gujarat|\
IN:Haryana State:Haryana|\
IN:Himachal Pradesh State:Himachal Pradesh|\
IN:Jammu and Kashmir State:Jammu and Kashmir|\
IN:Kerala State:Kerala|\
IN:Lakshadweep Union Territory:Lakshadweep|\
IN:Maharashtra State:Maharashtra|\
IN:Manipur State:Manipur|\
IN:Meghalaya State:Meghalaya|\
IN:Karnataka State:Karnataka|\
IN:Nagaland State:Nagaland|\
IN:Orissa State:Orissa|\
IN:Puducherry Union Territory:Puducherry|\
IN:Punjab State:Punjab|\
IN:Rajasthan State:Rajasthan|\
IN:Tamil Nadu State:Tamil Nadu|\
IN:Tripura State:Tripura|\
IN:West Bengal State:West Bengal|\
IN:Sikkim State:Sikkim|\
IN:Arunachal Pradesh State:Arunachal Pradesh|\
IN:Mizoram State:Mizoram|\
IN:Daman and Diu Union Territory:Daman and Diu|\
IN:Goa State:Goa|\
IN:Bihar State:Bihar|\
IN:Madhya Pradesh State:Madhya Pradesh|\
IN:Uttar Pradesh State:Uttar Pradesh|\
IN:Chhattisgarh State:Chhattisgarh|\
IN:Jharkhand State:Jharkhand|\
IN:Uttarakhand State:Uttarakhand|\
DE:BW:Baden-Wurttemberg|\
DE:BY:Bayern|\
DE:BE:Berlin|\
DE:BB:Brandenburg|\
DE:HB:Bremen|\
DE:HH:Hamburg|\
DE:HE:Hessen|\
DE:MV:Mecklenburg-Vorpommern|\
DE:NI:Niedersachsen|\
DE:NW:Nordrhein-Westfalen|\
DE:RP:Rheinland-Pfalz|\
DE:SL:Saarland|\
DE:SN:Sachsen|\
DE:ST:Sachsen-Anhalt|\
DE:SH:Schleswig-Holstein|\
DE:TH:Thuringen|\
AE:AZ:Abu Dhabi|\
AE:AJ:Ajman|\
AE:FU:Al Fujayrah|\
AE:SH:Sharjah|\
AE:DU:Dubai|\
AE:RK:Ras al Khaymah|\
AE:UQ:Umm al Qaywayn|\
PH:ABR:Abra|\
PH:AGN:Agusan del Norte|\
PH:AGS:Agusan del Sur|\
PH:AKL:Aklan|\
PH:ALB:Albay|\
PH:ANT:Antique|\
PH:APA:Apayao|\
PH:AUR:Aurora|\
PH:14:Muslim Mindanao|\
PH:BAS:Basilan|\
PH:BAN:Bataan|\
PH:BTN:Batanes|\
PH:BTG:Batangas|\
PH:BEN:Benguet|\
PH:5:Bicol Region V|\
PH:BIL:Biliran|\
PH:BOH:Bohol|\
PH:BUK:Bukidnon|\
PH:BUL:Bulacan|\
PH:CAG:Cagayan|\
PH:2:Cagayan Valley Region II|\
PH:40:CALABARZON Region IV-A|\
PH:CAN:Camarines Norte|\
PH:CAS:Camarines Sur|\
PH:CAM:Camiguin|\
PH:CAP:Capiz|\
PH:13:Caraga Region XIII|\
PH:CAT:Catanduanes|\
PH:CAV:Cavite|\
PH:CEB:Cebu|\
PH:3:Central Luzon Region III|\
PH:7:Central Visayas Region VII|\
PH:COM:Compostela Valley|\
PH:15:Cordillera Administrative Region|\
PH:11:Davao Region XI|\
PH:DAV:Davao del Norte|\
PH:DAS:Davao del Sur|\
PH:DAO:Davao Oriental|\
PH:DIN:Dinagat Islands|\
PH:EAS:Eastern Samar|\
PH:8:Eastern Visayas Region VIII|\
PH:GUI:Guimaras|\
PH:IFU:Ifugao|\
PH:1:Ilocos Region I|\
PH:ILN:Ilocos Norte|\
PH:ILS:Ilocos Sur|\
PH:ILI:Iloilo|\
PH:ISA:Isabela|\
PH:KAL:Kalinga|\
PH:LUN:La Union|\
PH:LAG:Laguna|\
PH:LAN:Lanao del Norte|\
PH:LAS:Lanao del Sur|\
PH:LEY:Leyte|\
PH:MAG:Maguindanao|\
PH:MAD:Marinduque|\
PH:MAS:Masbate|\
PH:41:MIMAROPA Region IV-B|\
PH:MDC:Mindoro Occidental|\
PH:MDR:Mindoro Oriental|\
PH:MSC:Misamis Occidental|\
PH:MSR:Misamis Oriental|\
PH:MOU:Mountain Province|\
PH:0:National Capital Region|\
PH:NEC:Negros Occidental|\
PH:NER:Negros Oriental|\
PH:NCO:North Cotabato|\
PH:10:Northern Mindanao Region X|\
PH:NSA:Northern Samar|\
PH:NUE:Nueva Ecija|\
PH:NUV:Nueva Vizcaya|\
PH:PLW:Palawan|\
PH:PAM:Pampanga|\
PH:PAN:Pangasinan|\
PH:QUE:Quezon|\
PH:QUI:Quirino|\
PH:RIZ:Rizal|\
PH:ROM:Romblon|\
PH:SAR:Sarangani|\
PH:X2:Shariff Kabunsuan|\
PH:SIG:Siquijor|\
PH:12:Soccsksargen Region XII|\
PH:SOR:Sorsogon|\
PH:SCO:South Cotabato|\
PH:SLE:Southern Leyte|\
PH:SUK:Sultan Kudarat|\
PH:SLU:Sulu|\
PH:SUN:Surigao del Norte|\
PH:SUR:Surigao del Sur|\
PH:TAR:Tarlac|\
PH:TAW:Tawi-Tawi|\
PH:WSA:Western Samar|\
PH:6:Western Visayas Region VI|\
PH:ZMB:Zambales|\
PH:ZAN:Zamboanga del Norte|\
PH:ZAS:Zamboanga del Sur|\
PH:9:Zamboanga Peninsula Region IX|\
PH:ZSI:Zamboanga Sibuguey|\
';

// Country data table
//
// 
// To edit the list, just delete a line or add a line.  Order is important.  The order 
// displayed is the order it appears on the drop down.
//
var Address_Country = '\
US:United States|\
AF:Afghanistan|\
AL:Albania|\
DZ:Algeria|\
AS:American Samoa|\
AD:Andorra|\
AO:Angola|\
AI:Anguilla|\
AQ:Antarctica|\
AG:Antigua and Barbuda|\
AR:Argentina|\
AM:Armenia|\
AW:Aruba|\
AU:Australia|\
AT:Austria|\
AZ:Azerbaijan|\
BS:Bahamas|\
BH:Bahrain|\
BD:Bangladesh|\
BB:Barbados|\
BY:Belarus|\
BE:Belgium|\
BZ:Belize|\
BJ:Benin|\
BM:Bermuda|\
BT:Bhutan|\
BO:Bolivia|\
BA:Bosnia and Herzegowina|\
BW:Botswana|\
BV:Bouvet Island|\
BR:Brazil|\
IO:British Indian Ocean Territory|\
BN:Brunei Darussalam|\
BG:Bulgaria|\
BF:Burkina Faso|\
BI:Burundi|\
KH:Cambodia|\
CM:Cameroon|\
CA:Canada|\
CV:Cape Verde|\
KY:Cayman Islands|\
CF:Central African Republic|\
TD:Chad|\
CL:Chile|\
CN:China|\
CX:Christmas Island|\
CC:Cocos (Keeling) Islands|\
CO:Colombia|\
KM:Comoros|\
CG:Congo|\
CD:Congo, the Democratic Republic of the|\
CK:Cook Islands|\
CR:Costa Rica|\
CI:Cote dIvoire|\
HR:Croatia (Hrvatska)|\
CU:Cuba|\
CY:Cyprus|\
CZ:Czech Republic|\
DK:Denmark|\
DJ:Djibouti|\
DM:Dominica|\
DO:Dominican Republic|\
TP:East Timor|\
EC:Ecuador|\
EG:Egypt|\
SV:El Salvador|\
GQ:Equatorial Guinea|\
ER:Eritrea|\
EE:Estonia|\
ET:Ethiopia|\
FK:Falkland Islands (Malvinas)|\
FO:Faroe Islands|\
FJ:Fiji|\
FI:Finland|\
FR:France|\
FX:France, Metropolitan|\
GF:French Guiana|\
PF:French Polynesia|\
TF:French Southern Territories|\
GA:Gabon|\
GM:Gambia|\
GE:Georgia|\
DE:Germany|\
GH:Ghana|\
GI:Gibraltar|\
GR:Greece|\
GL:Greenland|\
GD:Grenada|\
GP:Guadeloupe|\
GU:Guam|\
GT:Guatemala|\
GN:Guinea|\
GW:Guinea-Bissau|\
GY:Guyana|\
HT:Haiti|\
HM:Heard and Mc Donald Islands|\
VA:Holy See (Vatican City State)|\
HN:Honduras|\
HK:Hong Kong|\
HU:Hungary|\
IS:Iceland|\
IN:India|\
ID:Indonesia|\
IR:Iran (Islamic Republic of)|\
IQ:Iraq|\
IE:Ireland|\
IL:Israel|\
IT:Italy|\
JM:Jamaica|\
JP:Japan|\
JO:Jordan|\
KZ:Kazakhstan|\
KE:Kenya|\
KI:Kiribati|\
KP:Korea, Democratic Peoples Republic of|\
KR:Korea, Republic of|\
KW:Kuwait|\
KG:Kyrgyzstan|\
LA:Lao Peoples Democratic Republic|\
LV:Latvia|\
LB:Lebanon|\
LS:Lesotho|\
LR:Liberia|\
LY:Libyan Arab Jamahiriya|\
LI:Liechtenstein|\
LT:Lithuania|\
LU:Luxembourg|\
MO:Macau|\
MK:Macedonia, Former Yugoslav Republic of|\
MG:Madagascar|\
MW:Malawi|\
MY:Malaysia|\
MV:Maldives|\
ML:Mali|\
MT:Malta|\
MH:Marshall Islands|\
MQ:Martinique|\
MR:Mauritania|\
MU:Mauritius|\
YT:Mayotte|\
MX:Mexico|\
FM:Micronesia, Federated States of|\
MD:Moldova, Republic of|\
MC:Monaco|\
MN:Mongolia|\
MS:Montserrat|\
MA:Morocco|\
MZ:Mozambique|\
MM:Myanmar|\
NA:Namibia|\
NR:Nauru|\
NP:Nepal|\
NL:Netherlands|\
AN:Netherlands Antilles|\
NC:New Caledonia|\
NZ:New Zealand|\
NI:Nicaragua|\
NE:Niger|\
NG:Nigeria|\
NU:Niue|\
NF:Norfolk Island|\
MP:Northern Mariana Islands|\
NO:Norway|\
OM:Oman|\
PK:Pakistan|\
PW:Palau|\
PA:Panama|\
PG:Papua New Guinea|\
PY:Paraguay|\
PE:Peru|\
PH:Philippines|\
PN:Pitcairn|\
PL:Poland|\
PT:Portugal|\
PR:Puerto Rico|\
QA:Qatar|\
RE:Reunion|\
RO:Romania|\
RU:Russian Federation|\
RW:Rwanda|\
KN:Saint Kitts and Nevis|\
LC:Saint LUCIA|\
VC:Saint Vincent and the Grenadines|\
WS:Samoa|\
SM:San Marino|\
ST:Sao Tome and Principe|\
SA:Saudi Arabia|\
SN:Senegal|\
SC:Seychelles|\
SL:Sierra Leone|\
SG:Singapore|\
SK:Slovakia (Slovak Republic)|\
SI:Slovenia|\
SB:Solomon Islands|\
SO:Somalia|\
ZA:South Africa|\
GS:South Georgia and South Sandwich Islands|\
ES:Spain|\
LK:Sri Lanka|\
SH:St. Helena|\
PM:St. Pierre and Miquelon|\
SD:Sudan|\
SR:Suriname|\
SJ:Svalbard and Jan Mayen Islands|\
SZ:Swaziland|\
SE:Sweden|\
CH:Switzerland|\
SY:Syrian Arab Republic|\
TW:Taiwan, Province of China|\
TJ:Tajikistan|\
TZ:Tanzania, United Republic of|\
TH:Thailand|\
TG:Togo|\
TK:Tokelau|\
TO:Tonga|\
TT:Trinidad and Tobago|\
TN:Tunisia|\
TR:Turkey|\
TM:Turkmenistan|\
TC:Turks and Caicos Islands|\
TV:Tuvalu|\
UG:Uganda|\
UA:Ukraine|\
AE:United Arab Emirates|\
GB:United Kingdom|\
US:United States|\
UM:United States Minor Outlying Islands|\
UY:Uruguay|\
UZ:Uzbekistan|\
VU:Vanuatu|\
VE:Venezuela|\
VN:Viet Nam|\
VG:Virgin Islands (British)|\
VI:Virgin Islands (U.S.)|\
WF:Wallis and Futuna Islands|\
EH:Western Sahara|\
YE:Yemen|\
YU:Yugoslavia|\
ZM:Zambia|\
ZW:Zimbabwe|\
';

// Save the country & state field names
var countryFieldCfgArray = document.getElementById('cs_config_country_field').value.split(' ');
var stateFieldCfgArray   = document.getElementById('cs_config_state_field').value.split(' ');

// Save the names of the fields that hold the country & state default values
var countryDefaultCfgArray = document.getElementById('cs_config_country_default').value.split(' ');
var stateDefaultCfgArray   = document.getElementById('cs_config_state_default').value.split(' ');

var defaultState = false;
var defaultCountry = false;

function TrimString(sInString) {
   
   if ( sInString ) {

      sInString = sInString.replace( /^\s+/g, "" );// strip leading
      return sInString.replace( /\s+$/g, "" );// strip trailing
   }
}
// Populates the country select with the counties from the country list
//
function populateCountry(idName) {

   var countryLineArray = Address_Country.split('|');      // Split into lines

   var selObj = document.getElementById( idName );

   selObj.options[0] = new Option('Select Country','');
   selObj.selectedIndex = 0;

   for (var loop = 0; loop < countryLineArray.length; loop++) {

      lineArray = countryLineArray[loop].split(':');

      countryCode  = TrimString(lineArray[0]);
      countryName  = TrimString(lineArray[1]);
   
      if ( countryCode != '' ) {

         selObj.options[loop + 1] = new Option(countryName, countryCode);
      }

      if ( defaultCountry == countryCode ) {

         selObj.selectedIndex = loop + 1;
      }
   }
}
function populateState( statestateIdName, countryIdName ) {

   var selObj = document.getElementById( stateIdName );
   var foundState = false;

   // Empty options just in case new drop down is shorter
   //
   if ( selObj.type == 'select-one' ) {

      selObj.options.length = 0;

      selObj.options[0] = new Option('Select State','');
      selObj.selectedIndex = 0;
   }
   // Populate the drop down with states from the selected country
   //
   var stateLineArray   = Address_State.split("|");        // Split into lines

   var optionCntr = 1;

   for (var loop = 0; loop < stateLineArray.length; loop++) {

      lineArray = stateLineArray[loop].split(":");

      countryCode  = TrimString(lineArray[0]);
      stateCode    = TrimString(lineArray[1]);
      stateName    = TrimString(lineArray[2]);

      if ( document.getElementById( countryIdName ).value == countryCode && countryCode != '' ) {

         // If it's a input element, change it to a select
         //
         if ( selObj.type == 'text' ) {

            parentObj = document.getElementById( stateIdName ).parentNode;
            parentObj.removeChild(selObj);

            var inputSel = document.createElement("select");
            inputSel.setAttribute("name","Address_State"); 
            inputSel.setAttribute("id", stateIdName ); 
            inputSel.setAttribute("style", "font-family: Arial; font-size: 9pt" ); 

            parentObj.appendChild(inputSel) ;

            selObj = document.getElementById( stateIdName );
            selObj.options[0] = new Option('Select State or Province','');
            selObj.selectedIndex = 0;
         }
   
         if ( stateCode != '' ) {

            selObj.options[optionCntr] = new Option(stateName, stateCode);
         }
         // See if it's selected from a previous post
         //
         if ( stateCode == defaultState && countryCode == defaultCountry ) {

            selObj.selectedIndex = optionCntr;
         }
         foundState = true;
         optionCntr++
      }
   }
   // If the country has no states, change the select to a text box
   //
   if ( ! foundState ) {

      parentObj = document.getElementById( stateIdName ).parentNode;
      parentObj.removeChild(selObj);
 
      // Create the Input Field
      var inputEl = document.createElement("input");

      inputEl.setAttribute("id",  stateIdName ); 
      inputEl.setAttribute("type", "text"); 
      inputEl.setAttribute("name", "Address_State"); 
      inputEl.setAttribute("size", 20); 
      inputEl.setAttribute("value", defaultState); 
      parentObj.appendChild(inputEl) ;
   }
   
}
// Called when state drop down is changed
// 
function updateState( countryIdNameIn ) {

   for (var loop = 0; loop < countryFieldCfgArray.length; loop++) {
   
      countryIdName  = countryFieldCfgArray[loop];
      stateIdName    = stateFieldCfgArray[loop];

      // Read the default value hidden fields
      defaultCountry = document.getElementById( countryDefaultCfgArray[loop] ).value;
      defaultState   = document.getElementById( stateDefaultCfgArray[loop] ).value;

      if ( countryIdNameIn == countryIdName ) {

         populateState( stateIdName, countryIdName );
      }
   }
}
// Initialize the drop downs
// 
function initCountry() {

   for (var loop = 0; loop < countryFieldCfgArray.length; loop++) {
   
      countryIdName  = countryFieldCfgArray[loop];
      stateIdName    = stateFieldCfgArray[loop];

      // Read the default value hidden fields
      defaultCountry = document.getElementById( countryDefaultCfgArray[loop] ).value;
      defaultState   = document.getElementById( stateDefaultCfgArray[loop] ).value;

      populateCountry( countryIdName);
      populateState( stateIdName, countryIdName );
   }
}


