/*
---

name: Mask.Extended

description: Adds opacity tween fade effect to Mask

authors: Rolf Langenhuijzen

license: MIT-style license.

requires: [Mask]

provides: Mask.Extended

...
*/

Mask.Extended = new Class({

	Extends: Mask,

	options: {
		opacity: 0.8,
		fxOptions: {
			link: 'cancel',
			duration: 900
		}
	},

	initialize: function(){
		this.parent.apply(this, arguments);
		this.element.setStyle('opacity', 0);
		this.element.set('tween', this.options.fxOptions);
	},

	showMask: function(useOriginal){
		if (useOriginal) return this.parent();
		this.element.setStyle('display', 'block');
		this.element.tween('opacity', this.options.opacity).get('tween').chain(this.showMask.bind(this, true));
	},

	hide: function(useOriginal){
		if (useOriginal) return this.parent();
		this.element.tween('opacity', 0).get('tween').chain(this.hide.bind(this, true));
	}

});
