// Diese Routinen und Algorithmen sind urheberlich geschützt (c) von Reinhard Doberstein, Mannheim; info@doberstein.com !
// This funktions are copyright (c) by Reinhard Doberstein, info@doberstein.com !

var ns = 0;
var ns6= 0;
var ie = 0;
var op = 0;
var programmVersion = "version=1.4";
// ab Version 1.4, Erkennung von Flash 8 möglich

//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return "";
}

//
//  Function to create or update a cookie.
//    name - String object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}


function ersetze(txt){
        erg = "";
        if (ns == 1 || ie == 1) {
                ln = txt.length;
                zeichen = "0123456789ABCDEF";
                zeichen_ok = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                for(i = 0; i <= ln; i++){
                        c = txt.charAt(i);
                        if (zeichen_ok.indexOf(c) < 0 ) {
                                nm = c.charCodeAt(0);
                                nm_hi = Math.floor(nm / 16);
                                nm_lo = nm - (16*nm_hi);
                                nm_hi_c = zeichen.charAt(nm_hi);
                                nm_lo_c = zeichen.charAt(nm_lo);
                                erg += "%" + nm_hi_c + nm_lo_c;
                        } else {
                                erg += c;
                        }
                }
        } else {
                erg = txt;
        }
        return erg;
}

//-------------------------------------------                create_statistik()                ---------------------------


function create_statistik(){
        // alert ("statistik.js: IN create_statistik()");

        parameter = programmVersion;
        parameter += "&javascript=" + 1;
        parameter += "&javascriptversion=" + jsVersion;

        br = "-1";
        if ( ns == 1 ) {
                br = "NS";
        } else if ( ie == 1) {
                br = "IE";
        }
        parameter += "&browser=" + br ;

   mitJava = -1;
   BrowserCodeName = navigator.appCodeName;        // ab NS2 + IE3
        parameter += "&appCodeName=" + ersetze(BrowserCodeName);
   BrowserName = navigator.appName;                // ab NS2 + IE3
        parameter += "&appName=" + ersetze(BrowserName);
   BrowserVersion = navigator.appVersion;                // ab NS2 + IE3
        parameter += "&appVersion=" + ersetze(BrowserVersion);
   BrowserPlatform = navigator.platform;                // ab NS4 + IE4
        parameter += "&platform=" + ersetze(BrowserPlatform);
   Agent = navigator.userAgent;                        // ab NS2 + IE3
        parameter += "&userAgent=" + ersetze(Agent);
   V = BrowserVersion.split(" ");
/*
   if ((BrowserName == "Netscape" && V[0] >=  3.0  ) ||
        BrowserName.indexOf( "Explorer") >= 0 && V[0] >=  4.0 ) {
     mitJava = navigator.javaEnabled();                        // ab NS3 + IE4
     if ( mitJava == 'true' ) {
       mitJava = 1;
     } else {
       mitJava = 0;
     }
*/
     if ( ns ==1 || ie ==1 || op ==1) {
       mitJava = navigator.javaEnabled();                        // ab NS3 + IE4
     } else {
       mitJava = -1;
     }
     if ( mitJava == true ) {
       mitJava = '1';
     } else {
       mitJava = '0';
     }
     parameter += "&java=" +mitJava ;
/*
   } else {
     mitJava = -1;
                parameter += "&java=0";
   }
*/

        if ( ns == 1 || ie == 1  || op ==1) {
     do_screen = true;
     do_window = true;
     do_clip = true;
        } else {
     do_screen = false;
     do_window = false;
     do_clip = false;
        }

   if ( do_window == true) {
                // Parameter des Windows ermitteln
                if ( ie == 1) {
                   F_breite_innen = document.body.clientWidth ;
                   F_hoehe_innen = document.body.clientHeight;
                   F_breite_aussen = -1;        // kein IE
                   F_hoehe_aussen = -1;        // kein IE
                }
                if ( ns == 1 || op ==1) {
                   F_breite_innen = window.innerWidth;        // ab NS4 kein IE
                   F_hoehe_innen = window.innerHeight;        // ab NS4 kein IE
                   F_breite_aussen = window.outerWidth;        // ab NS4 kein IE
                   F_hoehe_aussen = window.outerHeight;        // ab NS4 kein IE
                }
   } else {
           F_breite_innen = -1;
           F_hoehe_innen = -1;
           F_breite_aussen = -1;
           F_hoehe_aussen = -1;
   }
        parameter += "&window.innerWidth=" + F_breite_innen ;
        parameter += "&window.innerHeight=" + F_hoehe_innen ;
        parameter += "&window.outerWidth=" + F_breite_aussen ;
        parameter += "&window.outerHeight=" + F_hoehe_aussen ;

   if ( do_screen == true ) {
                // Parameter des Screens ermitteln
           S_breite = screen.width;                        // ab NS4 + IE3.02
           S_hoehe = screen.height;                        // ab NS4 + IE3.02
           Farb_tiefe = screen.colorDepth;                // ab NS4 + IE3.02
   } else {
           S_hoehe = -1;
           S_breite = -1;
           Farb_tiefe = -1;
   }
        parameter += "&screen.width=" + S_breite ;
        parameter += "&screen.height=" + S_hoehe ;
        parameter += "&screen.colorDepth=" + Farb_tiefe ;

   br = 0;
   he = 0;
   brFix = 0;
   heFix = 0;
   br_mdash = 0;
   he_mdash = 0;
   brFix_mdash = 0;
   heFix_mdash = 0;

   if ( do_clip == true ) {
                if ( ns == 1  || op ==1) {
                        // Breite und Höhe eines Textes ermitteln
                   if ( ns6 ==1  || op ==1) {
                      // NS6
                      br = document.getElementById("testSize").offsetWidth;
                      he = document.getElementById("testSize").offsetHeight;
                      brFix = document.getElementById("testSizeFix").offsetWidth;
                      heFix = document.getElementById("testSizeFix").offsetHeight;
                      br_mdash = document.getElementById("testSizemdash").offsetWidth;
                      he_mdash = document.getElementById("testSizemdash").offsetHeight;
                      brFix_mdash = document.getElementById("testSizemdashFix").offsetWidth;
                      heFix_mdash = document.getElementById("testSizemdashFix").offsetHeight;
                   } else {
                      // NS 4
                      br = document.testSize.document.testSizeL.clip.width;
                      he = document.testSize.document.testSizeL.clip.height;
                      brFix = document.testSizeFix.document.testSizeLFix.clip.width;
                      heFix = document.testSizeFix.document.testSizeLFix.clip.height;
                      br_mdash = document.testSizemdash.document.testSizeLmdash.clip.width;
                      he_mdash = document.testSizemdash.document.testSizeLmdash.clip.height;
                      brFix_mdash = document.testSizemdashFix.document.testSizeLmdashFix.clip.width;
                      heFix_mdash = document.testSizemdashFix.document.testSizeLmdashFix.clip.height;
                   }
                }
                if ( ie == 1) {
                        // Breite und Höhe eines Textes ermitteln
                   br = document.all.testSize.offsetWidth; // ergibt den richtigen Wert nur, wenn position:absolute gewählt ist
                   he = document.all.testSize.offsetHeight;
                   brFix = document.all.testSizeFix.offsetWidth; // ergibt den richtigen Wert nur, wenn position:absolute gewählt ist
                   heFix = document.all.testSizeFix.offsetHeight;
                   br_mdash = document.all.testSizemdash.offsetWidth; // ergibt den richtigen Wert nur, wenn position:absolute gewählt ist
                   he_mdash = document.all.testSizemdash.offsetHeight;
                   brFix_mdash = document.all.testSizemdashFix.offsetWidth; // ergibt den richtigen Wert nur, wenn position:absolute gewählt ist
                   heFix_mdash = document.all.testSizemdashFix.offsetHeight;
                }
        } else {
                br = -1;
                he = -1;
                brFix = -1;
                heFix = -1;
        }
        parameter += "&clip.width=" + br;
        parameter += "&clip.height=" + he;
        parameter += "&clipFix.width=" + brFix;
        parameter += "&clipFix.height=" + heFix;
        parameter += "&mdash.width=" + br_mdash;
        parameter += "&mdash.height=" + he_mdash;
        parameter += "&mdashFix.width=" + brFix_mdash;
        parameter += "&mdashFix.height=" + heFix_mdash;

        pl = "";
        if ( ns == 1  || op ==1) {
                pl = "" + navigator.plugins.length;
                for(j=0; j< navigator.plugins.length; ++j){
                        pl += "," + ersetze(navigator.plugins[j].name);
                        pl += "," + ersetze(navigator.plugins[j].description);
                }
        } else {
                pl = -1;
        }

        // parameter += "&plugins=" + pl;

        // ref = document.referrer;
        // p = ref.replace(/&/,"%26");
        // p = p.replace("=","%3d");

        // var Ausdruck = /(\w.+)\s(\w.+)/;
        // Ausdruck.exec(Wert);

        parameter += "&woher=" + ersetze(document.referrer);

        // Cookiebehandung
        cookiename = "ReDoTest";
        Zufall = parseInt(Math.random()*1000000);
        SetCookie (cookiename, "" + Zufall);
        co = GetCookie (cookiename);
        if ( co == Zufall ) {
          parameter += "&cookies=1";
        } else {
          parameter += "&cookies=0";
        }

        cookiename = "ReDoTravel";
        co = GetCookie (cookiename);
        if ( co != "") {
            value = co.split("-");
            value[1]= 1 + parseInt(value[1]);
        } else {
            value = new Array()
            value[0]= parseInt(Math.random()*1000000);
            value[1]= 1;
        }
        SetCookie (cookiename, "" + value[0] + "-" + value[1]);
        parameter += "&besucherid=" + value[0];
        parameter += "&seitenzaehler=" + value[1];

        plugin3type = "Shockwave Flash 3";
        plugin4type = "Shockwave Flash 4";
        plugin5type = "Shockwave Flash 5";
        plugin6type = "Shockwave Flash 6";
        plugin7type = "Shockwave Flash 7";
        plugin8type = "Shockwave Flash 8";
        plugin9type = "Shockwave Flash 9";
        plugin10type = "Shockwave Flash 10";
        plugin11type = "Shockwave Flash 11";
        treffer = false;
        gefunden = "";
        if ( ns ==1  || op ==1) {
          for(i=0;i<navigator.plugins.length;i++) {
            if(navigator.plugins[i].description.indexOf(plugin7type) > -1 && treffer == false ){
              gefunden = "7";
              treffer = true;
            }
            if(navigator.plugins[i].description.indexOf(plugin6type) > -1 && treffer == false ){
              gefunden = "6";
              treffer = true;
            }
            if(navigator.plugins[i].description.indexOf(plugin5type) > -1 && treffer == false ){
              gefunden = "5";
              treffer = true;
            }
            if(navigator.plugins[i].description.indexOf(plugin4type) > -1 && treffer == false ){
              gefunden = "4";
              treffer = true;
            }
            if(navigator.plugins[i].description.indexOf(plugin3type) > -1 && treffer == false ){
              gefunden = "3";
              treffer = true;
            }
          }
        }
        if ( ie ==1 ) {
          if ( FlashMode11 && treffer == false ) {
              gefunden = "11";
              treffer = true;
          }
          if ( FlashMode10 && treffer == false ) {
              gefunden = "10";
              treffer = true;
          }
          if ( FlashMode9 && treffer == false ) {
              gefunden = "9";
              treffer = true;
          }
          if ( FlashMode8 && treffer == false ) {
              gefunden = "8";
              treffer = true;
          }
          if ( FlashMode7 && treffer == false ) {
              gefunden = "7";
              treffer = true;
          }
          if ( FlashMode6 && treffer == false ) {
              gefunden = "6";
              treffer = true;
          }
          if ( FlashMode5 && treffer == false ) {
              gefunden = "5";
              treffer = true;
          }
          if ( FlashMode4 && treffer == false ) {
              gefunden = "4";
              treffer = true;
          }
          if ( FlashMode3 && treffer == false ) {
              gefunden = "3";
              treffer = true;
          }
        }
        if ( treffer == true) {
          parameter += "&Flashversion=" + gefunden;
        } else {
          parameter += "&Flashversion=0";
        }

        // PDF Plugin abchecken
        plugin1type = "Adobe Acrobat";
        plugin5type = "Adobe Acrobat Plug-In Version 5.00 for Netscape";
        plugin4type = "Netscape Navigator Plug-in for Adobe Acrobat v4";
        treffer = false;
        gefunden = "";
        if ( ns ==1 || op ==1) {
          for(i=0;i<navigator.plugins.length;i++) {
            if(navigator.plugins[i].description.indexOf(plugin5type) > -1 && treffer == false ){
              gefunden = "5";
              treffer = true;
            }
            if(navigator.plugins[i].description.indexOf(plugin4type) > -1 && treffer == false ){
              gefunden = "4";
              treffer = true;
            }
            if(navigator.plugins[i].description.indexOf(plugin1type) > -1 && treffer == false ){
              gefunden = "1";
              treffer = true;
            }
          }
        }
        if ( ie == 1) {
          if ( PDFMode11 && treffer == false ) {
              gefunden = "11";
              treffer = true;
          }
          if ( PDFMode10 && treffer == false ) {
              gefunden = "10";
              treffer = true;
          }
          if ( PDFMode9 && treffer == false ) {
              gefunden = "9";
              treffer = true;
          }
          if ( PDFMode8 && treffer == false ) {
              gefunden = "8";
              treffer = true;
          }
          if ( PDFMode7 && treffer == false ) {
              gefunden = "7";
              treffer = true;
          }
          if ( PDFMode6 && treffer == false ) {
              gefunden = "6";
              treffer = true;
          }
          if ( PDFMode5 && treffer == false ) {
              gefunden = "5";
              treffer = true;
          }
          if ( PDFMode4 && treffer == false ) {
              gefunden = "4";
              treffer = true;
          }
          if ( PDFMode3 && treffer == false ) {
              gefunden = "3";
              treffer = true;
          }
          if ( PDFMode2 && treffer == false ) {
              gefunden = "2";
              treffer = true;
          }
          if ( PDFMode1 && treffer == false ) {
              gefunden = "1";
              treffer = true;
          }
        }
        if ( treffer == true) {
          parameter += "&PDFversion=" + gefunden;
        } else {
          parameter += "&PDFversion=0";
        }


        // Quicktime abchecken
        plugin1type = "QuickTime Plug-In";
        plugin4type = "QuickTime Plug-in 4";
        plugin5type = "QuickTime Plug-in 5";
        plugin6type = "QuickTime Plug-in 6";
        plugin7type = "QuickTime Plug-in 7";
        treffer = false;
        gefunden = 0;
        if ( ns ==1 || op ==1) {
          for(i=0;i<navigator.plugins.length;i++) {
            if((navigator.plugins[i].description.indexOf(plugin7type) > -1 || navigator.plugins[i].name.indexOf(plugin7type) > -1) && gefunden  < 7 ){
              gefunden = 7;
              treffer = true;
            }
            if((navigator.plugins[i].description.indexOf(plugin6type) > -1 || navigator.plugins[i].name.indexOf(plugin6type) > -1) && gefunden  < 6 ){
              gefunden = 6;
              treffer = true;
            }
            if((navigator.plugins[i].description.indexOf(plugin5type) > -1 || navigator.plugins[i].name.indexOf(plugin5type) > -1) && gefunden  < 5 ){
              gefunden = 5;
              treffer = true;
            }
            if((navigator.plugins[i].description.indexOf(plugin4type) > -1 || navigator.plugins[i].name.indexOf(plugin4type) > -1) && gefunden  < 4 ){
              gefunden = 4;
              treffer = true;
            }
            if((navigator.plugins[i].description.indexOf(plugin1type) > -1 || navigator.plugins[i].name.indexOf(plugin1type) > -1) && gefunden  < 1 ){
              gefunden = 1;
              treffer = true;
            }
          }
        }
        if ( ie == 1) {
          if ( QuicktimeMode9 && treffer == false ) {
              gefunden = 9;
              treffer = true;
          }
          if ( QuicktimeMode8 && treffer == false ) {
              gefunden = 8;
              treffer = true;
          }
          if ( QuicktimeMode7 && treffer == false ) {
              gefunden = 7;
              treffer = true;
          }
          if ( QuicktimeMode6 && treffer == false ) {
              gefunden = 6;
              treffer = true;
          }
          if ( QuicktimeMode5 && treffer == false ) {
              gefunden = 5;
              treffer = true;
          }
          if ( QuicktimeMode4 && treffer == false ) {
              gefunden = 4;
              treffer = true;
          }
          if ( QuicktimeMode3 && treffer == false ) {
              gefunden = 3;
              treffer = true;
          }
          if ( QuicktimeMode2 && treffer == false ) {
              gefunden = 2;
              treffer = true;
          }
          if ( QuicktimeMode1 && treffer == false ) {
              gefunden = 1;
              treffer = true;
          }
        }
        if ( treffer == true) {
          parameter += "&QuicktimeVersion=" + gefunden;
        } else {
          parameter += "&QuicktimeVersion=0";
        }

        if ( window.opera ) {
          parameter += "&Opera=1";
          opera = 1;
        } else {
          parameter += "&Opera=0" ;
          opera = 0;
        }


        out = "<IMG src=\"/cgi-bin/statistik.pl?" + parameter + "\" width=1 height=1 alt=\"\">";
// alert ("out= '" + out +"'");
// alert ("ns = " + ns + " ;ie = "+ie);
      // alert ("statistik.js: IN create_statistik() E,");
      var bild = new Image();
      bild.src = "/cgi-bin/statistik.pl?" + parameter;
        if (ns == 1){
//              alert ("statistik.js: IN create_statistik() F" );
//                with( document.CreateLog.document) {
//                              // alert ("statistik.js: IN create_statistik() F2" );
//                        open();
//                              // alert ("statistik.js: IN create_statistik() F3" );
//                        write(out);
//                              // alert ("statistik.js: IN create_statistik() F4" );
//                        close();
//                              // alert ("statistik.js: IN create_statistik() F5" );
//                }
//              alert ("statistik.js: IN create_statistik() F-B" );
//
        } else if ( ie == 1) {
              // alert ("statistik.js: IN create_statistik() G" );
              //  CreateLog.innerHTML=out;
        }
        // alert ("statistik.js: out=" + out);
};


appNameS = navigator.appName;
appVersionF = parseFloat(navigator.appVersion);
appVersionI = parseInt(navigator.appVersion);

if ( appNameS.toLowerCase().indexOf("netscape") >= 0) ns =1;
if ( appNameS.toLowerCase().indexOf("explorer") >= 0) ie =1;

if ( ns == 1) {
  if ( appVersionI >= 5) {
    ns6 = 1;
  }
}
if ( window.opera ) {
  op = 1;
}


document.onLoad = create_statistik();
