(function(){ParleyMessagePreview=function(){var Dom=YAHOO.util.Dom,YU=YAHOO.util;this.config={trigger:"message_preview",user_input:"thread_message",container:"message_container",trigger_evt:"click",post_url:"post/preview",label_edit:"Edit",label_preview:"Preview"};this.message_source=false;this.message_preview=false;this.handleSuccess=function(o){var data=eval("("+o.responseText+")");var obj=o.argument.obj;if(data.formatted){obj.previewElId=YU.Dom.generateId();obj.user_input.style.visibility="hidden";var pWidth=obj.user_input.clientWidth,pHeight=obj.user_input.clientHeight,pLeft=obj.user_input.offsetLeft,pTop=obj.user_input.offsetTop;obj.preview_overlay=new YAHOO.widget.Overlay("preview_overlay",{context:[obj.config.user_input,"tl","tl"],visible:true,width:obj.user_input.clientWidth+"px",height:obj.user_input.clientHeight+"px"});obj.preview_overlay.setBody(data.formatted);obj.preview_overlay.render(document.body);Dom.get("preview_overlay").style.overflow="auto";obj.trigger.value=obj.config.label_edit;YU.Event.removeListener(obj.trigger,"click");YU.Event.addListener(obj.trigger,obj.config.trigger_evt,obj.edit,obj,true)}};this.handleFailure=function(o){console.log("failure")};this.edit=function(){this.trigger.value=this.config.label_preview;this.user_input.style.visibility="visible";this.preview_overlay.destroy();YU.Event.removeListener(this.trigger,"click");YU.Event.addListener(this.trigger,this.config.trigger_evt,this.preview,this,true)};this.preview=function(){var msgSource=escape(this.user_input.value);msgSource=msgSource.replace(/\+/g,"%2b");var request=YU.Connect.asyncRequest("POST",this.config.post_url,{success:this.handleSuccess,failure:this.handleFailure,argument:{obj:this}},"msg_source="+msgSource)};this.init=function(){this.container=Dom.get(this.config.container);this.user_input=Dom.get(this.config.user_input);this.trigger=Dom.get(this.config.trigger);YU.Event.addListener(this.trigger,this.config.trigger_evt,this.preview,this,true)}}})();