var SelectFilter = Class.create();
SelectFilter.prototype = {
	version: 0.1,
	debug: false,

	applyFilterButton:null,
	filterSelect: null,
	targetUrl: null,
	targetPane: null,
	indicator: null,
	options:[],
	
	initialize: function (options) {
		if(options) {
		this.options = options;
		} else {
			alert("No options were provided to the control")
			return false;
		}

		this.container = $(this.options.container);
		this.applyFilterButton = $(this.options.applyFilterButton);
		this.filterSelect = $(this.options.filterSelect);
		this.targetPane = $(this.options.targetPane);

		//Make the select on change
		Event.observe(this.filterSelect, "change", this.updateTargetPane.bindAsEventListener(this));
		
	},
	
	filterSelectChange: function() {
		this.updateTargetPane();
	},
	
	startIndicator: function() {
		if(! this.indicator) {

			this.indicator = new AjaxIndicator(this.targetPane.id);
		}
	},

	stopIndicator: function() {
		if(this.indicator != false) {
			this.indicator.close();

			this.indicator = false;
		}
	},
	
	updateTargetPane: function() {
		this.startIndicator();

		new Ajax.Updater(
		  this.targetPane,
		  this.options.targetUrl,
		  {asynchronous: true,
		  evalScripts: false,
		  onComplete: function(request, json) {
		  },
		  parameters: 'filterSelect='+Form.Element.getValue(this.filterSelect.name)
		  });
		
		this.stopIndicator();
	}
	
}
