// Vertikales Ping-Pong mit einem HTML-Element
var x = 0;             // current top-position of the div-area
var speed = 50;        // Intervall in ms, in dem das Zitat um ein Pixel bewegt wird
var xoff = 1;          // offset-Wert 1=down; -1=up
var browser = "";      // default-Wert
var idz = "zitat";     // Default-Bezeichner für Zitat (div-area)
var idt = "table";     // Höhe der Tabelle
var zh, th;            // Tabellen und Zitathöhe
var pause = 5000       // Anfangspause in ms
var tstart;            // Startzeit

function getBrowser() {
  if (browser == "") {
    // IE4
    if (document.all) {
      browser = "ie4";
    }
    // IE5, IE6, Netscape6, Opera6
    // xxx - Blödsinn, hier wird noch offset abgefragt, tasächlich wird aber style.top verwendet
    if ((document.getElementById) && (document.getElementById(idz).offsetTop >= 0)) {
      browser = "ie5c";
    }
    // Netscape 4.x
    if (document.layers) {
      browser = "n4";
    }
  }
  return browser;
}

// die wichtigsten Parameter initialisieren
function init() {
  tstart = new Date().getTime();
  getParams();
}

// startet das Script
function start() {
  setInterval("run()", speed);
}

// move the object within a certain interval over the screen
function run() {
  if (new Date().getTime() - tstart <= pause) {
    // warten
  }
  else {
    move();
  }
}

// Höhe des Zitats bestimmen
function getParams() {
  if (getBrowser() == "ie4") {
    zh = document.all[idz].offsetHeight;
    th = document.all[idt].offsetHeight;
  }
  if (getBrowser() == "ie5c") {
    zh = parseInt(document.getElementById(idz).offsetHeight);
    th = parseInt(document.getElementById(idt).offsetHeight);
  }
  if (getBrowser() == "n4") {
    zh = document.layers[idz].clip.height;
    // wenn sich die Tabellenhöhe nicht als Parameter auslesen läßt, hilfsweise body benutzen
    th = document.layers[idt].clip.height;
  }
}


// actually moves the object
function move() {
  x = x + xoff;
  // turn around at top and bottom
  if ((x == th-zh) || (x == 0)) {
    xoff = xoff * -1;
  }
  xset = x + "px";
  if (getBrowser() == "ie4") {
    document.all[idz].style.top = xset;
  }
  if (getBrowser() == "ie5c") {
    // document.getElementById(idz).style.top = xset;
    document.getElementById(idz).style.top = xset;

  }
  if (getBrowser() == "n4") {
    xnset = parseInt(xset);
    document.layers[idz].top = xnset;
  }
}

// Popup-Fenster
function popWin(w, h, target, scrollbars) {
  posy = (screen.height - h)/2;
  posx = (screen.width - w)/2;
  param = new String("width=" + w + ",height=" + h + ",screenX=" + posx + ",screenY=" + posy + ";resizable=no,dependent=yes");
  if (scrollbars) param = param + ", scrollbars";
  popup = window.open("", target, param);
  popup.focus();
}
function popBio(w, h) {
  param = new String("width=" + w + ",height=" + h + ",resizable=yes,dependent=yes,scrollbars=yes");
  popup = window.open("", "bio", param);
  popup.focus();
}

