var XPSlider = new Class({
	Extends: Slider,
	Implements: Options,
	options: {/*
		onSlide: $empty(points,money)*/
		initial: undefined,
		wheel: true,
		pointMin: 0,
		pointMax: 100,
		pointValue: 1
	},
	initialize: function(element, options){
		element = $(element);
		this.setOptions(options);
		if (this.options.initial == undefined)
			this.options.initial = this.options.pointMax;
		this.options.steps = this.options.pointMax - this.options.pointMin;

		this.parent(element, element.getElement('.knob'), {
			wheel: true,
			steps: this.options.steps,
			initial: this.options.initial,
			onChange: function(step){
				var points = (step/this.options.steps)*this.options.pointMax + (1-step/this.options.steps)*this.options.pointMin;
				var money = (this.options.pointMax - points) / this.options.pointValue;
				this.fireEvent('slide', [points, money]);
			}
		});

		this.set(this.options.initial - this.options.pointMin);
	},
	updatePoints: function(points){
		if (points > this.options.pointMax)
			points = this.options.pointMax;
		else if(points < this.options.pointMin)
			points = this.options.pointMin;
		this.set((points*this.options.steps - this.options.steps*this.options.pointMin)/(this.options.pointMax - this.options.pointMin));
	}
});

function number_format(number, decimals, dec_point, thousands_sep){
	if (decimals === undefined)
		decimals = '0';
	if (dec_point === undefined)
		dec_point = '.';
	if (thousands_sep === undefined)
		thousands_sep = ',';

	number = new Number(number);

	var split = number.toFixed(decimals).toString().split('.',2);
	if (split[1] == undefined)
		split[1] = 0;

	split[0] = split[0].replace(/(\d)(?=(\d{3})+$)/g,'$1,');
	if (decimals == 0)
		return split[0];
	else
		return split[0]+dec_point+split[1];
}

function clean_number(number, dec_point, thousands_sep){
	if (dec_point === undefined)
		dec_point = '.';
	if (thousands_sep === undefined)
		thousands_sep = ',';

	number = number.replace(thousands_sep,'','g');
	
	return number.replace(dec_point,'.');
}