/* Tool-Tip-Fenster */
// (c) Klaus Gottschling 112004

var mx=0;
var my=0;
var ypos=0;
var xpos=0;
var fnst_breite = 0;
var fnst_hoehe = 0;
var bbtext = "";

function HideBubble()
{
	if(DOM || MS) getElem("id","bubble",null).style.visibility = "hidden";
	if(NS) getElem("id","bubble",null).visibility = "hide";
	bbtext = "";
}

function ShowBubble(text)
{
	if (bbtext != "") return false;
	bbtext = text;
	if (MS)
	{
		document.all.bubble.innerHTML = bbtext;
		bubble.style.visibility = "visible";
	}
	else if (NS)
	{
		bbtext="<div class='BubbleClass'>"+bbtext+"</div>"
		with (document.bubble.document)
		{
			open();
			write(bbtext);
			close();
		}
		document.bubble.bgColor = "ffffcc";
		document.bubble.visibility = "SHOW";
	}
	else if(DOM || MS)
	{
		getElem("id","bubble",null).innerHTML = bbtext;
		getElem("id","bubble",null).style.visibility = "visible";
	}
}

function NSwatch_mouse(e)
{
        mx = e.x;
        my = e.y;
        xpos = mx + 5;
        if ((xpos + document.bubble.clip.width + 15) > (window.innerWidth + window.pageXOffset)) xpos = window.innerWidth + window.pageXOffset - document.bubble.clip.width -15;
        if (xpos < 5) xpos = 5;
        ypos = my - document.bubble.clip.bottom - 15;
        if (ypos < (window.pageYOffset+2)) ypos = my + 20;
        document.bubble.left = xpos;
        document.bubble.top  = ypos;
}

function MSwatch_mouse(e)
{
        mx = window.event.x;
        my = window.event.y;
        xpos = mx + document.body.scrollLeft + 2;
        if ((xpos + bubble.offsetWidth + 15) > (document.body.offsetWidth + document.body.scrollLeft))
        {
                xpos = document.body.offsetWidth + document.body.scrollLeft - bubble.offsetWidth - 15;
        }
        if (xpos < (document.body.scrollLeft + 5)) xpos = document.body.scrollLeft + 5;
        bubble.style.left = xpos;
        ypos = my + document.body.scrollTop - getElem("id","bubble",null).offsetHeight - 15;
        if (ypos < (document.body.scrollTop + 2)) ypos = my + document.body.scrollTop + 25;
        bubble.style.top = ypos;
}

function DOMwatch_mouse(e)
{
	var elm = getElem("id","bubble",null);
	var elmbr = document.getElementById("bubble").offsetWidth;
	var elmho = document.getElementById("bubble").offsetHeight;

	mx = e.pageX;
	xpos = mx + 5;
	if ((xpos + elmbr) > (window.innerWidth + window.pageXOffset)) xpos = window.innerWidth + window.pageXOffset - elmbr -15;
	if (xpos < 5) xpos = 5;
	elm.style.left = xpos;

	my = e.pageY;
	ypos = my - elmho - 15;
	if (ypos < (window.pageYOffset+2)) ypos = my + 20;
	elm.style.top = ypos;
}

function helpinit()
{
	if(DOM && !MS && !OP) {
		getElem("tagname","body",0).addEventListener("mousemove", DOMwatch_mouse, true);
	}
	if(NS) {
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = NSwatch_mouse;
	}
	if (DOM && OP) {
		document.onmousemove = DOMwatch_mouse;
	}
	if (MS) getElem("tagname","body",0).onmousemove = MSwatch_mouse;
	HideBubble();
}

