function SearchSlider(range, sliderId, textId, valuesHash, count)
{
	this.range = range;
	this.sliderId = '#' + sliderId;
	this.textId = '#' + textId;
	this.valuesHash = valuesHash;
        this.count=5;
        if (count){
            this.count=count;
        }
	if (this.range) {
		$(this.sliderId).slider({
			orientation: "vertical",
			range: true,
			values: [0, this.count],
			step: 1,
			min: 0,
			max: this.count
		});
	} else {
		$(this.sliderId).slider({
			orientation: "vertical",
			range: false,
			value: this.count,
			step: 1,
			min: 0,
			max: this.count
		});
	}

}

SearchSlider.prototype.getSlider = function() {
	return $(this.sliderId);
};

SearchSlider.prototype.setValue = function(value) {
	var _this = this;
	$(this.textId + ' li').each(function() {
		var itemValue = $(this).attr('i');
		var liClass = (itemValue == _this.valuesHash[value]) ? 'active' : '';
		$(this).attr('class', liClass);
	});
};

SearchSlider.prototype.setValues = function(values) {
   
	var max = this.count - values[0];
	var min = this.count - values[1];
        //alert(min+':'+max);
        $(this.textId + ' li').each(function(index) {
		var liValue = index;
		$(this).attr('class', '');

		if (liValue >= min)
			$(this).attr('class', 'active');
		if (liValue > max)
			$(this).attr('class', '');
	});
};


SearchSlider.prototype.onChange = function(ui) {
	(this.range) ?	this.setValues(ui.values) : this.setValue(ui.value);

	var variablesString = findParams();
    updateCount(variablesString);
};

SearchSlider.prototype.bindEvents = function() {
	var _this = this;
	$(this.sliderId).bind('slidechange', function(event, ui) {
		_this.onChange(ui);
	});
};

