/*
Script: Element.Visibility.js
	Contains useful Element methods to hide/show elements in an elegant way.

License:
	MIT-style license.
*/

/*
Native: Element
	Custom Native to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

Element.implement({


	visible: function(){
		return (this.getStyle('display') || 'none') != 'none' && this.getStyle('visibility') != 'hidden';
	},


	show: function(){
		return this.setStyle('display', this.$attributes.display || '').setOpacity(1);
	},

	hide: function(stay){
		if (!this.$attributes.display){
			var display = this.getStyle('display');
			this.$attributes.display = (display == 'none') ? '' : display;
		}
		return stay ? this.setOpacity(0) : this.setStyle('display', 'none');
	},


	toggle: function(stay){
		return this[this.visible() ? 'hide' : 'show'](stay);
	}

});

