/////////////////////////////////////////////////////////////////////
//
//  JavaScript-Modul "PopUp"
//
//  Aufgabe:        stellt Funktion zum Anzeigen eines PopUps an aktueller
//                  Cursor-Position
//
//  Vorraussetzung: -
//
//  Beispiel:       <html><head>
//                    <title>PopUp-Demo</title>
//                    <script type="text/javascript" src="PopUp.js"></script>
//                  </head><body>
//                    <a href="#"
//                       onMouseOver="showPopUp(200, 'PopUp-Inhalt!');"
//                       onMouseOut="hidePopUp();">PopUp anzeigen</a>
//                  </head></html>
//
/////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////
//  Konfiguarion
/////////////////////////////////////////////////////////////////////
var PopUpWidth = -1;     // Breite des PopUps; -1 für automatische Anpassung
var PopUpHeight = -1;    // Höhe des PopUps; -1 für automatische Anpassung

/////////////////////////////////////////////////////////////////////
//  Initialisierung
/////////////////////////////////////////////////////////////////////
var BrowIE5 = false,
    BrowNS6 = false;
var CursorX, CursorY;
var PopUpAktuell = false;

/////////////////////////////////////////////////////////////////////
//  Globaldefinition
/////////////////////////////////////////////////////////////////////
var argtop_global, argleft_global, argContent_global

/////////////////////////////////////////////////////////////////////
//  Browser identifizieren
/////////////////////////////////////////////////////////////////////
if (document.getElementById && document.all && document.styleSheets) { BrowIE5 = true; }
if (document.getElementById && !document.all) { BrowNS6 = true; }



/////////////////////////////////////////////////////////////////////
//  PopUp vorbereiten
/////////////////////////////////////////////////////////////////////
if (BrowIE5 || BrowNS6) {
	document.write(
		"<style type='text/css'>"+
		"  #PopUpDiv {border: 1px solid black; background-color: #DDDDDD; color: #444444;}"+
		"</style>"+
		"<div id='PopUpDiv' style='position:absolute; top:-500px; left:0px; z-index:999999; padding:5px;' onMouseOver='showPopUp(0,0,0);' onMouseOut='hidePopUp();'>&nbsp;</div>");
}

/////////////////////////////////////////////////////////////////////
//  PopUp anzeigen
/////////////////////////////////////////////////////////////////////
function showPopUp(argtop, argleft, argContent){

	if(argtop == 0 && argleft == 0 &&  argContent == 0) {
                argContent = argContent_global;
	  	PositionX = argleft_global;
		PositionY = argtop_global;
        } else {

          if(BrowIE5) {
	  	PositionX = CursorX + document.body.scrollLeft - argleft;
		PositionY = CursorY + document.body.scrollTop - argtop;
	  } else if (BrowNS6) {
	  	PositionX = CursorX - argleft;
		PositionY = CursorY - argtop;
	  }
	}

        desc = argContent;

	document.getElementById("PopUpDiv").style.left = PositionX + "px";
	document.getElementById("PopUpDiv").style.top = PositionY + "px";
	document.getElementById("PopUpDiv").innerHTML = desc;
	PopUpAktuell = true;
	argleft_global = PositionX;
	argtop_global = PositionY;
        argContent_global = argContent;
	return true;
}

/////////////////////////////////////////////////////////////////////
//  PopUp ausblenden
/////////////////////////////////////////////////////////////////////
function hidePopUp() {
		document.getElementById("PopUpDiv").style.top = "-1500px";
		PopUpAktuell = false;
}

/////////////////////////////////////////////////////////////////////
//  Ermittlung der aktuellen Cursorposition
/////////////////////////////////////////////////////////////////////
function getAktCursorPos(e) {
	if (BrowIE5) {
		CursorX = event.clientX;
		CursorY = event.clientY;
	} else if (BrowNS6) {
		CursorX = e.pageX;
		CursorY = e.pageY;
	}
	
 // Fenster mitbewegen?
	// TO-DO
}

/////////////////////////////////////////////////////////////////////
//  bei jeder Mausbewegung die aktuelle Cursorposition bestimmen
/////////////////////////////////////////////////////////////////////
document.onmousemove = getAktCursorPos;

