function on_blur() {
	var el = jQuery(this);
	if (el.attr('_old_value') != el.val()) {
		el.change();
	}
}

jQuery('select[name^=address]').live('change', function() {
	var el = jQuery(this);
	el.parent().nextAll('div.selector').remove();
	if (el.find('option:selected').attr('_c') > 0) {
		$('.address_place').addClass('dataloading')
		load_children(el.val());
	}else{
		getIndex('parent='+$('.address_place select:last').val()+'&home='+$('#User_home_num').val(), fillIndex)
	}
	el.attr('_old_value', el.val());
});

function create_select(options) {
	return jQuery('<select></select>').attr('name', 'address[]').html(
		options
	).prepend(
		jQuery('<option>')
	).attr('_old_value', 0).blur(on_blur);
}
		
function load_children(parent) {
	getChildren({
		parent: parent,
		options_str: 1
	}, function(data) {
		create_select(data['options_str']).appendTo('.address_place').focus();
		$('.address_place').removeClass('dataloading')
		$(".step_2 select:last, #update_form select:last").uniform();
	});
}


