/**
 * Selector for selecting ranges in select or inputing own
 * values.
 * The selector is used mainly on advanced search page.
 *
 * @author Vlada Kobetic kobetic@gmail.com
 */
var ValueRangeSelectorController = Class.create();
ValueRangeSelectorController.prototype = {

	initialize: function( ) {
		this.view = null;
	},
	
	initializeOnSelectHandler: function() {
		var select = this.view.getSelect();
		var oThis = this;
		select.observe("change", function(event) {
			// only input by hand value is need to be caught
			if(select.value == 1) {
				oThis.view.showValueInput();
			} else { 
				oThis.view.hideValueInput();
			}
		});
	}
	
	,
	hideValueInput: function() {
		this.view.hideValueInput();
	}
	
}


var ValueRangeSelectorView = Class.create();
ValueRangeSelectorView.prototype = {

	/**
	 * @param {String} prefix prefix of all elements, 
	 *							connected to the selector
	 */
	initialize: function( prefix ) {
		this.prefix = prefix;
	},
	
	showValueInput: function() {
		$( this.prefix + "-input-box" ).show();
		$( this.prefix + "-input" ).focus();
	},
	
	hideValueInput: function() {
		$( this.prefix + "-input-box" ).hide();
	},
	
	getSelect: function() {
		return $( this.prefix + "-select" );
	}
} 

