Fx.Reveal=new Class({Extends:Fx.Morph,options:{link:"cancel",styles:["padding","border","margin"],transitionOpacity:!Browser.Engine.trident4,mode:"vertical",display:function(){return this.element.get("tag")!="tr"?"block":"table-row"},hideInputs:Browser.Engine.trident?"select, input, textarea, object, embed":false,opacity:1},dissolve:function(){try{if(!this.hiding&&!this.showing){if(this.element.getStyle("display")!="none"){this.hiding=true;this.showing=false;this.hidden=true;this.cssText=this.element.style.cssText;var d=this.element.getComputedSize({styles:this.options.styles,mode:this.options.mode});this.element.setStyle("display",$lambda(this.options.display).apply(this));if(this.options.transitionOpacity){d.opacity=this.options.opacity}var b={};$each(d,function(f,e){b[e]=[f,0]},this);this.element.setStyle("overflow","hidden");var a=this.options.hideInputs?this.element.getElements(this.options.hideInputs):null;this.$chain.unshift(function(){if(this.hidden){this.hiding=false;$each(d,function(f,e){d[e]=f},this);this.element.style.cssText=this.cssText;this.element.setStyle("display","none");if(a){a.setStyle("visibility","visible")}}this.fireEvent("hide",this.element);this.callChain()}.bind(this));if(a){a.setStyle("visibility","hidden")}this.start(b)}else{this.callChain.delay(10,this);this.fireEvent("complete",this.element);this.fireEvent("hide",this.element)}}else{if(this.options.link=="chain"){this.chain(this.dissolve.bind(this))}else{if(this.options.link=="cancel"&&!this.hiding){this.cancel();this.dissolve()}}}}catch(c){this.hiding=false;this.element.setStyle("display","none");this.callChain.delay(10,this);this.fireEvent("complete",this.element);this.fireEvent("hide",this.element)}return this},reveal:function(){try{if(!this.showing&&!this.hiding){if(this.element.getStyle("display")=="none"){this.showing=true;this.hiding=this.hidden=false;var d;this.cssText=this.element.style.cssText;this.element.measure(function(){d=this.element.getComputedSize({styles:this.options.styles,mode:this.options.mode})}.bind(this));$each(d,function(f,e){d[e]=f});if($chk(this.options.heightOverride)){d.height=this.options.heightOverride.toInt()}if($chk(this.options.widthOverride)){d.width=this.options.widthOverride.toInt()}if(this.options.transitionOpacity){this.element.setStyle("opacity",0);d.opacity=this.options.opacity}var b={height:0,display:$lambda(this.options.display).apply(this)};$each(d,function(f,e){b[e]=0});this.element.setStyles($merge(b,{overflow:"hidden"}));var a=this.options.hideInputs?this.element.getElements(this.options.hideInputs):null;if(a){a.setStyle("visibility","hidden")}this.start(d);this.$chain.unshift(function(){this.element.style.cssText=this.cssText;this.element.setStyle("display",$lambda(this.options.display).apply(this));if(!this.hidden){this.showing=false}if(a){a.setStyle("visibility","visible")}this.callChain();this.fireEvent("show",this.element)}.bind(this))}else{this.callChain();this.fireEvent("complete",this.element);this.fireEvent("show",this.element)}}else{if(this.options.link=="chain"){this.chain(this.reveal.bind(this))}else{if(this.options.link=="cancel"&&!this.showing){this.cancel();this.reveal()}}}}catch(c){this.element.setStyles({display:$lambda(this.options.display).apply(this),visiblity:"visible",opacity:this.options.opacity});this.showing=false;this.callChain.delay(10,this);this.fireEvent("complete",this.element);this.fireEvent("show",this.element)}return this},toggle:function(){if(this.element.getStyle("display")=="none"){this.reveal()}else{this.dissolve()}return this},cancel:function(){this.parent.apply(this,arguments);this.element.style.cssText=this.cssText;this.hiding=false;this.showing=false;return this}});Element.Properties.reveal={set:function(a){var b=this.retrieve("reveal");if(b){b.cancel()}return this.eliminate("reveal").store("reveal:options",a)},get:function(a){if(a||!this.retrieve("reveal")){if(a||!this.retrieve("reveal:options")){this.set("reveal",a)}this.store("reveal",new Fx.Reveal(this,this.retrieve("reveal:options")))}return this.retrieve("reveal")}};Element.Properties.dissolve=Element.Properties.reveal;Element.implement({reveal:function(a){this.get("reveal",a).reveal();return this},dissolve:function(a){this.get("reveal",a).dissolve();return this},nix:function(){var a=Array.link(arguments,{destroy:Boolean.type,options:Object.type});this.get("reveal",a.options).dissolve().chain(function(){this[a.destroy?"destroy":"dispose"]()}.bind(this));return this},wink:function(){var b=Array.link(arguments,{duration:Number.type,options:Object.type});var a=this.get("reveal",b.options);a.reveal().chain(function(){(function(){a.dissolve()}).delay(b.duration||2000)})}});