// This is from http://webfx.eae.net/dhtml/ieemu/htmlmodel.html.

if (typeof HTMLElement != 'undefined')
{
	HTMLElement.prototype.__defineSetter__(
		"innerText",
		function (inText)
		{
			this.innerHTML = inText.replace(/\&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
		});

	HTMLElement.prototype.__defineGetter__(
		"innerText",
		function ()
		{
			var theRange;

			theRange = this.ownerDocument.createRange();
			theRange.selectNodeContents(this);
			return (theRange.toString());
		});

	var theSharedOuterHTMLEmptyTags = {
	   "IMG":   true,
	   "BR":    true,
	   "INPUT": true,
	   "META":  true,
	   "LINK":  true,
	   "PARAM": true,
	   "HR":    true
	};

	HTMLElement.prototype.__defineGetter__(
		"outerHTML",
		function ()
		{
			var theAttributes;
			var theString;
			var i;

			theAttributes = this.attributes;
			theString = "<" + this.tagName;
			for (i = 0; i < theAttributes.length; i++)
				theString += " " + theAttributes[i].name + "=\"" + theAttributes[i].value + "\"";

			if (theSharedOuterHTMLEmptyTags[this.tagName])
				return (theString + ">");

			return (theString + ">" + this.innerHTML + "</" + this.tagName + ">");
		});
}