
// Browser detector (S:--)

/* RESERVED WORDS: browser */

/* PROPERTIES:
     browser.code - code of the detected browser:
                   -1 - Not detected;
                    0 - Internet Explorer;
                    1 - Netscape Communicator;
                    2 - Opera.

     browser.version - version of the detected browser:
                      -1 - Not detected.

     browser.platform - platform of the detected browser:
                       -1 - Not detected.

     browser.addInfo - additional information - for further compatibility */

/* Known browsers: Microsoft Internet Explorer
                   Netscape (MOZILLA Version)
                   Opera */

browser = new Object();
browser.code = -1;
browser.version = -1;
browser.platform = -1;
browser.addInfo = -1;

if (typeof navigator != "undefined")
  {

    // Getting browser's code

    if (navigator.appName && navigator.userAgent)
      switch (navigator.appName)
        {
          case "Microsoft Internet Explorer" :
            browser.code = (navigator.userAgent.indexOf("Opera") == -1) ? 0 : 2;
            break;
          case "Netscape" :
            browser.code = (navigator.userAgent.indexOf("Opera") == -1) ? 1 : 2;
            break;
          case "Opera" :
            browser.code = 2
        }

    // Getting browser's version

    switch (browser.code)
      {
        case 0 :
          if (navigator.appVersion)
            if (navigator.appVersion.indexOf("MSIE") > -1)
              if (!isNaN(parseFloat(navigator.appVersion.split("MSIE")[1])))
                browser.version = parseFloat(navigator.appVersion.split("MSIE")[1]);
          break;
        case 1 :
          if (navigator.appVersion && navigator.userAgent)
           {
             if (navigator.userAgent.indexOf("Mozilla") > -1)
               if (!isNaN(parseFloat(navigator.userAgent.split("Mozilla/")[1])))
                 browser.version = parseFloat(navigator.userAgent.split("Mozilla/")[1])
           }
          break;
        case 2 :
          if (navigator.userAgent)
            if (navigator.userAgent.indexOf("Opera") > -1)
              {
                if (!isNaN(parseFloat(navigator.userAgent.split("Opera")[1])))
                  browser.version = parseFloat(navigator.userAgent.split("Opera")[1]);
                if (!isNaN(parseFloat(navigator.userAgent.split("Opera/")[1])))
                  browser.version = parseFloat(navigator.userAgent.split("Opera/")[1])
              }
      }

    // Getting browser's platform

    if (navigator.platform)
      browser.platform = navigator.platform
  }