﻿var InProgress = new Class({
	Implements: Options, options: {statusLayerId: '',inprogressText: 'Saving...',doneText: 'Done',closeDelay: 500},
	initialize: function(options) {
		this.setOptions(options);

		if ($(this.options.statusLayerId) && this.options.statusLayerId.length > 0) {
			$(this.options.statusLayerId).style.display = 'none';
		}
	},
	End: function(status) {
		if ($(this.options.statusLayerId) && this.options.statusLayerId.length > 0) {
			$(this.options.statusLayerId).set('text', status);
			var ch = new Chain();
			// TODO: Delay
			var first = function() {
				var effect = new Fx.Tween($(this.options.statusLayerId));
				effect.start('opacity', 1, 0).chain(function() {
					$(this.options.statusLayerId).style.display = 'none';
				}.bind(this));
			}.bind(this);
			ch.chain(first);
			ch.callChain(); //.delay(this.options.closeDelay);
		}
	},
	Start: function(status) {
		if ($(this.options.statusLayerId) && this.options.statusLayerId.length > 0) {
			$(this.options.statusLayerId).set('text', status);
			$(this.options.statusLayerId).style.display = 'block';
			$(this.options.statusLayerId).set('style', 'opacity: 1');
		}
	}
});
