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 <= 52)
            form.country.selectedIndex = 1;
        // if a province/territory is selected, then pre-select Canada for the country
        if(form.state.selectedIndex >= 53 && form.state.selectedIndex <= 65)
            form.country.selectedIndex = 2;
		// if a province/territory is selected, then pre-select Australia for the country
		if(form.state.selectedIndex >= 116 && form.state.selectedIndex <= 126)
            form.country.selectedIndex = 8;
		// if a province/territory is selected, then pre-select UK for the country
		if(form.state.selectedIndex >= 73 && form.state.selectedIndex <= 76)
            form.country.selectedIndex = 165;
				// if a province/territory is selected, then pre-select ESP for the country
		if(form.state.selectedIndex >= 77 && form.state.selectedIndex <= 84)
            form.country.selectedIndex = 147;
		// if a province/territory is selected, then pre-select MEX for the country
		if(form.state.selectedIndex >= 85 && form.state.selectedIndex <= 115)
            form.country.selectedIndex = 103;	
						
    }
}

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' && selectedCountryCode != 'AU' && selectedCountryCode != 'GB' && selectedCountryCode != 'ES' && selectedCountryCode != 'MX')
            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 = 53;  // 53 = 'Alberta'
			
		// if the country selection is Australia, jump to the first province in the list
		if(form.country.options[form.country.selectedIndex].value == 'AU')
            form.state.selectedIndex = 116;  // 116 = Australian Capital Territory
				// if the country selection is UK, jump to the first province in the list
		if(form.country.options[form.country.selectedIndex].value == 'GB')
            form.state.selectedIndex = 73;  // 73 = 'England'
			
		if(form.country.options[form.country.selectedIndex].value == 'ES')
            form.state.selectedIndex = 77;  // 77 'Madrid'
			
		if(form.country.options[form.country.selectedIndex].value == 'MX')
            form.state.selectedIndex = 85;  // 85 = 'DF'				
    }
}

