/**
 * This file defines the <code>Is</code> class, which does the job of detecting the 
 * environment (browser and operating system) that the application 
 * is running in.  
 *
 * <br>(C) Netscape Communications 1999.  
 * <br>
 * Permission granted to reuse and distribute.
 * <br>Code and documentation 
 * modified by TreeLogic Software Engineering (see CHANGELOG).
 *
 * Used for the present software application, Gigapan Explorer, by: <br>
 * Fall-2005-CMU-NASA/Google-Practicum-Subteam: 
 *    <a href="mailto:ehudsons@andrew.cmu.edu">Ellen Hudson-Snyder</a>, 
 *    <a href="mailto:evedar@andrew.cmu.edu">Elvin Vedar</a>, 
 *    <a href="mailto:cbalz@andrew.cmu.edu">Christopher M. Balz</a>.
 * <br><br>CVS Version Info:<br>
 *  $Id: Is.js,v 1.7 2005/12/09 05:49:03 evedar Exp $     
 * <br><br>
 * @author Netscape Communications, with modifications (see above).
 * <br><br>
 */

/**
 * Create a new Is object.
 * This class provides everything you always wanted to know about your 
 * JavaScript client
 * but were afraid to ask. 
 * "Is" is the constructor function for "is" object.
 * <br><br>
 * ** This is an abridged version.
 * <br><br>
 * The full version has the following properties:
 * which has properties indicating:
 * (1) browser vendor:
 *     is.nav, is.ie, is.opera, is.hotjava, is.webtv, is.TVNavigator, is.AOLTV
 * (2) browser version number:
 *     is.major (integer indicating major version number: 2, 3, 4 ...)
 *     is.minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
 * (3) browser vendor AND major version number
 *     is.nav2, is.nav3, is.nav4, is.nav4up, is.nav6, is.nav6up, is.gecko, is.ie3, 
 *     is.ie4, is.ie4up, is.ie5, is.ie5up, is.ie5_5, is.ie5_5up, is.hotjava3, is.hotjava3up
 * (4) JavaScript version number:
 *     is.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
 * (5) OS platform and version:
 *     is.win, is.win16, is.win32, is.win31, is.win95, is.winnt, is.win98, is.winme, is.win2k
 *     is.os2
 *     is.mac, is.mac68k, is.macppc
 *     is.unix
 *     is.sun, is.sun4, is.sun5, is.suni86
 *     is.irix, is.irix5, is.irix6
 *     is.hpux, is.hpux9, is.hpux10
 *     is.aix, is.aix1, is.aix2, is.aix3, is.aix4
 *     is.linux, is.sco, is.unixware, is.mpras, is.reliant
 *     is.dec, is.sinix, is.freebsd, is.bsd
 *     is.vms
 * <br><br>
 *
 * CHANGELOG of Fall-2005-CMU-NASA/Google-Practicum-Subteam
 * <br>
 * Removed code block for Internet Explorer 3 (not needed).
 * <br><br>
 * CHANGELOG of TreeLogic Software Engineering's changes from original version:
 * <br>
 * Cut out all but what is really needed for the customer survey application.
 * Put detection of IE and NN browser versions that are less than version #4
 * at the top of the application, so don't need that code here.  Also don't 
 * need detailed
 * info on Unix o/s variants.  Moved the 
 * formerly global 'is' and 'is3Mac' variables to be type-prepended 
 * properties of the System object.  Updated ie4 detection to cope
 * with IE6 (marked in code below).  Such things are quirky due to the
 * nature of user agent strings (see non-JSDoc comments 
 * in this file for more detail).
 * <br><br>
 * Added detection of Gecko's (Mozilla's) revision number.
 * <br><br>
 * Added detection of Firefox from Mozilla.org.
 * <br><br>
 * CHANGELOG of Netscape Corp.'s changes from earlier versions:
 * <br>
 * Revised 22 Feb 01 to correct Javascript Detection for IE 5.x, Opera 4, 
 *                      correct Opera 5 detection
 *                      add support for winME and win2k
 *                      synch with browser-type-oo.js
 * <br>
 * Revised 26 Mar 01 to correct Opera detection
 * <br><br>
 * Note: See non-JSDoc comments in the code
 * for further detailed information
 * on use of this class.
 * <br><br>
 * @object-prop <code>major</code> The major (to the left of the decimal
 *                    point) version of the browser that the 
 *                    application is running on (the "current" browser).
 * @object-prop <code>minor</code> The minor (to the right of the decimal 
 *                    point) version of the browser that the 
 *                    application is running on (the "current" browser).  
 * @object-prop <code>nav</code> A boolean value indicating whether or not 
 *                  the current browser is a version of Netscape Navigator.
 * @object-prop <code>nav4</code> A boolean value indicating whether or not the current 
 *                   browser is a version of Navigator 4.x.
 * @object-prop <code>nav4up</code> A boolean value indicating whether or not the current
 *                     browser is a version of Navigator 4 or greater.
 * @object-prop <code>nav6</code> A boolean value indicating whether or not the current
 *                   browser is a version of Navigator 6.x.
 * @object-prop <code>nav6up</code> A boolean value indicating whether or not the current
 *                     browser is a version of Navigator 6 or greater.
 * @object-prop <code>gecko</code>  A boolean value indicating whether or not the current
 *                     browser is a version of Mozilla.org's browser or 
 *                     adaptions of or not.
 * @object-prop <code>firefox</code>  A boolean value indicating whether or not the current
 *                       browser is a version of Mozilla.org's Firefox browser 
 *                       or not.
 * @object-prop <code>ie</code>     A boolean value indicating whether or not the current
 *                     browser is a version of the Internet Explorer browser
 *                     or not.
 * @object-prop <code>ie4</code>    A boolean value indicating whether or not the current
 *                     browser is version 4.x of the Internet Explorer browser.
 * @object-prop <code>ie5</code>    A boolean value indicating whether or not the current
 *                     browser is a version 5.x of the Internet Explorer browser.
 * @object-prop <code>ie5_5</code>  A boolean value indicating whether or not the current
 *                     browser is Internet Explorer 5.5 or not.
 * @object-prop <code>ie5up</code> A boolean value indicating whether or not the current
 *                     browser is a version of Internet Explorer 5 or greater.
 * @object-prop <code>aol5up</code> A boolean value indicating whether or not this is the
 *                     browser from America Online (AOL) version 5 and up.  AOL
 *                     browsers are always almost identical to either Internet 
 *                     Explorer or Netscape Navigator, and so they return 
 *                     proper readings for "ie5", etc.
 * @object-prop <code>opera</code>  A boolean value indicating whether or not this is the
 *                     Opera browser.
 * @object-prop <code>win</code>    A boolean value indicating whether or not the current
 *                     operating system is Windows.
 * @object-prop <code>win95</code>  A boolean value indicating whether or not the current
 *                     operating system is Windows 95.
 * @object-prop <code>win16</code>  A boolean value indicating whether or not the current
 *                     operating system is 16-bit Windows.
 * @object-prop <code>win31</code>  A boolean value indicating whether or not the current
 *                     operating system is Windows 3.1.
 * @object-prop <code>win98</code>  A boolean value indicating whether or not the current
 *                     operating system is Windows 98.  Note: on Navigator 4
 *                     and earlier, "Windows" is the only identification made
 *                     (no '98', '95', etc.).
 * @object-prop <code>winnt</code>  A boolean value indicating whether or not the current
 *                     operating system is Windows NT.
 * @object-prop <code>win32</code>  A boolean value indicating whether or not the current
 *                     operating system is a 32-bit version of Windows 95, 98,
 *                     or NT.
 * @object-prop <code>win2k</code>  A boolean value indicating whether or not the current
 *                     operating system is Windows 2000.
 * @object-prop <code>mac</code>    A boolean value indicating whether or not the current
 *                     operating system is Macintosh.
 * @object-prop <code>linux</code>  A boolean value indicating whether or not the current
 *                     operating system is linux.
 */
function Is () {   
    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var rxpGeckoRevision = /(rv:\d+\.\d+)/;
    var strTemp;

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.

    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    this.nav4 = (this.nav && (this.major == 4));
    this.nav4up = (this.nav && (this.major >= 4));
    this.nav6 = (this.nav && (this.major == 5));
    this.nav6up = (this.nav && (this.major >= 5));
    this.gecko = (agt.indexOf('gecko') != -1);
    this.firefox = (agt.indexOf('firefox') != -1);
    if (this.gecko) {
    this.fltGeckoRevision = (agt.split(rxpGeckoRevision)[1]).replace(/rv:/, "");
    }   
    this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie4    = (
                   this.ie && (this.major ==  4) && 
                   (agt.indexOf("msie 5") == -1) && 
                   (agt.indexOf("msie 6") == -1) && 
                   (agt.indexOf("msie 7") == -1) && 
                   (agt.indexOf("msie 8") == -1)
                  ); // 10/9/2001 mod. TreeLogic SWE. -> update this after IE 8!.
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);

    /*-
     * Note: The AOL browser yields 'true' to the standard vendor i.d.'s
     * (this.ie, this.nav7, etc.).  A nice thing.
     */

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is.aol, is.aol3, and is.aol4 aren't 100% reliable.
    this.aol5up  = ( (agt.indexOf("aol 5") != -1) || (agt.indexOf("aol 6") != -1) );

    this.opera = (agt.indexOf("opera") != -1); 

    // *** PLATFORM ***
    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    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));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    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.winme = ((agt.indexOf("win 9x 4.90")!=-1));
    this.win2k = ((agt.indexOf("windows nt 5.0")!=-1));
    this.mac    = (agt.indexOf("mac")!=-1);
    this.linux = (agt.indexOf("inux")!=-1);
} //-Is

/*-
 * See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
 * http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
 * for detailed lists of userAgent strings.
 *
 * Note: you don't want your Nav4 or IE4 code to "turn off" or
 * stop working when later browser versions are released, so
 * in conditional code forks, use for example is.nav6up 
 * ("Nav6 or greater")
 * and is.ie6up ("IE6 or greater") instead of is.nav6 or is.ie6
 * to check version in code which you want to work on future
 * versions.
 */


