priceSlider = {

	value: null,
	realRange: null,
	layout: null,
	currency: null,
	defaultMessage: null,

	loadSlider: function (initialValue) {

		this.realRange = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000];
		this.value = this.fromRangeToValue(initialValue);

		$("#priceSlider").slider({

			range: "min",
			min: 0,
			max: 9,
			value: this.value,
			
			slide: function (event, ui) {
				priceSlider.value = ui.value;
				priceSlider.printValue();
			},

			change: function (event, ui) {
				priceSlider.value = ui.value;
				listing.filterByCommon("price", priceSlider.fromValueToRange(priceSlider.value));
			}

		});

		this.printValue();

	},

	fromValueToRange: function (value) {
		return this.realRange[value];
	},

	fromRangeToValue: function (range) {
		var key; 
		for (var i = 0; i < this.realRange.length; i++) {
			if (this.realRange[i] == range) {
				key = i;
			}
		}
		return key;
	},

	setMessages: function (msg, layout, currency) {
		this.defaultMessage = msg;
		this.layout = layout;
		this.currency = currency;
	},

	printValue: function () {
		price = this.fromValueToRange(this.value);
		if(price == 1000) {
			$("#textSlider").html("<i>" + this.defaultMessage + "</i>");
		} else {
			$("#textSlider").html(this.layout + " <strong>" + price + "</strong> " + this.currency);
		}
	}

}


