
/********************************************************************
 *Browser Sniffer v1.0
 *Michael Binniger (mixel); heimat.de
 *
 *changelog:
 *05.04.2000 mixel: Erkennung des Real-player-Plugins hinzugefügt
 *04.03.2000 mixel: Sicherheitseinstellung hoch bei IE verhindert Download
 *                  von Flash-content. Jetzt wird entsprechend darauf reagiert.
 *                  neuer Prototyp: noflash(name,url,message);
 *31.03.2000 mixel: Bugfix fuer Flashabfrage aller ie.
 *                  function noflash(url) eingefuegt.
 *30.03.2000 mixel: Bugfix fuer jScript-Hang bei Flashabfrage bei ie4.6mac
 ********************************************************************/


function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()

    // *** BROWSER VERSION ***
    this.major = parseInt(navigator.appVersion)
    this.minor = parseFloat(navigator.appVersion)

    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav2 = (this.nav && (this.major == 2))
    this.nav3 = (this.nav && (this.major == 3))
    this.nav4 = (this.nav && (this.major == 4))
    this.nav4up = this.nav && (this.major >= 4)

    this.navonly      = (this.nav && (agt.indexOf(";nav") != -1))

    this.ie   = (agt.indexOf("msie") != -1)
    this.ie3  = (this.ie && (this.major == 2))
    this.ie4  = (this.ie && (this.major == 4))
    this.ie4up  = this.ie  && (this.major >= 4)

    this.opera = (agt.indexOf("opera") != -1)

    if (this.nav2 || this.ie3) this.js = 1.0
    else if (this.nav3 || this.opera) this.js = 1.1
    else if (this.nav4 || this.ie4) this.js = 1.2

    else if ((this.nav && (this.minor > 4.05)) || (this.ie && (this.major > 4)))
         this.js = 1.2
    else this.js = 0.0 // HACK: always check for JS version with > or >=

    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) )
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1))

    this.win16 = ((agt.indexOf("win16")!=-1)
               || (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1)
               || (agt.indexOf("windows 16-bit")!=-1) )

    this.win31 = (agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                 (agt.indexOf("windows 16-bit")!=-1)

    this.win98 = ((agt.indexOf("win98")!=-1)||(agt.indexOf("windows 98")!=-1))
    this.winnt = ((agt.indexOf("winnt")!=-1)||(agt.indexOf("windows nt")!=-1))
    this.win32 = this.win95 || this.winnt || this.win98 ||
                 ((this.major >= 4) && (navigator.platform == "Win32")) ||
                 (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1)

    this.os2   = (agt.indexOf("os/2")!=-1)
                 || (navigator.appVersion.indexOf("OS/2")!=-1)
                 || (agt.indexOf("ibm-webexplorer")!=-1)

    this.mac    = (agt.indexOf("mac")!=-1)
    this.mac68k = this.mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1))
    this.macppc = this.mac && ((agt.indexOf("ppc")!=-1) ||
                               (agt.indexOf("powerpc")!=-1))
    this.linux = (agt.indexOf("inux")!=-1)

    //shockwave-flash-plugin detektieren
    if(this.nav)     //funktioniert nur bei nav
    {
            this.shkw = navigator.mimeTypes["application/x-shockwave-flash"] != null;
            this.shkw = this.shkw && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin!= null;
    }
    else
        this.shkw=true;    //kann nur zur Laufzeit abgefangen werden

    //real-player-plugin detektieren
    if(this.nav)     //funktioniert nur bei nav
    {
            this.real = navigator.mimeTypes["audio/x-pn-realaudio-plugin"] != null;
            this.real = this.real && navigator.mimeTypes["audio/x-pn-realaudio-plugin"].enabledPlugin!= null;
    }
    else
        this.real=true;    //kann nur zur Laufzeit abgefangen werden

}

var is = new Is()

/*******************************************************************************************
 *Diese Funktion detektiert das Flash-Plugin beim IE. Sie muss auf der Seite, die den
 *Flash-Movie enthält, mit onload im Body-Tag aufgerufen werden.
 *
 *Parameter: name: Name des Plugins wie im EMBED-Tag mit name angegeben
 *            url: Seite auf die Umgeleitet wird, wenn kein Flash angezeigt werden kann.
 *        message: (optional) Falls die Sicherheitseinstellung beim IE die Darstellung
 *                    von Flash-Content verbietet, wird ein hier angegebener Text in einer
 *                    alert-box vor dem Redirect angezeigt.
 *******************************************************************************************/

function noflash(name,url,message)
{
  if (is.ie4)
  {
          var c=0;
          if(document.embeds)                    //ist plugin da, liegen hier 2 objekte
          {
                for(var i in document.embeds)    //objekte zählen
                        c++;
          }
          if(c==1)
          {                                     //nur ein objekt gefunden, kein Plugin
                is.shkw=false;
                location=url;                   //dann auf Seite ohne Flash umleiten
          }                                     //verbietet Securitypolicy dem Flash den
                                                //Webzugriff, dann fehlt diese property
          obj=eval("document." + name + ".Movie");
          if(!obj)
          {
                if(message)                     //Message anzeigen, falls vorhanden
                           alert(message);
                is.shkw=false;
                location=url;                   //dann auf Seite ohne Flash umleiten
          }
  }
  else                                          //Kein IE, dann die übliche Methode
  {
      if(!is.shkw)
                  location=url;
  }
}

/*******************************************************************************************
 *Diese Funktion detektiert das Real-Plugin beim IE. Sie muss auf der Seite, die den
 *Real-Movie enthält, mit onload im Body-Tag aufgerufen werden.
 *
 *Parameter: name: Name des Plugins wie im EMBED-Tag mit name angegeben
 *            url: Seite auf die Umgeleitet wird, wenn kein Real angezeigt werden kann.
 *        message: (optional) Falls die Sicherheitseinstellung beim IE die Darstellung
 *                    von Real-Content verbietet, wird ein hier angegebener Text in einer
 *                    alert-box vor dem Redirect angezeigt.
 *******************************************************************************************/

function noreal(name,url,message)
{
  if (is.ie4)
  {
          var c=0;
          if(document.embeds)                    //ist plugin da, liegen hier 2 objekte
          {
                for(var i in document.embeds)    //objekte zählen
                        c++;
          }
          if(c==1)
          {                                     //nur ein objekt gefunden, kein Plugin
                is.real=false;
                location=url;                   //dann auf Seite ohne Flash umleiten
          }                                     //verbietet Securitypolicy dem Flash den
                                                //Webzugriff, dann fehlt diese property
          obj=eval("document." + name + ".AutoStart");
          if(!obj)
          {
                if(message)                     //Message anzeigen, falls vorhanden
                           alert(message);
                is.real=false;
                location=url;                   //dann auf Seite ohne Flash umleiten
          }
  }
  else                                          //Kein IE, dann die übliche Methode
  {
      if(!is.real)
                  location=url;
  }
}

