


// Erzeugen einer Textfahne, fals ein Objekt mit der Maus überfahren wird.
// Copyright: Patrick Wagner, www.patrickwagner.de
// Einbindung in ein HTML-Dokument: <script langauge="JavaScript" type="text/javascript" src="./Textfahne.js"></script>
// Aufruf: <a href="javaScript: nichts();" onMouseover='showComment("Text")' onMouseout ='hideComment()'>
// Aufruf im <img>-Tag: <img src="Bild.JPG" width="600" onMouseover="showComment('Text')" onMouseout ="hideComment()">

var aktiv = false;
if (document)
{
  document.write('<div id="comment" style="position: absolute; width:135px; visibility:hidden; color:#000000;  background-color:#cFcFcf; border: 1px solid #000000; font:normal 10px comic sans ms; padding:1pt;">&nbsp;</div>');
  document.onmousemove = MousemoveHandler;
}

// Bestimme die Position des Mauszeigers
function MousemoveHandler(e){
  if (document.all) // Microsoft Internet Explorer
  {
    xPosMaus = document.body.scrollLeft  + event.clientX - 10;
    yPosMaus = document.body.scrollTop +  event.clientY +20;


  }
  else if (document) // Mozilla
  {
    xPosMaus = document.body.scrollLeft + e.clientX - 10;
    yPosMaus = document.body.scrollTop  + e.clientY + 20;
  }
  if (aktiv == true) moveComment();
}

// Verschieben der Textfahne falls sie bereits sichtbar ist
function moveComment() {
  if (document)
  {

    document.getElementById("comment").style.left = xPosMaus - xPosMaus +20;
    document.getElementById("comment").style.top   = yPosMaus  + 1  ;
      }
}

// Einblenden der Textfahne mit übergebenem Text
function showComment(aktuellerText) {
  if (document)
  {
    document.getElementById("comment").style.visibility = "visible";
    document.getElementById("comment").firstChild.nodeValue = aktuellerText;
  }
  aktiv = true;
}

// Ausblenden der Textfahne
function hideComment() {
  if (document)
  {
    document.getElementById("comment").style.visibility = "hidden";
    aktiv = false;
    xPosMaus = -500;
    yPosMaus = -500;
    moveComment();
  }
}