findSystem(window)

function findSystem(ancestorWindow)
{
	try
	{
		if (typeof (ancestorWindow.document) == "unknown")
		{
			if (ancestorWindow.parent != ancestorWindow)
			{
				findSystem(ancestorWindow.parent);
			}
			else if (ancestorWindow.opener)
			{
				findSystem(ancestorWindow.opener);
			}
			return;
		}
		system = ancestorWindow;

		if (system.isSystem) return;

		if (ancestorWindow.opener) findSystem(ancestorWindow.opener);

		if (ancestorWindow.parent == ancestorWindow) return;
		findSystem(ancestorWindow.parent);
	}
	catch (e)
	{
	// Can happen if one of the parent documents are not accessible like when launched from a different domain.
	}
}

if (system.isFirefox)
{
	HTMLElement.prototype.__defineGetter__("innerText", function()
	{
		return this.textContent;
	});
	HTMLElement.prototype.__defineSetter__("innerText", function(value)
	{
		this.textContent = value;
	});
}
