var Initialisierung = 0
var Ex, Ey, TextFarbe, ContentInfo;

TextFarbe = "yellow"

function ToolTipBewegen(layerName, FromTop, FromLeft, e)
{
    if (FromTop + document.getElementById(layerName).offsetHeight > document.documentElement.clientHeight + document.documentElement.scrollTop)
        document.getElementById(layerName).style.top = (document.documentElement.clientHeight + document.documentElement.scrollTop 
            - document.getElementById(layerName).offsetHeight) + "px";
    else
        document.getElementById(layerName).style.top = FromTop + "px";
    document.getElementById(layerName).style.left = FromLeft + 15 + "px";
}

function Aktivieren()
{
    Initialisierung=1;
}

function Deaktivieren()
{
    Initialisierung=0;
}

function Starten(e)
{
    if(Initialisierung)
    {
    	Ex = document.all ? window.event.x + document.documentElement.scrollLeft : e.pageX;
        Ey = document.all ? window.event.y + document.documentElement.scrollTop : e.pageY;
        ToolTipBewegen("ToolTip", Ey, Ex, e);
        document.getElementById('ToolTip').style.position = "absolute";
        document.getElementById('ToolTip').style.visibility = "visible";
    }
    else
    {
        ToolTipBewegen("ToolTip", 0, 0);
        document.getElementById('ToolTip').style.visibility = "hidden";
    }
}

function strToZeit(str)
{
	var doppelPos = str.search(/:/);
	var result = 6000 * str.substr(0, 2) + 100 * str.substr(doppelPos + 1, 2) + 1 * str.substr(doppelPos + 4);
	return result;
}

function rechts(str, count)
{
	var len = str.length;
	if (count >= len)
		return str;
		
	return str.substr(len - count);
}

function zeitToStr(zeit)
{
	str = zeit;
	str = rechts("0" +  Math.floor(zeit / 6000), 2) + ":";
	zeit = zeit % 6000;
	str += rechts("0" +  Math.floor(zeit / 100), 2) + ",";
	zeit = zeit % 100;
	str += rechts("0" + zeit, 2);
	return str;
}

function ToolTip(layerName, TInhalt, Endzeit)
{
	var lasZeilen;
	var lsTmp;
	TInhalt = TInhalt.replace(/<br>/g, "<br />");
	lasZeilen = TInhalt.split("<br />");
	for (i=0; i<lasZeilen.length; i++)
	{
		if (i==0)
		{
			TInhalt = lasZeilen[0] + '<br />';
		}
		else
		{
			TInhalt += lasZeilen[i] + ' (' + zeitToStr(strToZeit(lasZeilen[i]) - strToZeit(lasZeilen[i-1])) + ')' + '<br />';
		}
	}
	if (Endzeit != "")
		TInhalt += Endzeit + ' (' + zeitToStr(strToZeit(Endzeit) - strToZeit(lasZeilen[lasZeilen.length-1])) + ')';
    ContentInfo = '<table border="0" cellspacing="0" cellpadding="0">'+'<tr><td width="130px" bgcolor="#000000">'+'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+'<tr><td width="100%" bgcolor='+TextFarbe+'>'+'<table border="0" width="90%" cellpadding="0" cellspacing="1" align="center">'+'<tr><td width="100%">'+'<font class="ToolTipInhalt">'+TInhalt+'</font>'+'</td></tr>'+'</table>'+'</td></tr>'+'</table>'+'</td></tr>'+'</table>';
    
    document.getElementById(layerName).innerHTML = ContentInfo;
}
