/**
* Location JS
*/
var CmooLocation = new Class({
	Implements: Options,
	options:{
		ajaxUrl: ''
	},
	initialize: function(opts){
		this.setOptions(opts);
		//$('OrszagSelect').addEvent('change', this.orszagChange.bind(this));
		$('RegioSelect').addEvent('change', this.regioChange.bind(this));
	},
	/*
	orszagChange: function(e){
		if ($('OrszagSelect').get('value') == '1'){
			this.switchHun();
		}else{
			this.switchForeign();
		}
	},
	*/
	regioChange: function(e){
		new Request.JSON({
			method: 'post',
			url: this.options.ajaxUrl,
			data: {
				'regio': $('RegioSelect').get('value')
			},
			onSuccess: this.regioCallback.bind(this)
		}).send();
	},
	regioCallback: function(obj, text){
		$('VarosSelect').empty();
		$each(obj.varosok, function(item, index){
			new Element('option', {
				'value': index,
				'html': item
			}).inject($('VarosSelect'));
		});
	}
	/*
	switchHun: function(){
		//$('SwitchLayerFOREIGN').setStyle('display', 'none');
		$('SwitchLayerHUN').setStyle('display', 'block');
	},
	switchForeign: function(){
		$('SwitchLayerFOREIGN').setStyle('display', 'block');
		$('SwitchLayerHUN').setStyle('display', 'none');
	}
	*/
});
