function getSize() {
    var myWidth = 0, myHeight = 0;

    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return [ myWidth, myHeight ];
}

function getScrollXY() {
    var scrOfX = 0, scrOfY = 0;

    if (typeof(window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return [scrOfX, scrOfY];
}

function setScrollXY(xp, yp) {
	xpos = 200;
	ypos = 200;
    if (typeof(window.pageYOffset) == 'number') {
        //Netscape compliant
        xpos = (xp) ? xp : window.pageXOffset;
        ypos = (yp) ? yp : window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        xpos = (xp) ? xp : document.body.scrollLeft;
        ypos = (yp) ? yp : document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        xpos = (xp) ? xp : document.documentElement.scrollLeft;
        ypos = (yp) ? yp : document.documentElement.scrollTop;
    }
    window.scrollTo(xpos, ypos);
}

var mouse_x = 0;
var mouse_y = 0;
var min_x = 0;
var max_x = 0;
var showhelp = false;
var toolbox = null;
var elmbr = 0;
var elmhoe = 0;

function watchmouve(ev) {
	if (!ev) ev = window.event;
	mouse_x = ev.pageX ? ev.pageX : ev.clientX;
	mouse_y = ev.pageY ? ev.pageY : ev.clientY;
	if (document.body.offsetLeft) {
		mouse_x += (document.body.scrollLeft) ? document.body.scrollLeft : document.documentElement.scrollLeft;
		mouse_y += (document.body.scrollTop) ? document.body.scrollTop : document.documentElement
.scrollTop;
	}
	if (showhelp) {
		mouse_y += 22;
		mouse_x -= 15;
		diff_xl = mouse_x - shift[0];
		if (1 > diff_xl) setScrollXY(mouse_x, null);
		diff_xr = shift[0] + area[0] - mouse_x - elmbr - 5;
		if (0 > diff_xr) mouse_x += diff_xr;
//		setScrollXY(mouse_x + elmbr - area[0], null);
		diff_y = shift[1] + area[1] - mouse_y - elmhoe;
//		if (1 > diff_y) setScrollXY(false, mouse_y + elmhoe - area[1]);
		if (NS4) {
			toolbox.left = mouse_x + 'px';
			toolbox.top = mouse_y + 'px';
		}
		else {
			toolbox.style.left = mouse_x + 'px';
			toolbox.style.top = mouse_y + 'px';
		}
	}
}

function helpinit () {
	if (document.addEventListener) {
    	document.addEventListener("mousemove", watchmouve, true);
	} else {
		if (NS4) {
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = watchmouve;
		} else {
			document.body.onmousemove = watchmouve;
		}
	}
/* 	if (OP) {
		NavLinksPos = 42; // Position des Bereiches NavLinks
		getElement("id", "NavLinks").style.pixelTop = NavLinksPos;
	} */
	toolbox = getElement("id","bubble",null);
}

function ShowBubble(inhalt) {
	if (!showhelp) {
		showhelp = true;
		area = getSize();
		shift = getScrollXY();
		if (toolbox) {
			if (MSIE4)
			{
				toolbox.innerHTML = inhalt;
				toolbox.style.visibility = "visible";
				elmbr = toolbox.offsetWidth;
				elmhoe = toolbox.offsetHeight;
			}
			else if (NS4)
			{
				bbtext="<div class='BubbleClass'>"+inhalt+"<\/div>"
				with (toolbox.document)
				{
					open();
					write(bbtext);
					close();
				}
				toolbox.bgColor = "ffffcc";
				toolbox.visibility = "SHOW";
				elmbr = toolbox.clip.width;
				elmhoe = toolbox.clip.height;
			}
			else if(DOM)
			{
				toolbox.innerHTML = inhalt;
				toolbox.style.visibility = "visible";
				elmbr = toolbox.offsetWidth;
				elmhoe = toolbox.offsetHeight;
			}
		}
	}
}

function HideBubble() {
	showhelp = false;
	if (toolbox) {
		if (DOM || MSIE4) getElement("id","bubble",null).style.visibility = "hidden";
		if (NS4) getElement("id","bubble",null).visibility = "hide";
	}
}

