// globale Variablen
var ID1; //Timeout-IDs
var guideText, guideGrafik;

// Browser
var N4=false, IE=false, W3C=false;
  
function init() {
  if (document.layers) 
    N4 = true;
  else if (document.all)
    IE = true;
  else if (document.getElementById)
    W3C = true;

  //alert(N4 + " " + IE + " " + W3C);
  
  // globale Referenz auf Banner
  if (N4) {
    guideText = document.GuideText;
    guideGrafik = document.GuideGrafik;
  } else if (IE) {
    guideText = document.all.GuideText.style;
    guideGrafik = document.all.GuideGrafik.style;
  } else if (W3C) {
    guideText = document.getElementById("GuideText").style;
    guideGrafik = document.getElementById("GuideGrafik").style;
  }

//  if (IE && W3C && !bannerstil.left) // Abgrenzung zwischen IE und Opera der sich als IE5 ausgibt
//  if (IE)
//    W3C = false;
//  alert("2");
//  alert(N4 + " " + IE + " " + W3C);

  ID1 = window.setTimeout("animation()", 50);
}
  
// Hilfsfunktionen

function XOffset() {
  if (N4 || W3C)
    return window.pageXOffset;
  else if (IE)
    return document.body.scrollLeft;
}

function YOffset() {
  if (N4 || W3C)
    return window.pageYOffset;
  else if (IE)
    return document.body.scrollTop;
}

function browserbreite() {
  if (N4 || W3C)
    return window.innerWidth;
  else if (IE)
    return document.body.clientWidth;
}

function browserhoehe() {
  if (N4 || W3C)
    return window.innerHeight;
  else if (IE)
    return document.body.clientHeight;
}

function positionX() {  //x-Koordinate der Grafik
  if (N4 || W3C)
    return parseInt(guideText.left);
  if (IE)
    return parseInt(guideText.posLeft);
}

function positionY() {  //y-Koordinate der Grafik
  if (N4 || W3C)
    return parseInt(guideText.top);
  if (IE)
    return parseInt(guideText.posTop);
}

function bewege(y) {
//  alert("4: " + x + ", " + y);

  if (N4) {
    guideText.top = y;
    guideGrafik.top = y - 50;
  } else if (IE) {
    guideText.posTop = y;
    guideGrafik.posTop = y - 50;
  } else if (W3C) {
    guideText.top = y + "px";
    guideGrafik.top = (y - 50) + "px";
  }
}

function animation() {
  //alert(positionY() + "  " + YOffset());
  
  if (positionY() != YOffset()) {
    d = Math.max(10, Math.abs(positionY() - YOffset()) / 5);
    
    if (Math.abs(positionY() - YOffset()) < 10)
      bewege(YOffset());
    else if (positionY() < YOffset())
      bewege(positionY() + d);
    else
      bewege(positionY() - d);
    
  }
      
  ID1 = window.setTimeout("animation()", 50); //Position auch beim Scrollen beibehalten
}

