comments=Class.extend({_state:null,_id:null,_showId:null,_adderId:null,_commentFormId:null,_okBtn:null,_cancelBtn:null,_md5hash:null,_textareaId:null,_commentsDiv:null,init:function(id,showId,adderId,commentFormId,okBtn,cancelBtn,md5hash,textarea,commentsDiv){var obj=this;this._id=id;this._showId=showId;this._adderId=adderId;this._commentFormId=commentFormId;this._state='hidden';this._okBtn=okBtn;this._cancelBtn=cancelBtn;this._md5hash=md5hash;this._textareaId=textarea;this._commentsDiv=commentsDiv;$('#'+id).hide();$('#'+showId).bind('click',function(e){obj.toggleState(e)});$('#'+adderId).bind('click',function(e){obj.adderAction(e)})},adderAction:function(e){var obj=this;var x=(($(window).width()-$('#'+this._commentFormId).width())/2);var y=(($(window).height()-$('#'+this._commentFormId).height())/2);$('#error').empty();$('#'+this._textareaId).val('');$('#'+this._okBtn).bind('click',function(e){obj.submit(e)});$('#'+this._cancelBtn).bind('click',function(e){$('#'+obj._commentFormId).hide()});$('#'+this._commentFormId).css({position:'absolute',left:x,top:y,'z-index':'100'});$('#'+this._commentFormId).show()},toggleState:function(e){if(this._id&&this._state=='hidden'){this._state='shown';$('#'+this._id).show();$('#'+this._showId).removeClass('comments_icons_open');$('#'+this._showId).addClass('comments_icons_close')}else if(this._id&&this._state=='shown'){this._state='hidden';$('#'+this._id).hide();$('#'+this._showId).removeClass('comments_icons_close');$('#'+this._showId).addClass('comments_icons_open')}},webserviceCallback:function(data){if(data.status=='OK'){subparams={md5hash:this._md5hash};params={service:'comments',method:'getcomments',params:subparams};var obj=this;$.post(undiluted.config._apiURL,$.toJSON(params),function(data){$('#'+obj._commentsDiv).html(data.values.comments)},'json');$('#'+this._commentFormId).hide()}else{$('#error').text('Comments Adding Unsuccessful.')}},submit:function(e){if($('#'+this._textareaId).val()!=''){var obj=this;var subparams={md5hash:this._md5hash,comment:$('#'+this._textareaId).val()};var params={service:'comments',method:'addcomment',params:subparams};$.post(undiluted.config._apiURL,$.toJSON(params),function(data){obj.webserviceCallback(data)},'json')}else{$('#error').text('Comments Adding Unsuccessful.')}}});