function ajax_crs_actions(hash)
	{	
    var req = new JsHttpRequest();

    req.onreadystatechange = function() 
		{
        if (req.readyState == 4) 
			{
			if (req.responseText) alert(req.responseText);

            switch (req.responseJS.action)
				{
				case 'select_country':
					{
					var obj=document.getElementById("mycard_city_cont");
					if (obj)
						{
						obj.innerHTML=req.responseJS.citys;
						}
					}
				break;

				case 'select_city':
					{
					var obj=document.getElementById("mycard_district_cont");
					if (obj)
						{
						obj.innerHTML=req.responseJS.districts;
						}
					}
				break;

				case 'select_district':
					{
					/*
					var obj=document.getElementById("ddm_field_name");
					if (obj)
						{
						obj.value=req.responseJS.street_name;
						}

					var obj=document.getElementById("ddm_field_id");
					if (obj)
						{
						obj.value=req.responseJS.street_id;
						}
					*/
					}
				break;
				}
		    }
	    }

    req.open(null, site_root+'/inc/js_crs.php', true);
    req.send( hash );
	}


//#########################

function update_country_childs(selected_obj, upd_citys, upd_raions, upd_streets)
	{
	var id=selected_obj.options[selected_obj.selectedIndex].value;
	ajax_crs_actions({action: 'select_country', country_id: id, update_citys: upd_citys, update_raions: upd_raions, update_streets: upd_streets});
	}

function update_city_childs(selected_obj, upd_raions, upd_streets)
	{
	var id=selected_obj.options[selected_obj.selectedIndex].value;

	if (cityid>=0) {
	    
	    cityid=id;
	}

	ajax_crs_actions({action: 'select_city', city_id: id, update_raions: upd_raions, update_streets: upd_streets});
	}

function update_raion_childs(selected_obj, upd_streets)
	{
	var id=selected_obj.options[selected_obj.selectedIndex].value;

	if (raionid>=0) {raionid=id;}

	ajax_crs_actions({action: 'select_district', district_id: id, update_streets: upd_streets});
	}

//#########################



function clearCRS_Select(id, cont_id)
	{
	var objcont=document.getElementById(cont_id);

	var obj=document.getElementById(id);
	var obj_name=obj.name;
	var obj_id=obj.id;
	var obj_style=obj.style.cssText;
	
	objcont.innerHTML='<select name="'+obj_name+'" style="'+obj_style+'" id="'+obj_id+'"></select>';
	}

