	function disableCommentEdit(_form){
		for (i=0; i<_form.elements.length; i++) {
			var element = _form.elements[i];
			if (element.type == "text") {
			 	element.disabled=true; 
			} 
			else{
				element.disabled=true;
			}
			
		}
	}
	
	function enableCommentEdit(_form){
		for (i=0; i<_form.elements.length; i++) {
			var element = _form.elements[i];
			if (element.type == "text") {
			 	element.disabled=false; 
			} 
			else {
				element.disabled=false;
			}
		}
	}
	
	function loadCommentPage(backendlink, p, entries, entitytype, entityid, commentscontainerid, errormsg){
		//alert(backendlink+" "+p+" "+entries+" "+entitytype+" "+entityid+" "+commentscontainerid);
		
		var args = 'id='+entityid+'&current='+p+'&type='+entitytype+'&entries='+entries;
		//alert('args: ' + args);
	
		var ajaxUpdater = new Ajax.Updater(commentscontainerid, backendlink, 
			{
				method: 'post', 
			    parameters: args,
			    evalScripts: true,
			    onFailure: function handle_failure(ipe){
				    Element.replace(commentscontainerid, '<p class="errormsg">' + errormsg + '</p>');
				    	
				}
			}
		);
		return false;
	}
	
	function extendEditor(editor, area, hidealways){
		//area is not the textarea but the div containing the text
		if(editor == undefined){
			alert('editor: ' + editor + ' undefined');
		}
		if(hidealways == undefined){
			hidealways = false;
		}
		if(hidealways){
			area.style.visibility='hidden';
		}
		Object.extend(editor, {
	
			  prepareSubmission: function() {
			  area.style.visibility='visible';
				this._erroroccured = false;
			    this._saving = true;
			    this.removeForm();
			    this.leaveHover();
			    
			    this.showSaving();
			  },
			 
			  
			  leaveEditMode: function() {
			  	  if($(this.options.formId) == undefined){
					  this.createForm();
		    		  this.element.parentNode.insertBefore(this._form, this.element);
					  disableCommentEdit(editor._form);
				  }
			  	if((this._erroroccured == undefined || !this._erroroccured) && this._saving != undefined && this._saving) {
			  		area.style.visibility='hidden';
			  		return;
			  	}
			  	if(hidealways && this._erroroccured != undefined && this._erroroccured) {
			  		area.style.visibility='visible';
			  	}
			  	else if(hidealways){
			  		area.style.visibility='hidden';
			  	}
			  	enableCommentEdit(editor._form);
			    this.element.removeClassName(this.options.savingClassName);
			    this.removeForm();
			    this.leaveHover();
			    this.element.style.backgroundColor = this._originalBackground;
			    this.element.show();
			    if (this.options.externalControl)
			      this.options.externalControl.show();
			    this._saving = false;
			    this._editing = false;
			    this._oldInnerHTML = null;
			    this.triggerCallback('onLeaveEditMode');
			    //area.style.visibility='visible';
			  }
	
			});
		}