Element.extend({
        isVisible: function() {
                return this.getStyle('display') != 'none';
        },
        toggle: function() {
                return this[this.isVisible() ? 'hide' : 'show']();
        },
        hide: function() {
                this.originalDisplay = this.getStyle('display'); 
                this.setStyle('display','none');
                return this;
        },
        show: function(display) {
                this.originalDisplay = (this.originalDisplay=="none")?'block':this.originalDisplay;
                this.setStyle('display',(display || this.originalDisplay || 'block'));
                return this;
        },
        tidy: function(){
                try {   
                        if(this.getValue().tidy())this.value = this.getValue().tidy();
                }catch(e){dbug.log('element.tidy error: %o', e);}
        },
        findParent: function(collection){
                return $$(collection).filter(function(el){
                        return el.hasChild(this);
                }, this)[0];
        },
        fxOpacityOk: function(){
                if (!window.ie6)return true;
                var isColor = false;
                try {
                        if (new Color(this.getStyle('backgroundColor'))) isColor = true;
                }catch(e){}
                return isColor;
        }
});
Element.visible = Element.isVisible;


if(!Element.empty) {
        Element.extend({
                empty: function(){
                        return this.setHTML('');
                }
        });
}
var $S = $$;

