	document.onmousemove = MouseMove;
	var m_nMouseX = 0;
	var m_nMouseY = 0;	
	var m_pDivSmall = null;
	var m_pDivLarge = null; 

function InitTips()
{	var pTable = document.getElementById("galerie");
	var pImages = pTable.getElementsByTagName("img");
	for (var i = 0; i < pImages.length; i++)
	{	var sUrl = pImages[i].src;  
		if (sUrl.substr(sUrl.length-3, 3) == "gif" ||
			sUrl.substr(sUrl.length-3, 3) == "jpg")
		{	var pDiv = pImages[i].parentNode;
			if (pDiv.className == "galerie_tn")
				pDiv.onmouseover = function() { ShowTip(this); };
		}
	}
	document.onmousemove = MouseMove;	
}

function ShowTip(pImgDiv)
{	HideTip();
	
	m_pDivSmall = pImgDiv;
	m_pDivLarge = m_pDivSmall.nextSibling;
	
	if (m_pDivLarge.className != "galerie_tip")
		m_pDivLarge = m_pDivLarge.nextSibling;
	
	if (m_pDivLarge.className != "galerie_tip")
	{	m_pDivSmall = null;
		m_pDivLarge = null;
		return;	
	}
	
	RefreshPos();
}

function RefreshPos()
{	if (m_pDivLarge == null) reurn;
	
	var nXPos = m_nMouseX; // GetAbsX(m_pDivSmall);
	var nYPos = m_nMouseY; // GetAbsY(m_pDivSmall);	
	
	var nWidth = GetWidth(m_pDivLarge);
	var nHeight = GetHeight(m_pDivLarge);

	var nWinX = GetWindowX();
	var nWinY = GetWindowY();
	var nWinW = GetWindowWidth()-16;
	var nWinH = GetWindowHeight()-16;
	
	// Auf Seite einpassen
	if (nXPos + nWidth > nWinX + nWinW)
		nXPos = nWinX + nWinW - nWidth;
			
	if (nXPos < nWinX) nXPos = nWinX;

	if (nYPos + nHeight > nWinY + nWinH)
		nYPos = nWinY + nWinH - nHeight;

	if (nYPos < nWinY) nYPos = nWinY;
	
	SetPos(m_pDivLarge, nXPos, nYPos);
	m_pDivLarge.style.display = "block";
}

function HideTip()
{	if (m_pDivLarge != null)
	{	m_pDivLarge.style.display = "none";
		m_pDivSmall = null;
		m_pDivLarge = null;
	}
}

function MouseMove(e)
{	m_nMouseX =  e? e.pageX : window.event.x;
	m_nMouseY =  e? e.pageY : window.event.y;
    
    if (ie)
    {	m_nMouseX    += document.body.scrollLeft;
		m_nMouseY    += document.body.scrollTop;
	}
	
	// Hide?	
	if (m_pDivLarge != null)
	{	var x = GetAbsX(m_pDivSmall);
		var y = GetAbsY(m_pDivSmall)
		var w = GetWidth(m_pDivSmall);
		var h = GetHeight(m_pDivSmall);
		if (m_nMouseX < x || m_nMouseX > x+w ||
			m_nMouseY < y || m_nMouseY > y+h)
		{	//x = GetAbsX(m_pDivLarge);
			//y = GetAbsY(m_pDivLarge);
			//w = GetWidth(m_pDivLarge);
			//h = GetHeight(m_pDivLarge);
			//if (m_nMouseX < x || m_nMouseX > x+w ||
			//	m_nMouseY < y || m_nMouseY > y+h)
			{	HideTip();
			}
		}				
	}	
	if (m_pDivLarge != null) RefreshPos();
}
