Places = {
	chngCountry: function(country) {
		this.country = country; 		
		this.emptySelect($('region'));
		this.addDefaultOption($('region'));
		this.places.select(function(place) {
			return !this.country || place.country == this.country;
		}.bind(this)).pluck('region').each(function (region) {
			if (!$A($('region').options).detect(function (option) {
				return option.value == region;
			})) {
				var option = document.createElement('option');				
				option.appendChild(document.createTextNode(region));
				option.value = region;
				$('region').appendChild(option);
			}				
		});
		this.chngRegion(false);
		
	},
	chngRegion: function(region) {
		this.region = region;
		this.emptySelect($('place'));
		this.addDefaultOption($('place'));
		this.places.select(function(place) {
			return (!this.country || place.country == this.country) && (!this.region || this.region == place.region);
		}.bind(this)).pluck('place').each(function (place) {
			var option = document.createElement('option');
			option.appendChild(document.createTextNode(place));
			option.value = place;
			$('place').appendChild(option);			
		});
	}, 
	emptySelect: function(select) {		
		while(select.firstChild) {			
			Element.remove(select.firstChild);
		}
	},
	addDefaultOption: function(select) {
		var option = document.createElement('option');
		option.appendChild(document.createTextNode('-- wszystkie --'));
		option.value = '';
		select.appendChild(option);
	}
} 
