function getRayonList(sel) {
	$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {   
	      alert(textStatus);
	      alert(errorThrown);
	      alert(XMLHttpRequest.responseText);
	  }});
	
	var oblastId = $("#select_oblast").val();
	$("#select_rayon").find('option:not(:first)').remove();
	$("#select_city").find('option:not(:first)').remove();
	
	if(oblastId.length > 0) {
		$.getJSON("city_service.php", { id: oblastId }, function(data) {
			createCityList(data, "#select_rayon")
		});
		
	}
}

function getCityList(sel) {
	$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {   
	      alert(textStatus);
	      alert(errorThrown);
	      alert(XMLHttpRequest.responseText);
	  }});
	
	var rayonId = $("#select_rayon").val();
	$("#select_city").find('option:not(:first)').remove();
	
	if(rayonId.length > 0) {
		$.getJSON("city_service.php", { id: rayonId }, function(data) {
			createCityList(data, "#select_city")
		});
	}
}

function createCityList(data, elementId) {
	$.each(data, function(key, value) {   
	     $(elementId).
	          append($("<option></option>").
	          attr("value", key).
	          text(value)); 
	});
}

