var ToggleOperation = new Class({
		initialize: function(){
			this.operation = $('operation');
			this.searchForm = $('search-ordination');
			
			if ($('buttonGps')) {
				this.buttonGps = $('buttonGps');
				this.buttonGps.addEvent('click', function(e){
						new Event(e).stop();
						this.sendForm('GET_LOCATION');
				}.bind(this));
			}
			if ($('buttonSearch')) {
				this.buttonSearch = $('buttonSearch');
				this.buttonSearch.addEvent('click', function(e){
						new Event(e).stop();
						this.sendForm('GET_ORDINATIONS_BY_LOCATION');
				}.bind(this));
			}
			if ($('buttonCity')) {
				this.buttonCity = $('buttonCity');
				this.buttonCity.addEvent('click', function(e){
						new Event(e).stop();
						this.sendForm('GET_ORDINATIONS_BY_CITY');
				}.bind(this));
			}
			if ($('buttonSearchAll')) {
				this.buttonAll = $('buttonSearchAll');
				this.buttonAll.addEvent('click', function(e){
					new Event(e).stop();
					this.sendForm('GET_ORDINATIONS_BY_LOCATION_ONE_STEP');
				}.bind(this));
			}
		},
		
		sendForm: function(searchValue) {
			this.operation.value = searchValue;
			this.searchForm.submit();
		}
});

window.addEvent('domready', function(){
		 if ($('operation'))
			var SearchOperations = new ToggleOperation();
}.bind(this));
