$(document).ready(function(){
	//******************************************** ГЕО ***************************************************
	//Создание списка стран 
	var city_id, region_id, country_id;
	setGeoLoaders();
	
	
	function setGeoLoaders(){ //Ajax загрузка городов, регионов, стран
			$("select[name='regcountry']").change(function(e){
				e.preventDefault();
				$("#regcountry option[value=0]").attr('selected', false);
				$("#regregion").hide();
				$("#regionLabelHolder").hide();
				$("#regcity").hide();
				$("#regcityLabelHolder").hide();
				$.post("/xajax/xajax.php", {
					func: "getGeoList",
					geoParent: $(this).attr('value'),
					geoTarget: "region"
				}, function(xml){
					//Пришел ответ-список регионов
					$("select[name='regregion']").html($("option", xml).get());
					$("select[name='regregion'] > option[value=0]").attr('selected', true);
					$("select[name='regregion']").show();
					$("#regionLabelHolder").show();
					
					$("#regcity").hide();
					$("#regcityLabelHolder").hide();
					
					//Обработчик выбора региона 
					$("select[name='regregion']").change(function(){
						$.post("/xajax/xajax.php", {
							func: "getGeoList",
							geoParent: $("select[name='regregion']").attr('value'),
							geoTarget: "city"
						}, function(xml){
							$("#regcity").show();
							$("#regcityLabelHolder").show();
							//Пришел ответ-список городов
							$("select[name='regcity']").html($("option", xml).get());
							$("select[name='regcity'] > option[value=0]").attr('selected', true);
							
							if (city_id > 0) {
								$("#regcity").attr('value', city_id);
								city_id = 0;
							}
						}, "html");
					});
					
					if (region_id > 0) {
						$("#regregion").attr('value', region_id);
						region_id = 0;
						$("#regregion").change();
					}
					
				}, "html");
				
			});
					$("select[name='regregion']").change(function(){
						$.post("/xajax/xajax.php", {
							func: "getGeoList",
							geoParent: $("select[name='regregion']").attr('value'),
							geoTarget: "city"
						}, function(xml){
							$("#regcity").show();
							$("#regcityLabelHolder").show();
							//Пришел ответ-список городов
							$("select[name='regcity']").html($("option", xml).get());
							$("select[name='regcity'] > option[value=0]").attr('selected', true);
							
							if (city_id > 0) {
								$("#regcity").attr('value', city_id);
								city_id = 0;
							}
						}, "html");
					});
			
	};
	
	
	$('.your-inf').hide();
$('.b-your-inf img').attr('src','img/plus1.gif');

$('.b-your-inf').toggle(function(event){
 $('.your-inf').show();
 $('.b-your-inf a').css('color', '#419639');
 $('.b-your-inf a').css('borderColor', '#419639');
 $('.b-your-inf img').attr('src','img/minus.gif')},
 function(event){
 $('.your-inf').hide();
 $('.b-your-inf a').css('color', '#396EA9');
 $('.b-your-inf a').css('borderColor', '#396EA9');
 $('.b-your-inf img').attr('src','img/plus1.gif');
 });
	//******************************************** ГЕО ***************************************************	
});

