function updateState(countryId, formId) {
	var statePath = "#" + formId + " .state";
	var cityPath = "#" + formId + " .city";
	
	displayMiddleName = (countryId == '804' || countryId == '643') ? "" : "none"; //Check is it UKRAINE OR RUSSIA
	$( "#" + formId + " .middle_name-row" ).css("display", displayMiddleName);
	//$( "#" + formId + " #StarDecoratorForState" ).css("display", displayMiddleName);
	
	displayMiddleName = (countryId == '804' || countryId == '643') ? "block" : "none"; //Check is it UKRAINE OR RUSSIA
	$( "#" + formId + " dd#middle_name-element ,  #" + formId + " dt#middle_name-label" ).css("display", displayMiddleName);
	
	$(statePath).attr("disabled", true);
	$(cityPath).attr("disabled", true);
	url = typeof(language)  == 'undefined' ? "/locale/states?reg_country=" + countryId : language + "/locale/states?reg_country=" + countryId;
	$.get(url, function(data) {
		if ( data.indexOf('<option') > 0 ) {
			$(statePath).replaceWith("<select id=\"state_id\" name=\"state_id\" class=\"state\"  onchange=\"updateCity(this.value,'"+formId+"')\" ></select>");
			$(statePath).html(data);
		} else {
			$(statePath).replaceWith("<input id=\"state\"  name=\"state\" class=\"state\" ></input>");
		} 
		$(cityPath).replaceWith("<input id=\"city\" name=\"city\" class=\"city\" ></input>");
		$(cityPath).attr("disabled", false);
	});
}

function updateCity(stateId, formId){	
	var cityPath = "#" + formId + " .city";

	$(cityPath).attr("disabled", true);
	url = "/locale/cities?reg_state=" + stateId + "&reg_country=" + $("#" + formId + " .country").val();
	url = typeof(language)  == 'undefined' ? url : language + url;
	$.get(url, function(data) {
		if ( data.indexOf('<option') > 0 ) {
			$(cityPath).replaceWith("<select id=\"city_id\" name=\"city_id\" class=\"city\" ></select>");
			$(cityPath).html(data);
		} else {
			$(cityPath).replaceWith("<input id=\"city\" name=\"city\" class=\"city\" ></input>");
		} 
	});
}