function doStateChange(form) {
    if(form != null && form.state != null && form.country !=null) {
		// if other is selected, then pre-select -Select Country- for the country
        if(form.state.selectedIndex == 1)
			form.country.selectedIndex = 0;
        // if a state is selected, then pre-select United States for the country
		if(form.state.selectedIndex >= 2 && form.state.selectedIndex <= 51)
            form.country.selectedIndex = 1;
        // if a province/territory is selected, then pre-select Canada for the country
        if(form.state.selectedIndex >= 52 && form.state.selectedIndex <= 68)
            form.country.selectedIndex = 2;
    }
}

function doCountryChange(form) {
    if(form != null && form.state != null && form.country !=null) {
        var selectedCountryCode = form.country.options[form.country.selectedIndex].value.toUpperCase();

        // if selected country isn't Canada or the US, then pre-select 'Outside the US or Canada'
        if(selectedCountryCode != 'US' && selectedCountryCode != 'CA')
            form.state.selectedIndex = 1;  // 1 = 'Outside the US or Canada'

        // if the country selection is United States, jump to the first state in the list
        if(selectedCountryCode == 'US')
            form.state.selectedIndex = 2;  // 2 = 'Alabama'

        // if the country selection is Canada, jump to the first province in the list
        if(form.country.options[form.country.selectedIndex].value == 'CA')
            form.state.selectedIndex = 52;  // 53 = 'Alberta'
    }
}
