/* Copyright 2008 Marc Mongenet */

// Transform the edited element into a text input.
function w2mlEdittext(elm)
{
	var edelm = document.createElement("input");
	edelm.type = "text";
	edelm.name = elm.getAttribute("w2mledid");
	edelm.value = elm.firstChild ? elm.firstChild.nodeValue : "";
	edelm.className = "w2mltextEditor";
	elm.style.display = "none";
	elm.parentNode.insertBefore(edelm, elm.nextSibling);
	if (w2mlRegisterEditedObject(edelm))
		w2mlMakeSaveUI(w2mlUnderElmOnScreen(edelm));
}

function w2mlRegistertextEditor(elm)
{
	var edrun = elm.getAttribute("w2mledrun");
	if (edrun == "auto") {
		w2mlEdittext(elm);
	}
	else {
		w2mlSetMouseHoverImg(elm, w2mlEditURI + "pencil.gif");
		elm.ondblclick = function() {
			w2mlUnsetMouseHoverImg(this);
			w2mlEdittext(this);
			return false;
		}
	}
}
