var objNodeOverlayCloseAtTimeout = null;

function isEditMode()
{
	return typeof(objDock) != 'undefined';
}

function openContentBlock(in_objNode, in_objEvent)
{
	var objEvent = window.event != null ? window.event : in_objEvent;

	if	(
				(isEditMode() && objEvent.type == 'click') ||
				(!isEditMode() && objEvent.type == 'mouseover')
			)
	{
		var objNodeOverlay
		var objNodeColoredContentBlock;
		var objNodeOpenedContentBlock;


		//Overlay bestimmen
		var objCurrentNode = in_objNode;
		while (objNodeOverlay == null)
		{
			if (objCurrentNode.className != null && objCurrentNode.className == 'overlay')
			{
				objNodeOverlay = objCurrentNode;
			}
			else
			{
				objCurrentNode = objCurrentNode.parentNode;
			}
		}

		if (objNodeOverlayCloseAtTimeout != null)	//wenn Block ueber Timeout gerade geschlossen werden soll
		{
			if (objNodeOverlayCloseAtTimeout != objNodeOverlay)	//wenn anderer Block geschlossen werden soll, diesen erst schliessen
			{
				hideContentBlockTimeout();
			}
			objNodeOverlayCloseAtTimeout = null;	//Block zuruecksetzen (nicht schliessen)
		}

		//ContentBlocks bestimmen
		var arrDivs = objNodeOverlay.getElementsByTagName('DIV');
		for (var i = 0; i < arrDivs.length; i++)
		{
			if (arrDivs[i].className != null && arrDivs[i].className == 'colored-content-block')
			{
				objNodeColoredContentBlock = arrDivs[i];
			}
			else if (arrDivs[i].className != null && arrDivs[i].className == 'opened-content-block')
			{
				objNodeOpenedContentBlock = arrDivs[i];
			}
		}

		objNodeColoredContentBlock.style.display = 'none'
		objNodeOpenedContentBlock.style.display = 'block'
	}
}

function closeContentBlock(in_objNode, in_objEvent)
{
	var objEvent = window.event != null ? window.event : in_objEvent;

	if	(
				(isEditMode() && objEvent.type == 'click') ||
				(!isEditMode() && objEvent.type == 'mouseout')
			)
	{
		var objNodeOverlay

		//Overlay bestimmen
		var objCurrentNode = in_objNode;
		while (objNodeOverlay == null)
		{
			if (objCurrentNode.className != null && objCurrentNode.className == 'overlay')
			{
				objNodeOverlay = objCurrentNode;
			}
			else
			{
				objCurrentNode = objCurrentNode.parentNode;
			}
		}

		objNodeOverlayCloseAtTimeout = objNodeOverlay;

		if (isEditMode())
		{
			hideContentBlockTimeout();
		}
		else
		{
			window.setTimeout('hideContentBlockTimeout()', 500);
		}
	}
}

function hideContentBlockTimeout()
{
	if (objNodeOverlayCloseAtTimeout != null)
	{
		var objNodeOverlay = objNodeOverlayCloseAtTimeout;
		var objNodeColoredContentBlock;
		var objNodeOpenedContentBlock;

		//ContentBlocks bestimmen
		var arrDivs = objNodeOverlay.getElementsByTagName('DIV');
		for (var i = 0; i < arrDivs.length; i++)
		{
			if (arrDivs[i].className != null && arrDivs[i].className == 'colored-content-block')
			{
				objNodeColoredContentBlock = arrDivs[i];
			}
			else if (arrDivs[i].className != null && arrDivs[i].className == 'opened-content-block')
			{
				objNodeOpenedContentBlock = arrDivs[i];
			}
		}

		objNodeColoredContentBlock.style.display = 'block'
		objNodeOpenedContentBlock.style.display = 'none'
	}
}