JAMLite.widgets.AjaxComments=Class.create();JAMLite.widgets.AjaxComments.prototype={DOM:{},CONFIG:{},initialize:function(container,config){this.CONFIG=Object.extend(this.CONFIG,config);this.DOM={container:null,commentForm:null,postButton:null};this.DOM.container=$(container);if(this.DOM.container==null){JAMLite.throwException("JAMLite.widgets.Comments(): please supply a container to the Comments constructor.")}this.setDisplay()},setDisplay:function(){this.DOM.commentForm=this.DOM.container.down(this.CONFIG.selectors.commentForm);if(this.DOM.commentForm==null){JAMLite.throwException('JAMLite.widgets.Comments(): Could not find commentForm using selector "'+this.CONFIG.selectors.commentForm+'"')}this.DOM.commentButton=this.DOM.container.down(this.CONFIG.selectors.commentButton);if(this.DOM.commentButton==null){JAMLite.throwException('JAMLite.widgets.Comments(): Could not find rateForm using selector "'+this.CONFIG.selectors.commentButton+'"')}this.attachEventListeners()},attachEventListeners:function(){this.DOM.commentForm.observe("submit",this.commentForm_onBeforeSubmit.bindAsEventListener(this))},commentForm_onBeforeSubmit:function(event){event.stop();if(this.DOM.commentButton){this.DOM.commentButton.toggleClassName("disabled");this.DOM.commentButton.innerHTML="Posting..."}this.DOM.commentForm.request({onComplete:this.commentForm_onComplete.bind(this),onFailure:this.commentForm_onFauilure.bind(this)});this.DOM.commentForm.disable()},commentForm_onComplete:function(respObj){this.DOM.commentForm.replace(respObj.responseText);this.setDisplay()},commentForm_onFauilure:function(){alert("There was a problem posting your comment please try again later.");if(this.DOM.commentButton.disabled){this.DOM.commentButton.toggleClassName("disabled");this.DOM.commentForm.enable();this.DOM.commentButton.innerHTML="Post"}}};