var postState = ''; var postCountry = ''; var state = 'BR:AC:Acre|US:AL:Alabama|BR:AL:Alagoas|US:AK:Alaska|CA:AB:Alberta|CA:AB:Alberta|BR:AP:Amapa|BR:AM:Amazonas|US:AS:American Samoa|US:AZ:Arizona|US:AR:Arkansas|AU:AAT:Australian Antarctic Territory|AU:ACT:Australian Capital Territory|GB:AVON:Avon|BR:BA:Baia|GB:BEDS:Bedfordshire|GB:BERKS:Berkshire|CA:BC:British Columbia|GB:BUCKS:Buckinghamshire|US:CA:California|GB:CAMBS:Cambridgeshire|BR:CE:Ceara|GB:CHESH:Cheshire|GB:CLEVE:Cleveland|US:CO:Colorado|US:CT:Connecticut|GB:CORN:Cornwall|IE:CO ANTRIM:County Antrim|IE:CO ARMAGH:County Armagh|IE:CO CARLOW:County Carlow|IE:CO CAVAN:County Cavan|IE:CO CLARE:County Clare|IE:CO CORK:County Cork|IE:CO DONEGAL:County Donegal|IE:CO DOWN:County Down|IE:CO DUBLIN:County Dublin|IE:CO FERMANAGH:County Fermanagh|IE:CO GALWAY:County Galway|IE:CO KERRY:County Kerry|IE:CO KILDARE:County Kildare|IE:CO KILKENNY:County Kilkenny|IE:CO LAOIS:County Laois|IE:CO LEITRIM:County Leitrim|IE:CO LIMERICK:County Limerick|IE:CO DERRY:County Londonderry|IE:CO LONGFORD:County Longford|IE:CO LOUTH:County Louth|IE:CO MAYO:County Mayo|IE:CO MEATH:County Meath|IE:CO MONAGHAN:County Monaghan|IE:CO OFFALY:County Offaly|IE:CO ROSCOMMON:County Roscommon|IE:CO SLIGO:County Sligo|IE:CO TIPPERARY:County Tipperary|IE:CO TYRONE:County Tyrone|IE:CO WATERFORD:County Waterford|IE:CO WESTMEATH:County Westmeath|IE:CO WEXFORD:County Wexford|IE:CO WICKLOW:County Wicklow|GB:CUMB:Cumbria|US:DC:D.C.|US:DE:Delaware|GB:DERBY:Derbyshire|GB:DEVON:Devon|BR:DF:Distrito Federal|GB:DORSET:Dorset|NL:DR:Drente|GB:DURHAM:Durham|BR:ES:Espirito Santo|GB:ESSEX:Essex|BR:FN:Fernando de Noronha|NL:FL:Flevoland|US:FL:Florida|NL:FR:Friesland|NL:GL:Gelderland|US:GA:Georgia|GB:GLOUS:Gloucestershire|BR:GO:Goias|GB:GLONDON:Greater London|GB:GMANCH:Greater Manchester|NL:GR:Groningen|US:GU:Guam|GB:HANTS:Hampshire|US:HI:Hawaii|GB:HERWOR:Hereford & Worcestershire|GB:HERTS:Hertfordshire|GB:HUMBER:Humberside|US:ID:Idaho|US:IL:Illinois|US:IN:Indiana|US:IA:Iowa|GB:IOM:Isle of Man|GB:IOW:Isle of Wight|US:KS:Kansas|GB:KENT:Kent|US:KY:Kentucky|GB:LANCS:Lancashire|GB:LEICS:Leicestershire|NL:LB:Limburg|GB:LINCS:Lincolnshire|US:LA:Louisiana|US:ME:Maine|CA:MB:Manitoba|CA:MB:Manitoba|BR:MA:Maranhao|US:MP:Marianas|US:MH:Marshall Islands|US:MD:Maryland|US:MA:Massachusetts|BR:MT:Mato Grosso|BR:MS:Mato Grosso do Sul|GB:MERSEY:Merseyside|US:MI:Michigan|US:FM:Micronesia|US:AA:Military Americas|US:AE:Military Europe/ME/Canada|US:AP:Military Pacific|BR:MG:Minas Gerais|US:MN:Minnesota|US:MS:Mississippi|US:MO:Missouri|US:MT:Montana|US:NE:Nebraska|US:NV:Nevada|CA:NB:New Brunswick|US:NH:New Hampshire|US:NJ:New Jersey|US:NM:New Mexico|AU:NSW:New South Wales|US:NY:New York|CA:NL:Newfoundland and Labrador|NL:NB:Noord Brabant|NL:NH:Noord Holland|GB:NORF:Norfolk|US:NC:North Carolina|US:ND:North Dakota|GB:NHANTS:Northamptonshire|AU:NT:Northern Territory|GB:NTHUMB:Northumberland|CA:NT:Northwest Territories|GB:NOTTS:Nottinghamshire|CA:NS:Nova Scotia|CA:NU:Nunavut|US:OH:Ohio|US:OK:Oklahoma|CA:ON:Ontario|US:OR:Oregon|NL:OV:Overijssel|GB:OXON:Oxfordshire|US:PW:Palau|BR:PA:Para|BR:PB:Paraiba|BR:PR:Parana|US:PA:Pennsylvania|BR:PE:Pernambuco|BR:PI:Piaui|CA:PE:Prince Edward Island|US:PR:Puerto Rico|CA:QC:Quebec|AU:QLD:Queensland|US:RI:Rhode Island|BR:RN:Rio Grande do Norte|BR:RS:Rio Grande do Sul|BR:RJ:Rio de Janeiro|BR:RO:Rondonia|BR:RR:Roraima|BR:SC:Santa Catarina|BR:SP:Sao Paulo|CA:SK:Saskatchewan|BR:SE:Sergipe|GB:SHROPS:Shropshire|GB:SOM:Somerset|AU:SA:South Australia|US:SC:South Carolina|US:SD:South Dakota|GB:STAFFS:Staffordshire|GB:SUFF:Suffolk|GB:SURREY:Surrey|GB:SUSS:Sussex|AU:TAS:Tasmania|US:TN:Tennessee|US:TX:Texas|BR:TO:Tocatins|US:UT:Utah|NL:UT:Utrecht|US:VT:Vermont|AU:VIC:Victoria|US:VI:Virgin Islands|US:VA:Virginia|GB:WARKS:Warwickshire|US:WA:Washington|GB:WMID:West Midlands|US:WV:West Virginia|AU:WA:Western Australia|GB:WILTS:Wiltshire|US:WI:Wisconsin|US:WY:Wyoming|GB:YORK:Yorkshire|CA:YT:Yukon Territory|NL:ZL:Zeeland|NL:ZH:Zuid Holland'; var country = 'AF:Afghanistan|AX:Aland|AL:Albania|DZ:Algeria|AS:American Samoa|AD:Andorra|AO:Angola|AI:Anguilla|AG:Antigua and Barbuda|AR:Argentina|AM:Armenia|AW:Aruba|AU:Australia|AT:Austria|BS:Bahama|BH:Bahrain|BD:Bangladesh|BB:Barbados|BY:Belarus|BE:Belgium|BZ:Belize|BJ:Benin|BM:Bermuda|BT:Bhutan|BO:Bolivia|BA:Bosnia and Herzegovina|BW:Botswana|BV:Bouvet Island|BR:Brazil|AQ:British Antarctic Territory|IO:British Indian Ocean Territory|VG:British Virgin Islands|BN:Brunei|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|PF:Clipperton Island|CC:Cocos (Keeling) Islands|CO:Colombia|KM:Comoros|CG:Congo|CD:Congo D.R.|CK:Cook Islands|CR:Costa Rica|CI:Cote d\'Ivoire (Ivory Coast)|HR:Croatia|CU:Cuba|CZ:Czech Republic|DK:Denmark|DJ:Djibouti|DM:Dominica|DO:Dominican Republic|EC:Ecuador|EG:Egypt|SV:El Salvador|GQ:Equatorial Guinea|ER:Eritrea|EE:Estonia|ET:Ethiopia|FK:Falkland Islands (Islas Malvinas)|FO:Faroe Islands|FJ:Fiji|FI:Finland|FR:France|GF:French Guiana|TF:French Southern and Antarctic Lands|GA:Gabon|GM:Gambia|DE:Germany|GH:Ghana|GI:Gibraltar|GR:Greece|GL:Greenland|GD:Grenada|GP:Guadeloupe|GU:Guam|GT:Guatemala|GG:Guernsey|GN:Guinea|GW:Guinea-Bissau|GY:Guyana|HT:Haiti|HM:Heard Island and McDonald Islands|HN:Honduras|HK:Hong Kong|HU:Hungary|IS:Iceland|IN:India|ID:Indonesia|IR:Iran|IQ:Iraq|IE:Ireland|IM:Isle of Man|IL:Israel|IT:Italy|JM:Jamaica|JP:Japan|JE:Jersey|JO:Jordan|KZ:Kazakhstan|KE:Kenya|KI:Kiribati|CS:Kosovo|KW:Kuwait|KG:Kyrgyzstan|LA:Laos|LV:Latvia|LB:Lebanon|LS:Lesotho|LR:Liberia|LY:Libya|LI:Liechtenstein|LT:Lithuania|LU:Luxembourg|MO:Macau|MK:Macedonia|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|MC:Monaco|MN:Mongolia|ME:Montenegro|MS:Montserrat|MA:Morocco|MZ:Mozambique|MM:Myanmar (Burma)|AZ:Nagorno-Karabakh|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|KP:Nordkorea|NF:Norfolk Island|CY:Northern Cyprus|MP:Northern Mariana Islands|NO:Norway|OM:Oman|PK:Pakistan|PW:Palau|PS:Palestinian Territories (Gaza Strip and West Bank)|PA:Panama|PG:Papua New Guinea|PY:Paraguay|PE:Peru|PH:Philippines|PN:Pitcairn Islands|PL:Poland|PT:Portugal|MD:Pridnestrovie (Transnistria)|PR:Puerto Rico|QA:Qatar|RE:Reunion|RO:Romania|RU:Russia|RW:Rwanda|SH:Saint Helena|KN:Saint Kitts and Nevis|LC:Saint Lucia|PM:Saint Pierre and Miquelon|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|SI:Slovenia|SB:Solomon Islands|SO:Somaliland|GS:South Georgia and the South Sandwich Islands|GE:South Ossetia|ES:Spain|LK:Sri Lanka|SD:Sudan|SR:Suriname|SJ:Svalbard|SZ:Swaziland|SE:Sweden|CH:Switzerland|ZA:Sydafrikanske Republik|KR:Sydkorea|SY:Syria|TW:Taiwan|TJ:Tajikistan|TZ:Tanzania|TH:Thailand|TL:Timor-Leste (East Timor)|TG:Togo|TK:Tokelau|TO:Tonga|TT:Trinidad and Tobago|TN:Tunisia|TR:Turkey|TM:Turkmenistan|TC:Turks and Caicos Islands|TV:Tuvalu|VI:U.S. Virgin Islands|UG:Uganda|UA:Ukraine|AE:United Arab Emirates|GB:United Kingdom|US:United States|UY:Uruguay|UZ:Uzbekistan|VU:Vanuatu|VA:Vatican City|VE:Venezuela|VN:Vietnam|UM:Wake Island|WF:Wallis and Futuna|EH:Western Sahara|YE:Yemen|ZM:Zambia|ZW:Zimbabwe'; 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(defaultCountry) { if ( postCountry != '' ) { defaultCountry = postCountry; } var countryLineArray = country.split('|'); // Split into lines var selObj = document.getElementById('countrySelect'); //selObj.options[0] = new Option('Vælg et land',''); //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] = new Option(countryName, countryCode); //selObj.options[loop + 1] = new Option(countryName, countryCode); } if ( defaultCountry == countryCode ) { selObj.selectedIndex = loop; //selObj.selectedIndex = loop + 1; } } } function populateState() { var selObj = document.getElementById('stateSelect'); 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('Vælg en stat',''); selObj.selectedIndex = 0; } // Populate the drop down with states from the selected country // var stateLineArray = 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('countrySelect').value == countryCode && countryCode != '' ) { // If it's a input element, change it to a select // if ( selObj.type == 'text' ) { parentObj = document.getElementById('stateSelect').parentNode; parentObj.removeChild(selObj); var inputSel = document.createElement("SELECT"); inputSel.setAttribute("name","region"); inputSel.setAttribute("id","stateSelect"); inputSel.setAttribute("className", "s"); //inputSel.style.width = '180px'; parentObj.appendChild(inputSel) ; selObj = document.getElementById('stateSelect'); selObj.options[0] = new Option('Vælg en stat',''); selObj.selectedIndex = 0; } if ( stateCode != '' ) { selObj.options[optionCntr] = new Option(stateName, stateCode); } // See if it's selected from a previous post // if ( stateCode == postState && countryCode == postCountry ) { selObj.selectedIndex = optionCntr; } foundState = true; optionCntr++ } } // If the country has no states, change the select to a text box // if ( ! foundState ) { parentObj = document.getElementById('stateSelect').parentNode; parentObj.removeChild(selObj); // Create the Input Field var inputEl = document.createElement("INPUT"); inputEl.setAttribute("id", "stateSelect"); inputEl.setAttribute("type", "text"); inputEl.setAttribute("name", "region"); inputEl.setAttribute("size", 50); inputEl.setAttribute("className", "s"); inputEl.setAttribute("value", postState); parentObj.appendChild(inputEl) ; } } function selectState(state, objSelect) { for (optionCounter = 0; optionCounter < objSelect.length; optionCounter++) { if ( objSelect.options[optionCounter].value == state ) { objSelect.selectedIndex = optionCounter; } } } function initCountry(country) { populateCountry(country); populateState(); }