$(document).ready(function(){

	$('a.light_gallery').lightBox({
		fixedNavigation:true,
		overlayBgColor: '#54BDEA',
		overlayOpacity: 0.6,
		/*imageLoading: '../img/loading.gif',
		imageBtnClose: 'http://example.com/images/close.gif',
		imageBtnPrev: 'http://example.com/images/prev.gif',
		imageBtnNext: 'http://example.com/images/next.gif',*/
		containerResizeSpeed: 350,
		txtImage: 'Снимка',
		txtOf: 'от'
	});
	
	$("#countries").change(function(){
		getCitiesByCountry(this.options[this.selectedIndex].value);	
	});
	
	
	
	if(cur_country_id != '0'){
		countries_list_url += '/' + cur_country_id;
		if(cur_city_id != '0'){
			getCitiesByCountry(cur_country_id,cur_city_id);
		}else{
			getCitiesByCountry(cur_country_id);
		}
		
	}
	getAllCountry(countries_list_url);
		
	$('#SearchTypes').change(function(){
		$('#SearchForm').attr('action',this.options[this.selectedIndex].value);
	});

	
});

function getAllCountry(url){
	$.ajax({
		type: "GET",
		url: url,
		success:function(html){
			$("#countries").html(html);
		}
	});
};
function getCitiesByCountry(country_id, city_id){
	$.ajax({
		type: "GET",
		url: cities_list_url+country_id+'/'+city_id,
		success:function(html){
			$("#cities").html(html);
		}
	});
};