/* CSM, 11/6/2006 addition of USStates and CanadaStates strings.
	I'm adding these because the arrays don't seem to properly reference
	country names. (The id of a state references the wrong country name.)
	This is an alternate and less buggy solution. */
var USStates = 'Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,District of Columbia,Florida,Georgia,Hawaii,Idaho,Illinois,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Maryland,Massachusetts,Michigan,Minnesota,Mississippi,Missouri,Montana,Nebraska,Nevada,New Hampshire,New Jersey,New Mexico,New York,North Carolina,North Dakota,Ohio,Oklahoma,Oregon,Pennsylvania,Puerto Rico,Rhode Island,South Carolina,South Dakota,Tennessee,Texas,Utah,Vermont,Virginia,Washington,West Virginia,Wisconsin,Wyoming';
var CanadaStates = 'Alberta,British Columbia,Manitoba,New Brunswick,Newfoundland,Northwest Territories,Nova Scotia,Ontario,Prince Edward Island,Quebec,Saskatchewan,Yukon';

function StateSelectorChange (stateSelector, stateOtherSpan, countrySelector) 
//CSM, 11/3/06, changed function declaration to fix "countryotherspan" bug.
//function StateSelectorChange (stateSelector, stateOtherSpan, countrySelector, countryOtherSpan) 
{
	var stateIndex = stateSelector.selectedIndex - 1;
	var stateName = stateSelector[stateSelector.selectedIndex].value;
	
	if(StateA[stateIndex]) 
	{
		CountryID = StateA[stateIndex].countryid;
		stateOtherSpan.style.display = 'none';
		
		// CSM, 11/2/2006 addition: Double-check country code using strings.
		if (USStates.indexOf(stateName) != -1) CountryID = 1;
		else if (CanadaStates.indexOf(stateName) != -1) CountryID = 2; 

		if(CountryID && (countrySelector != null)) 
		{
			for (i = 0; i < CountryA.length; i++)
			{
				if (CountryA[i]['id'] == CountryID)
				{
					countrySelector.selectedIndex = i + 1;
					//CSM, 11/3/06, also commented this buggy line of code 
					// (which does not appear to be in use)
					//countryOtherSpan.style.display = 'none';
				}				
			}
		}
	}
	else if (stateIndex == -1) 
	{
		stateOtherSpan.style.display = 'none';
	} 
	else 
	{
		stateOtherSpan.style.display = 'inline';
	}
	return true;
}