Element.implement({
	toggle: function() {
		if (this.getStyle('display') != 'none') this.setStyle('display','none');
		else this.setStyle('display','');
	},	
	lift: function() { this.toggle(); },
	toggleVis: function() {
		if (this.getStyle('visibility') != 'hidden') this.setStyle('visibility','hidden');
		else this.setStyle('visibility','visible');
	},	
	hide: function() {
		this.setStyle('display', 'none');
	},	
	show: function() {
		this.setStyle('display', '');
	},
	isShowing: function() {
		return this.getStyle('display') != 'none';
	},
	moveToBottom: function() {
		var w = this.clone(true, true);
		this.destroy();
		$(document.body).adopt(w);
		return w;
	},
	disable: function(txt)	{
		if( this.toString().indexOf('HTMLInput') > 0 ) {
			this.addClass('disabled');
			if(txt) this.value = txt;
			this.disabled = true;
			return;
		}
		
		$$('#' + this.id + ' select, #' + this.id + ' input').setProperty('disabled', true);
		
		if( $(this.id + '_disable') ) {
			$(this.id + '_disable').destroy();
		}
		
		this.setStyle('position', 'relative');
		if( !$(this.id + '_disable') ) {
			var coords = this.getSize();
			this.adopt(
				new Element('div', {
					'id': this.id + '_disable',
					'styles': {
						'background-color': !txt ? '#fff' : '#' + txt,
						'width': coords.x,
						'height': coords.y,
						'top': '0',
						'left': '0',
						'position': 'absolute',
						'opacity': 0.7
					}
				})
			);
		}
	},
	
	enable: function(txt) {
		
		if( this.toString().indexOf('HTMLInput') > 0 ) {
			this.disabled = false;
			this.removeClass('disabled');
			if(txt) this.value = txt;
			return;
		}
		
		$$('#' + this.id + ' select, #' + this.id + ' input').setProperty('disabled', false);
		
		this.setStyle('position', '');
		if( $(this.id + '_disable') ) {
			$(this.id + '_disable').destroy();
		}
	},
	
	setWidth: function(num) {
		this.setStyle('width', num.toString() + 'px');
	},
	
	setHeight: function(num) {
		this.setStyle('height', num.toString() + 'px');
	},
	
	getWidth: function() {
		return this.isShowing() ? this.getSize().x : 0;
	},
	
	getHeight: function() {
		return this.isShowing() ? this.getSize().y : 0;
	},
	
	getX: function() {
		return this.getPosition().x;
	},
	
	/*setX: function(num) {
		this.setStyle('left', Math.round(num.toInt()) + 'px');
	},
	
	getY: function() {
		return this.getPosition().y;
	},
	
	setY: function(num) {
		this.setStyle('top', Math.round(num.toInt()) + 'px');
	},
	
	setPosition: function(x, y) {
		this.setX(x);
		this.setY(y);
	},*/
	
	getBottomY: function() {
		return this.getHeight() + this.getPosition().y;
	}
});
