var states = Object();
states['Canada'] = 'British Columbia|Alberta|Manitoba|New Brunswick|Newfoundland & Labrador|Northwest Territories|Nova Scotia|Nunavut|Ontario|Prince Edward Island|Quebec|Saskatchewan|Yukon Territory'; //removed 'Other' from the end
states['United States'] = 'Washington DC|Alabama|Alaska|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusets|Michigan|Minnesota|Mississippi|Missouri|Montana|Nebraska|Nevada|New Hampshire|New Jersey|New Mexico|New York|North Carolina|North Dakota|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South Carolina|South Dakota|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming';

var codes = Object();
codes['Canada'] = 'BC|AB|MB|NB|NL|NT|NS|NU|ON|PE|QC|SK|YT';
codes['United States'] = 'DC|AL|AK|AZ|AR|CA|CO|CT|DE|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY';

function setCountry(countryList, stateList, stateCode) {
	stateList.length = 0;
	var country = countryList.options[countryList.selectedIndex].text;
	if (states[country]) {
		stateList.disabled = false;
		stateNames = states[country].split('|');
		stateCodes = codes[country].split('|');
		for (var i=0; i<stateNames.length; i++) {
			stateList.options[i] = new Option(stateNames[i] + (stateCodes[i].length>0?' (' + stateCodes[i] + ')':''), stateCodes[i]);
			if (stateCode != undefined && stateCode.value != null && stateCode.value == stateCodes[i]) {
				stateList.options[i].selected="selected";
			}
		}
		if (typeof stateCode != 'undefined') setState(stateList, stateCode);
		else (stateList.form.stateCode.value = stateList.options[stateList.selectedIndex].value);
	}
}

function setState(stateList, stateCode) {
//if(stateList.options[stateList.selectedIndex].text == 'Other') { stateCode.value = ''; stateCode.style.display=''; stateCode.focus(); } else {
	stateCode.value = stateList.options[stateList.selectedIndex].value;
//stateCode.style.display='none'; }
}
