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(A){this.originalDisplay=(this.originalDisplay=="none")?"block":this.originalDisplay;this.setStyle("display",(A||this.originalDisplay||"block"));return this},tidy:function(){try{if(this.getValue().tidy()){this.value=this.getValue().tidy()}}catch(A){dbug.log("element.tidy error: %o",A)}},findParent:function(A){return $$(A).filter(function(B){return B.hasChild(this)},this)[0]},fxOpacityOk:function(){if(!window.ie6){return true}var A=false;try{if(new Color(this.getStyle("backgroundColor"))){A=true}}catch(B){}return A}});Element.visible=Element.isVisible;if(!Element.empty){Element.extend({empty:function(){return this.setHTML("")}})}var $S=$$;Element.extend({getDimensions:function(A){A=$merge({computeSize:false},A);var E={};function D(G,F){if(F.computeSize){E=G.getComputedSize(F)}else{E.width=G.getSize().size.x;E.height=G.getSize().size.y}return E}try{E=D(this,A)}catch(C){}if(this.getStyle("display")=="none"){var B={};["visibility","display","position"].each(function(F){B[F]=this.style[F]||""},this);this.setStyles({visibility:"hidden",display:"block",position:"absolute"});E=D(this,A);this.setStyles(B)}return $merge(E,{x:E.width,y:E.height})},getComputedSize:function(A){A=$merge({styles:["padding","border"],plains:{height:["top","bottom"],width:["left","right"]},mode:"both"},A);var C={width:0,height:0};switch(A.mode){case"vertical":delete C.width;delete A.plains.width;break;case"horizontal":delete C.height;delete A.plains.height;break}var B=[];$each(A.plains,function(G,F){G.each(function(H){A.styles.each(function(I){B.push((I=="border")?I+"-"+H+"-width":I+"-"+H)})})});var E=this.getStyles.apply(this,B);var D=[];$each(A.plains,function(G,F){C["total"+F.capitalize()]=0;C["computed"+F.capitalize()]=0;G.each(function(H){C["computed"+H.capitalize()]=0;B.each(function(J,I){if(J.test(H)){E[J]=E[J].toInt();if(isNaN(E[J])){E[J]=0}C["total"+F.capitalize()]=C["total"+F.capitalize()]+E[J];C["computed"+H.capitalize()]=C["computed"+H.capitalize()]+E[J]}if(J.test(H)&&F!=J&&(J.test("border")||J.test("padding"))&&!D.test(J)){D.push(J);C["computed"+F.capitalize()]=C["computed"+F.capitalize()]-E[J]}})})});if($chk(C.width)){C.width=C.width+this.offsetWidth+C.computedWidth;C.totalWidth=C.width+C.totalWidth;delete C.computedWidth}if($chk(C.height)){C.height=C.height+this.offsetHeight+C.computedHeight;C.totalHeight=C.height+C.totalHeight;delete C.computedHeight}return $merge(E,C)}});Fx.SmoothShow=Fx.Styles.extend({options:{styles:["padding","border","margin"],transitionOpacity:true,mode:"vertical",heightOverride:null,widthOverride:null},fixStyle:function(C,B){if(!$type(C)=="number"){return C}var A=["margin","padding","width","height"].some(function(D){return B.test(D,"i")});return(A)?C+"px":C},hide:function(){try{if(!this.hiding&&!this.showing){if(this.element.getStyle("display")!="none"){this.hiding=true;this.showing=false;this.hidden=true;var C=this.element.getComputedSize({styles:this.options.styles,mode:this.options.mode});if(this.element.fxOpacityOk()&&this.options.transitionOpacity){C.opacity=1}var A={};$each(C,function(E,D){A[D]=this.fixStyle(0,D)},this);this.chain(function(){if(this.hidden){this.hiding=false;$each(C,function(E,D){C[D]=this.fixStyle(E,D)},this);this.element.setStyles(C).setStyle("display","none")}this.callChain()}.bind(this));this.start(A)}else{this.callChain.delay(10,this);this.fireEvent("onComplete",this.element)}}}catch(B){this.element.hide();this.callChain.delay(10,this);this.fireEvent("onComplete",this.element)}return this},show:function(){try{if(!this.showing&&!this.hiding){if(this.element.getStyle("display")=="none"||this.element.getStyle("visiblity")=="hidden"||this.element.getStyle("opacity")==0){this.showing=true;this.hiding=false;this.hidden=false;var B=this.element.getStyles("visibility","display","position");this.element.setStyles({visibility:"hidden",display:"",position:"absolute"});if(this.element.fxOpacityOk()&&this.options.transitionOpacity){this.element.setStyle("opacity",0)}var D=this.element.getComputedSize({styles:this.options.styles,mode:this.options.mode});this.element.setStyles(B);$each(D,function(F,E){D[E]=this.fixStyle(F,E)},this);if($chk(this.options.heightOverride)){D.height=this.options.heightOverride.toInt()+"px"}else{D.height}if($chk(this.options.widthOverride)){D.width=this.options.widthOverride.toInt()+"px"}if(this.element.fxOpacityOk()&&this.options.transitionOpacity){D.opacity=1}var A={height:"0px",display:""};$each(D,function(F,E){A[E]=this.fixStyle(0,E)},this);this.element.setStyles(A);this.start(D);this.chain(function(){if(!this.options.heightOverride){this.element.setStyle("height","auto")}if(!this.hidden){this.showing=false}this.callChain()}.bind(this))}else{this.callChain();this.fireEvent("onComplete",this.element)}}}catch(C){this.element.setStyles({display:"",visiblity:"visible",opacity:1});this.callChain.delay(10,this);this.fireEvent("onComplete",this.element)}return this},toggle:function(){try{if(this.element.getStyle("display")=="none"||this.element.getStyle("visiblity")=="hidden"||this.element.getStyle("opacity")==0){this.show()}else{this.hide()}}catch(A){this.show()}return this}});Fx.SmoothShow.implement(new Options);Fx.SmoothShow.implement(new Events);Element.extend({smoothShow:function(A){if(arguments[1]){A.heightOverride=arguments[1]}return new Fx.SmoothShow(this,A).show()},smoothHide:function(A){if(arguments[1]){A.heightOverride=arguments[1]}return new Fx.SmoothShow(this,A).hide()}});