var stateabbrs = new Array("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "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");
var states = new Array("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", "NewJersey", "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 provs = new Array("Alberta", "British Columbia", "Manitoba", "New Brunswick", "Newfoundland", "Northwest Territories", "Nova Scotia", "Ontario", "Prince Edward Island", "Quebec", "Saskatchewan", "Yukon Territories");
var provabbrs = new Array("Al", "Bc", "Mn", "Nb", "Nf", "Nt", "Ns", "On", "Pi", "Qu", "Sa", "Yt");
function tunestate(country, state){
	var stateval=state[state.selectedIndex].value;
	var wasselect = false;
	for(i=state.length;i>=0;i--)state.options[i]=null;
	if (country[country.selectedIndex].value == 'US'){
		state.options[state.length]=new Option();
		state.options[state.length -1].text="-- Select state --";
		state.options[state.length -1].value="";
		for(i=0;i<states.length;i++){
			state.options[state.length]=new Option();
			state.options[state.length -1].text=states[i];
			state.options[state.length -1].value=stateabbrs[i];
			if(stateval == stateabbrs[i])
				state.options[state.length -1].selected=true;
		}
	}
	if (country[country.selectedIndex].value == 'CA'){
		state.options[state.length]=new Option();
		state.options[state.length -1].text="-- Select province --";
		state.options[state.length -1].value="";
		state.options[state.length -1].selected=true;
		for(i=0;i<provs.length;i++){
		state.options[state.length]=new Option();
		state.options[state.length -1].text=provs[i];
		state.options[state.length -1].value=provabbrs[i];
		if(stateval == provabbrs[i])
			state.options[state.length -1].selected=true;
		}
	}
	if ((country[country.selectedIndex].value != 'US')&& (country[country.selectedIndex].value != 'CA')){
		state.options[state.length]=new Option();
		state.options[state.length -1].text="N/A";
		state.options[state.length -1].value="";
		state.selectedIndex=0;
		state.disabled=true;
	} else {
		state.disabled=false;
	}
}
