/*
	myInPlaceEditor = Class.create();
	Object.extend(myInPlaceEditor.prototype, Ajax.InPlaceEditor.prototype);
	Object.extend(myInPlaceEditor.prototype, {
		createEditField: function() {
			var text;
			if(this.options.loadTextURL) {
				text = this.options.loadingText;
			} else {
				text = this.getText();
			}
  		if (this.options.default_string)
  		{
  				if (text==this.options.default_string)
  					text = "";
  		}
			var obj = this;
			this.observer =null;
			
			if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
				this.options.textarea = false;
				var textField = document.createElement("input");
				textField.obj = this;
				textField.type = "text";
				textField.name = "value";
				textField.value = text;
				textField.style.backgroundColor = this.options.highlightcolor;
				textField.style.width = "230px";
				textField.className = 'editor_field';
				var size = this.options.size || this.options.cols || 0;
				if (size != 0) textField.size = size;
				if (this.options.submitOnBlur)
					textField.onblur = this.onSubmit.bind(this);
				this.editField = textField;
			} else {
				this.options.textarea = true;
				var textArea = document.createElement("textarea");
				textArea.obj = this;
				textArea.name = "value";
				textArea.value = this.convertHTMLLineBreaks(text);
				textArea.rows = this.options.rows;
				textArea.cols = this.options.cols || 40;
				textArea.className = 'editor_field';			
				if (this.options.submitOnBlur)
					textArea.onblur = this.onSubmit.bind(this);
				this.editField = textArea;
			}
			
			if(this.options.loadTextURL) {
				this.loadExternalText();
			}
			this.form.appendChild(this.editField);
		},
		//
		createForm: function() {
		this.form = document.createElement("form");
		this.form.id = this.options.formId;
		Element.addClassName(this.form, this.options.formClassName)
		this.form.onsubmit = this.onSubmit.bind(this);
	
		this.createEditField();
	
		if (this.options.textarea) {
			var br = document.createElement("br");
			this.form.appendChild(br);
		}
	
		if (this.options.okButton) {
			okButton = document.createElement("input");
			if (this.options.okimage)
			{
				okButton.type = "image";
				okButton.src = this.options.okimage;
			}else
			{
				okButton.type = "submit";
				okButton.value = this.options.okText;
			}
			okButton.className = 'SaveBtn';
			this.form.appendChild(okButton);
		}
	
		if (this.options.cancelLink) {
			cancelLink = document.createElement("a");
			cancelLink.href = "javascript:void(0)";
			if (this.options.cancelimage)
			{
				var cancel_image = document.createElement("img");
				cancel_image.src = this.options.cancelimage;
				cancel_image.border ="0";
				cancelLink.appendChild(cancel_image);
			}else
			{
				cancelLink.appendChild(document.createTextNode(this.options.cancelText));
			}
			cancelLink.onclick = this.onclickCancel.bind(this);
			cancelLink.className = 'CancelBtn';			
			this.form.appendChild(cancelLink);
		}

		}
	} );
*/
/*---------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/

	myInPlaceEditorWithList = Class.create();
	Object.extend(myInPlaceEditorWithList.prototype, Ajax.InPlaceEditor.prototype);
	Object.extend(myInPlaceEditorWithList.prototype, {
		createEditField: function() {
			var text;
			if(this.options.loadTextURL) {
				text = this.options.loadingText;
			} else {
				text = this.getText();
			}
  		if (this.options.default_string)
  		{
  				if (text==this.options.default_string)
  					text = "";
  		}
			var obj = this;
			this.observer =null;
			
			if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
				this.options.textarea = false;
				var textField = document.createElement("input");
				textField.obj = this;
				textField.type = "text";
				textField.name = "value";
				textField.value = text;
				textField.style.backgroundColor = this.options.highlightcolor;
				textField.style.width = "230px";
				textField.className = 'editor_field';
				var size = this.options.size || this.options.cols || 0;
				if (size != 0) textField.size = size;
				if (this.options.submitOnBlur)
					textField.onblur = this.onSubmit.bind(this);
				if (this.options.textOnKeyup)
				{
					Event.observe(textField,"keypress",this.onEditorKeyPress.bindAsEventListener(this));
				}
				this.editField = textField;
			} else {
				this.options.textarea = true;
				var textArea = document.createElement("textarea");
				textArea.obj = this;
				textArea.name = "value";
				textArea.value = this.convertHTMLLineBreaks(text);
				textArea.rows = this.options.rows;
				textArea.cols = this.options.cols || 40;
				textArea.className = 'editor_field';			
				if (this.options.submitOnBlur)
					textArea.onblur = this.onSubmit.bind(this);
				if (this.options.textOnKeyup)
				{
					Event.observe(textArea,"keypress",this.onEditorKeyPress.bindAsEventListener(this));
				}
				this.editField = textArea;
			}
			
			if(this.options.loadTextURL) {
				this.loadExternalText();
			}
			this.form.appendChild(this.editField);
		},
		//
		onEditorKeyPress: function (event){
			if (this.options.textOnKeyup)
			{
				if(this.observer){clearTimeout(this.observer)};
				this.observer = setTimeout(this.options.textOnKeyup.bind(this, this.editField), 0.5*1000);
			}
		},
		//
		onEnterEditMode: function() {
			if (this.options.onEnterEdit)
			{
				this.options.onEnterEdit.bind(this)(this.element);
			}
		},
		//
		onLeaveEditMode: function() {
			if (this.options.default_string)
			{
  			if (this.element.innerHTML=="" || this.element.innerHTML==this.options.default_string)
  			{
  				this.element.innerHTML = this.options.default_string;
  				this.element.className = this.options.default_string_style;
  				/*
  				this.element.innerHTML = "";
  				this.element.title = this.options.default_string;
  				this.element.className = this.options.default_string_style;
  				*/
  			}else
					this.element.className = this.options.text_style;
			}

			if (this.options.onLeaveEdit)
			{
				this.options.onLeaveEdit.bind(this)(this.element);
			}
		},
		//
		afterCreateForm: function() {
			if (this.options.afterCreateFrom)
			{
				this.options.afterCreateFrom.bind(this)(this.element);
			}
		},
		//
		//
		createForm: function() {
		this.form = document.createElement("form");
		this.form.id = this.options.formId;
		Element.addClassName(this.form, this.options.formClassName)
		this.form.onsubmit = this.onSubmit.bind(this);
	
		this.createEditField();
	
		if (this.options.textarea) {
			var br = document.createElement("br");
			this.form.appendChild(br);
		}
		if (this.options.input_notice && this.options.input_notice!='') {
			var tmp_lable = document.createElement("lable");
			tmp_lable.innerHTML = this.options.input_notice;
			this.form.appendChild(tmp_lable);
		}
		
		if (this.options.okButton) {
			okButton = document.createElement("input");
			if (this.options.okimage)
			{
				okButton.type = "image";
				okButton.src = this.options.okimage;
			}else
			{
				okButton.type = "submit";
				okButton.value = this.options.okText;
			}
			okButton.className = 'SaveBtn';
			this.form.appendChild(okButton);
		}
	
		if (this.options.cancelLink) {
			cancelLink = document.createElement("a");
			cancelLink.href = "javascript:void(0)";
			if (this.options.cancelimage)
			{
				var cancel_image = document.createElement("img");
				cancel_image.src = this.options.cancelimage;
				cancel_image.border ="0";
				cancelLink.appendChild(cancel_image);
			}else
			{
				cancelLink.appendChild(document.createTextNode(this.options.cancelText));
			}
			cancelLink.onclick = this.onclickCancel.bind(this);
			cancelLink.className = 'CancelBtn';			
			this.form.appendChild(cancelLink);
		}

		this.afterCreateForm();
		}
	} );

/*--------------------------------*/
