/*
 * Enmuliert das ounmouseleave-Verhalten (IE-only),
 * d.h. das Verlassen eines Elementes "nach außen",
 * also ohne Berücksichtigung von Events innerhalb
 * des Elementes
 */

// Definiert contains(), falls es nicht vorhanden ist
if (window.Node && Node.prototype && !Node.prototype.contains)
{
	Node.prototype.contains = function(arg)
	{
		return !!(this.compareDocumentPosition(arg) & 16);
	};
}

/**
 * Initialisierungsfunktion
 *
 * @param id ID des Elementes
 */
function onMouseLeave(id)
{
	/** Referenz auf das Element */
	elm = document.getElementById(id);

	/** interne Variable, die speichert, ob das Element angezeigt wird */
	elm.visible = false;

	/**
	 * Blendet das Element ein
	 *
	 * @param e Event
	 */
	elm.onmouseover	= function(e)
	{
		if (this.visible)
			return;

		this.style.visibility	= "visible";
		this.visible			= true;
	};

	/**
	 * Blendet das Element aus
	 *
	 * @param e Event
	 */
	elm.onmouseout = function(e)
	{
		e				= e || window.event;
		var target		= e.target || e.srcElement;
		var toElement	= e.relatedTarget || e.toElement || false;

		if (this.contains(toElement))
			return;

		this.style.visibility	= "hidden";
		this.visible			= false;
	};
}