/**
 * Fx.ProgressBar
 *
 * @version		1.1
 *
 * @license		MIT License
 *
 * @author		Harald Kirschner <mail [at] digitarald [dot] de>
 * @copyright	Authors
 */

Fx.ProgressBar = new Class({

	Extends: Fx,

	options: {
		text: null,
		url: null,
		transition: Fx.Transitions.Circ.easeOut,
		fit: true,
		link: 'cancel'
	},

	initialize: function(element, options) {
		this.element = $(element);
		this.bar = this.element.getElement('.bar');
		this.parent(options);
				
		this.bar.fx = new Fx.Tween(this.bar, {
			duration: 100,
			transition: this.options.transition,
			property: 'width',
			unit: '%',
			link: 'cancel'
		});
		
		this.set(0);
	},

	start: function(to, total) 
	{
		return this.parent(this.now, (arguments.length == 1) ? to.limit(0, 100) : to / total * 100);
	},

	set: function(to) 
	{
		this.now = to;
		this.bar.fx.start(to);
		
		return this;
	}

});
