// Kontextscript erstellt das Infofenster (Info I, blau)
var x = 0;
var xx=10;
var yy=0;
var y = 0;
var over="";
var showit = 0;
var TipWndWidth = 350; // muss an die Fenstergr&ouml;sse angepasst werden
var yAbstand=10;        // Abstand vom Cursor
var xAbstand=10;
////////////////////////////Herausfinden des benutzten Browser des Kunden///////////////////////////////////
ns = (document.layers)? true:false
ie4 = (document.all)? true:false
ie5 = false;
ff = false;

if (navigator.userAgent.indexOf('Firefox')>0) {ff = true;}
if (typeof(document.addEventListener)=="function" && ff==false) {ff = true;}

if (ie4)
{
  if (navigator.userAgent.indexOf('MSIE 5')>0) {ie5 = true;}
  if (navigator.userAgent.indexOf('MSIE 6')>0) {ie5 = true;}
}

// Welche Plattform? bei IE auf MAC keine popi-Fenster
if ( navigator.platform.substring(0,3).toUpperCase() == "MAC" && (ie4 || ie5) )
   mac = true;
else
   mac = false;

if ( (ns) || (ie4) || (ff) )
{
    if (ns)
        over = document.TipWnd;
    if (ie4 || ff)
	{
	    over = document.getElementById("TipWnd").style;
	}
	//mozilla
    if (typeof(document.addEventListener)=="function"){
        document.addEventListener("mousemove",mouseMove,true);
	}
    document.onmousemove = mouseMove;
    if (ns)
        document.captureEvents(Event.MOUSEMOVE);
}

function wtl(txt)
{
    if (ns)
    {
        var lll = document.TipWnd.document;
        lll.write(txt);
        lll.close();
    }
    else
    {
        if (ie4 || ff)
        {
            document.getElementById('TipWnd').innerHTML = txt;
        }
    }
}
function show(obj)
{
    if (ns)
        obj.visibility = "show";
    else if (ie4 || ff)
        obj.visibility = "visible";
}
function hide(obj)
{
    if (ns)
        obj.visibility = "hide";
    else if (ie4 || ff)
        obj.visibility = "hidden";
}
function moveTo(obj,lx,ly)
{
    obj.left = Math.max(lx,0)+"px";
    obj.top = Math.max(ly,0)+"px";
}
function popuphidden()
{
    if (mac)
        return;
    if ( (ns) || (ie4) || (ff))
        {showit=0;hide(over);}
}
///////////////////////////////// zusammenstellen des Popup Fensters////////////////////////////////

function rpopi(text, title)
{
    txt = '<TABLE width="'+TipWndWidth+'" class="popup" id="MainTable">';
    txt+= "<TR><TD>";
    txt+= '<TABLE class=popuptitel width="100%">';
    txt+= "<TR><TD>";
    txt+= '<SPAN ID="thetext">';
    txt+= '<B><FONT face="Arial" size=-1>'+title+'</FONT></B>';
    txt+= "</SPAN></TD></TR></TABLE>";
    txt+= '<TABLE class="popuptext">';
    txt+= "<TR><TD>";
    txt+= '<SPAN ID="thetext2">';
    txt+= '<FONT face="Arial, Helvetica" size="-1" class="lt">';
    txt+= text;
    txt+= "</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>";
    wtl(txt);
    display_it();
}
function popup(i)
{
    if (mac)
        return;
    var ar=i.split("|");
    xx=ar[0];
    yy=Math.max(ar[1],-2000);
    TipWndWidth=ar[2];
    rpopi(ar[4],ar[3]);
}
///////////////////////////// anzeigen des Popup- Fensters//////////////////////////////////////////////////////
function display_it()
{
    if ( (ns) || (ie4) || ff )
    {
        if (showit == 0)
        {
            SetKoord();
            show(over);
            showit = 1;
        }
    }
}
////////////////////////////// Auf mousemoves reagieren////////////////////////////////////////////////////////
function mouseMove(e)
{
    if(ff || ns)
        {x=e.pageX;y=e.pageY;}
    if (ie4)
        {x=event.x;y=event.y;}
    if (ie5)
        {x=event.x+document.body.scrollLeft;y=event.y;}
    if (showit)
        SetKoord();
}
function SetKoord()
{
        // netscape
        if(window.pageYOffset && (ff==false))
            moveTo(over,x-xx-TipWndWidth,y+yy+window.pageYOffset+yAbstand);
        // mozilla
		if(ff)
            moveTo(over,x-xx-TipWndWidth,y+yy+yAbstand);
        else
        {   //ie
			yadd=0;
			if (document.documentElement && document.documentElement.scrollTop)
            	yadd= document.documentElement.scrollTop;
            else if (document.body && document.body.scrollTop)
           		yadd= document.body.scrollTop;
			if(yadd < 100)
				yadd=0;
            moveTo(over,x-xx-TipWndWidth+xAbstand,y+yy+yadd+yAbstand);
        }
}
