// -----------------------------------
// File: ibps_top_of_page.js
//
// Version: 1.0
// Editor: IBPS-Friedrichs
// Contact: info@ibps-friedrichs.com
//
// Last edit: 06.09.2003
//------------------------------------
var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

var siteWidth = 975; // 0 => full usable window width
var tpLinkHeight = 10, tpLinkWidth = 15, tpLinkNS4_offsetX = 5, tpLinkNS4_offsetY = 5, tpLink_offsetX = 0, tpLink_offsetY = 35;

var tpLinkContentBegin = '<div id="tpLink" style="position: absolute; left: 1px; top: 1px; width: ' + tpLinkWidth + 'px; height:' + tpLinkHeight + 'px; z-index: 1; visibility: hidden">';
var tpLinkContent = '<a href="#top"><img src="/images/icon_page-up.gif" width="12" height="9" border="0" title="zum Seitenanfang" alt="zum Seitenanfang"></a>';
var tpLinkContentEnd = '</div>';

tpInit();
window.onload = tpLinkInsert;
window.onresize = tpLinkInsert;

function tpInit() {
 if (window.opera) {
     OP = 1;
 }
 if (document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if (document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
 if (window.netscape && window.screen && !DOM && !OP) {
   DHTML = 1;
   NS = 1;
 }
 if (!NS) { 
   tpLinkContent = tpLinkContentBegin + tpLinkContent + tpLinkContentEnd; 
 }
} // End tpInit

function tpLinkInsert() {
  tpCreateLink();
  tpLinkPositioning();
  setInterval("tpLinkPositioning()",100);
}  // End tpLinkInsert

function tpCreateLink() {
  /*if (NS) {  // Netscape 4.x
    tpLink = new Layer(0);
    tpLink.left = 1;
    tpLink.top = 1;
    tpLink.zIndex = 1;
    tpLink.document.write(tpLinkContent);
    tpLink.document.close();
    tpLink.visibility = "show";
  }
  if (!DOM && MS) {  // MSIE 4.x
    tpLink.style.visibility = "visible";
  } */
  if (DOM) {  // MSIE 5.x/6.x, NS 6.x
    document.getElementById("tpLink").style.visibility = "visible";
  }
}  // End tpCreateLink

function tpLinkPositioning() {
  /*if (NS) {  // Netscape 4.x
    if (siteWidth != 0) {
      tpLink.left = pageXOffset + siteWidth - tpLink.document.width - tpLinkNS4_offsetX;
    } else {
        tpLink.left = pageXOffset + window.innerWidth - tpLink.document.width - tpLinkNS4_offsetX;
      }
    tpLink.top = pageYOffset + window.innerHeight - tpLink.document.height - tpLinkNS4_offsetY;
  }
  
  if (!DOM && MS) { // MSIE 4.x
    if (siteWidth != 0) {
      tpLink.style.left = siteWidth - tpLink.style.pixelWidth - tpLink_offsetX;
    } else {
        tpLink.style.left = document.body.clientWidth - tpLink.style.pixelWidth - tpLink_offsetX;
      }
    tpLink.style.top = document.body.clientHeight + document.body.scrollTop - tpLink.style.pixelHeight - tpLink_offsetY;
  } */
  
  if (DOM) { // MSIE 5.x/6.x, NS 6.x
    if (MS) {
      //if (siteWidth == 0) { siteWidth = document.body.clientWidth; }
      siteWidthFinal = parseInt((document.body.clientWidth/2)+(siteWidth/2))-245;
      if (document.body.clientWidth < siteWidth) { siteWidthFinal = parseInt(siteWidth)-245; }
      siteHeight = document.body.clientHeight + document.body.scrollTop+15;
    } else {
        //if (siteWidth == 0) { siteWidth = window.innerWidth;}
        siteWidthFinal = parseInt((window.innerWidth/2)+(siteWidth/2))-245;
        if (window.innerWidth < siteWidth) { siteWidthFinal = parseInt(siteWidth)-245; }
        siteHeight = window.innerHeight + pageYOffset;
      }
    document.getElementById("tpLink").style.left = siteWidthFinal - parseInt(document.getElementById("tpLink").style.width) - tpLink_offsetX;
    document.getElementById("tpLink").style.top =  siteHeight - parseInt(document.getElementById("tpLink").style.height) - tpLink_offsetY;
  }
}  // End tpLinkPositioning
