function StateSwitcher(states, states_keys, provinces, provinces_keys) {
	
	this.switchStates = function(stateInputParentId, currentCountry, currentState) {
		var parent = document.getElementById(stateInputParentId);
		if(parent.firstChild)
			parent.removeChild(parent.firstChild);
		var stateInput = null;
		if(currentCountry == "CA") {
			stateInput = document.createElement("select");
			var option = document.createElement("option");
			option.appendChild(document.createTextNode("-- Select One --"));
			stateInput.appendChild(option);
			
			for(var i=0; i<me.provinces.length; i++) {
				option = document.createElement("option");
				option.appendChild(document.createTextNode(me.provinces[i]));
				option.value = me.provinces_keys[i];
				if(currentState && currentState == me.provinces_keys[i]) {
					option.selected = true;
				}
				stateInput.appendChild(option);
			}
			
		} else if(currentCountry == "US") {
			stateInput = document.createElement("select");
			var option = document.createElement("option");
			option.appendChild(document.createTextNode("-- Select One --"));
			stateInput.appendChild(option);
			
			for(var i=0; i<me.states.length; i++) {
				option = document.createElement("option");
				option.appendChild(document.createTextNode(me.states[i]));
				option.value = me.states_keys[i];
				if(currentState && currentState == me.states_keys[i]) {
					option.selected = true;
				}
				stateInput.appendChild(option);
			}
		} else {
			stateInput = document.createElement("input");
			stateInput.type = "text";
		}
		if(stateInput) {
			stateInput.name = "state";
			stateInput.className = "sized";
			parent.appendChild(stateInput);
		}
	}

	var me = this;
	this.states = states;
	this.states_keys = states_keys;
	this.provinces = provinces;
	this.provinces_keys = provinces_keys;
}