$(document).ready(function () {
	$('#country_id').change(function () {
		var country_id = $(this).val();
                var sellang = document.getElementById("sellangru");
                var urllang = '';
                if (sellang == null)
                {
                urllang='&lang=en';
                } 
                if (country_id == '-1') {
			$('#city_id').html('');
			$('#city_id').attr('disabled', true);
			return(false);
		}
		if (country_id == '0') {
	          location.href='index.php?load=stat&cat=43&country=OTHR'+urllang;
	           return(true);
		}

		$('#city_id').attr('disabled', true);
                
                if (sellang != null)
                {
		$('#city_id').html('<option value=load>Загрузка...</option>');
                }
                else
                {
                $('#city_id').html('<option value=load>Load...</option>');
                }
		

		var url = 'query_city.php';
		
		$.get(
			url,
			"country_id=" + country_id+"&city_id="+ $('#city_id').val() + urllang,
			function (result) {
				if (result.type == 'error') {
					alert(error);
					return(false);
				}
				else {
					var options = '';
					$(result.regions).each(function() {
						options = options + '<option value="' + $(this).attr('id') + '">' + $(this).attr('title') + '</option>';
					});
					$('#city_id').html(options);
					$('#city_id').attr('disabled', false);
				}
			},
			"json"
		);
	});

	$('#city_id').change(function () {
		var city_id = $(this).val();
                var country_id=$('#country_id').val()
                var sellang = document.getElementById("sellangru");
                var urllang = '';
                if (sellang == null)
                {
                urllang='&lang=en';
                } 
                if (city_id == '-1') {
			return(false);
		}
		if (city_id == '0') {
		   location.href='index.php?load=stat&cat=43&gorod=-1' + urllang;
			return(true);
		}
                if (city_id != '0') {
		   /* location.href='index.php?load=gorod&country='+country_id+'&gorod='+city_id; */
		    location.href='index.php?load=gorod&gorod='+city_id  + urllang; 
			return(true);
		}
         });
         
        $('input[id^="dnt_"]').change(function () {
                   
           $.get( 'store/donate.php', 'cur_code='+$('input[name="cur_code"]:checked').val()+"&step=1",
                   function (result) {  $('div#donate_pay').replaceWith('<div id="donate_pay">'+result+'</div>');
                                         $('div#donate_inetmoney').replaceWith('<div id="donate_inetmoney"></div>');
                                         $('div#donate_action').replaceWith('<div id="donate_action"></div>');
                                          },
                  'html' )
               
         });


});
      
function PaySystem()
{

 $.get( 'store/donate.php', 'cur_code='+$('input[name="cur_code"]:checked').val()+'&pay_metod='+$('input[name="pay_metod"]:checked').val()+'&step=2',
  function (result) { $('div#donate_inetmoney').replaceWith('<div id="donate_inetmoney"></div>');
                       $('div#donate_action').replaceWith('<div id="donate_action">'+result+'</div>');  },
                  'html' )

};
   
function PayInet()
{

 $.get( 'store/donate.php', 'cur_code='+$('input[name="cur_code"]:checked').val()
                           +'&pay_metod='+$('input[name="pay_metod"]:checked').val()
                           +'&step=3',
  function (result) {  $('div#donate_inetmoney').replaceWith('<div id="donate_inetmoney">'+result+'</div>');
                        $('div#donate_action').replaceWith('<div id="donate_action"></div>'); },
                  'html' )

};  

function PayInetRes(result)
{
 $.get( 'store/donate.php', 'cur_code='+$('input[name="cur_code"]:checked').val()
                           +'&pay_metod='+$('input[name="pay_metod"]:checked').val()
                           +'&pay_system='+$('input[name="pay_system"]:checked').val()+'&step=4',
  function (result) { $('div#donate_action').replaceWith('<div id="donate_action">'+result+'</div>'); },
                     'html')   
};

