// <comment>
// ****************************************************************
// Purpose: Checks browser, OS, etc. 
// Source: http://www.webreference.com/tools/browser/javascript.html
// Assumptions: None
// Developer: Eric Krok, Andy King, Michel Plungjan, Ewen Cartwright DE-HILDEN
// Input: None
// Output: None
// Last update: 18. Sep. 2001, Ewen Cartwright DE-HILDEN
// ****************************************************************
// (Just added an object wrapper -- otherwise the code remains the same)
// </comment>

function BrowserTyper()
{
    // convert all characters to lowercase to simplify testing
    this.agt=navigator.userAgent.toLowerCase();
    this.appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***

    this.is_minor = parseFloat(this.appVer);
    this.is_major = parseInt(this.is_minor);

    // Note: On IE, start of this.appVersion return 3 or 4
    // which supposedly is the version of Netscape it is compatible with.
    // So we look for the real version further on in the string

    this.iePos  = this.appVer.indexOf('msie');
    if (this.iePos !=-1) {
       this.is_minor = parseFloat(this.appVer.substring(this.iePos+5,this.appVer.indexOf(';',this.iePos)))
       this.is_major = parseInt(this.is_minor);
    }

    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    this.nav6Pos = this.agt.indexOf('netscape6');
    if (this.nav6Pos !=-1) {
       this.is_minor = parseFloat(this.agt.substring(this.nav6Pos+10))
       this.is_major = parseInt(this.is_minor)
    }

    this.is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    this.is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    this.is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    this.is_nav  = ((this.agt.indexOf('mozilla')!=-1) && (this.agt.indexOf('spoofer')==-1)
                && (this.agt.indexOf('compatible') == -1) && (this.agt.indexOf('opera')==-1)
                && (this.agt.indexOf('webtv')==-1));
    this.is_nav2 = (this.is_nav && (this.is_major == 2));
    this.is_nav3 = (this.is_nav && (this.is_major == 3));
    this.is_nav4 = (this.is_nav && (this.is_major == 4));
    this.is_nav4up = (this.is_nav && (this.is_major >= 4));
    this.is_navonly      = (this.is_nav && ((this.agt.indexOf(";nav") != -1) ||
                          (this.agt.indexOf("; nav") != -1)) );

/*	this.is_nav6 = (this.is_nav && (this.agt.indexOf('netscape6') != -1)); // new 001120 - abk
	this.is_nav6up = (this.is_nav && this.is_getElementById);              // new 001121 - abk
*/
	this.is_nav6   = (this.is_nav && this.is_major==6);    // new 010118 mhp
	this.is_nav6up = (this.is_nav && this.is_minor >= 6) // new 010118 mhp

    this.is_nav5   = (this.is_nav && this.is_major == 5 && !this.is_nav6); // checked for ns6
    this.is_nav5up = (this.is_nav && this.is_minor >= 5);

    this.is_ie   = (this.iePos!=-1);
    this.is_ie3  = (this.is_ie && (this.is_major < 4));

    this.is_ie4   = (this.is_ie && this.is_major == 4);
    this.is_ie4up = (this.is_ie && this.is_minor >= 4);
    this.is_ie5   = (this.is_ie && this.is_major == 5);
    this.is_ie5up = (this.is_ie && this.is_minor >= 5);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables this.is_aol, this.is_aol3, and this.is_aol4 aren't 100% reliable.

    this.is_aol  = (this.agt.indexOf("aol") != -1);
    this.is_aol3  = (this.is_aol && this.is_ie3);
    this.is_aol4  = (this.is_aol && this.is_ie4);

    this.is_opera = (this.agt.indexOf("opera") != -1);
    this.is_webtv = (this.agt.indexOf("webtv") != -1);

    // *** JAVASCRIPT VERSION CHECK ***
    // Useful to workaround Nav3 bug in which Nav3
    // loads <SCRIPT LANGUAGE="JavaScript1.2">.
    this.is_js;
    if (this.is_nav2 || this.is_ie3) this.is_js = 1.0
    else if (this.is_nav3 || this.is_opera) this.is_js = 1.1
    else if ((this.is_nav4 && (this.is_minor <= 4.05)) || this.is_ie4) this.is_js = 1.2
    else if ((this.is_nav4 && (this.is_minor > 4.05)) || this.is_ie5) this.is_js = 1.3
    else if (this.is_nav5 && !(this.is_nav6)) this.is_js = 1.4
    else if (this.is_nav6) this.is_js = 1.5

    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.

    else if (this.is_nav && (this.is_major > 5)) this.is_js = 1.4
    else if (this.is_ie && (this.is_major > 5)) this.is_js = 1.3
    // HACK: no idea for other browsers; always check for JS version with > or >=
    else this.is_js = 0.0;

    // *** PLATFORM ***
    this.is_win   = ( (this.agt.indexOf("win")!=-1) || (this.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.is_win95 = ((this.agt.indexOf("win95")!=-1) || (this.agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    this.is_win16 = ((this.agt.indexOf("win16")!=-1) ||
               (this.agt.indexOf("16bit")!=-1) || (this.agt.indexOf("windows 3.1")!=-1) ||
               (this.agt.indexOf("windows 16-bit")!=-1) );

    this.is_win31 = ((this.agt.indexOf("windows 3.1")!=-1) || (this.agt.indexOf("win16")!=-1) ||
                    (this.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.is_win98 = ((this.agt.indexOf("win98")!=-1) || (this.agt.indexOf("windows 98")!=-1));
    this.is_winnt = ((this.agt.indexOf("winnt")!=-1) || (this.agt.indexOf("windows nt")!=-1));
    this.is_win32 = (this.is_win95 || this.is_winnt || this.is_win98 ||
                    ((this.is_major >= 4) && (navigator.platform == "Win32")) ||
                    (this.agt.indexOf("win32")!=-1) || (this.agt.indexOf("32bit")!=-1));

    this.is_os2   = ((this.agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (this.agt.indexOf("ibm-webexplorer")!=-1));

    this.is_mac    = (this.agt.indexOf("mac")!=-1);
    this.is_mac68k = (this.is_mac && ((this.agt.indexOf("68k")!=-1) ||
                               (this.agt.indexOf("68000")!=-1)));
    this.is_macppc = (this.is_mac && ((this.agt.indexOf("ppc")!=-1) ||
                                (this.agt.indexOf("powerpc")!=-1)));

    this.is_sun   = (this.agt.indexOf("sunos")!=-1);
    this.is_sun4  = (this.agt.indexOf("sunos 4")!=-1);
    this.is_sun5  = (this.agt.indexOf("sunos 5")!=-1);
    this.is_suni86= (this.is_sun && (this.agt.indexOf("i86")!=-1));
    this.is_irix  = (this.agt.indexOf("irix") !=-1);    // SGI
    this.is_irix5 = (this.agt.indexOf("irix 5") !=-1);
    this.is_irix6 = ((this.agt.indexOf("irix 6") !=-1) || (this.agt.indexOf("irix6") !=-1));
    this.is_hpux  = (this.agt.indexOf("hp-ux")!=-1);
    this.is_hpux9 = (this.is_hpux && (this.agt.indexOf("09.")!=-1));
    this.is_hpux10= (this.is_hpux && (this.agt.indexOf("10.")!=-1));
    this.is_aix   = (this.agt.indexOf("aix") !=-1);      // IBM
    this.is_aix1  = (this.agt.indexOf("aix 1") !=-1);
    this.is_aix2  = (this.agt.indexOf("aix 2") !=-1);
    this.is_aix3  = (this.agt.indexOf("aix 3") !=-1);
    this.is_aix4  = (this.agt.indexOf("aix 4") !=-1);
    this.is_linux = (this.agt.indexOf("inux")!=-1);
    this.is_sco   = (this.agt.indexOf("sco")!=-1) || (this.agt.indexOf("unix_sv")!=-1);
    this.is_unixware = (this.agt.indexOf("unix_system_v")!=-1);
    this.is_mpras    = (this.agt.indexOf("ncr")!=-1);
    this.is_reliant  = (this.agt.indexOf("reliantunix")!=-1);
    this.is_dec   = ((this.agt.indexOf("dec")!=-1) || (this.agt.indexOf("osf1")!=-1) ||
           (this.agt.indexOf("dec_alpha")!=-1) || (this.agt.indexOf("alphaserver")!=-1) ||
           (this.agt.indexOf("ultrix")!=-1) || (this.agt.indexOf("alphastation")!=-1));
    this.is_sinix = (this.agt.indexOf("sinix")!=-1);
    this.is_freebsd = (this.agt.indexOf("freebsd")!=-1);
    this.is_bsd = (this.agt.indexOf("bsd")!=-1);
    this.is_unix  = ((this.agt.indexOf("x11")!=-1) || this.is_sun || this.is_irix || this.is_hpux ||
                 this.is_sco ||this.is_unixware || this.is_mpras || this.is_reliant ||
                 this.is_dec || this.is_sinix || this.is_aix || this.is_linux || this.is_bsd || this.is_freebsd);

    this.is_vms   = ((this.agt.indexOf("vax")!=-1) || (this.agt.indexOf("openvms")!=-1));
// additional checks, abk
	this.is_anchors = (document.anchors) ? "true":"false";
	this.is_regexp = (window.RegExp) ? "true":"false";
	this.is_option = (window.Option) ? "true":"false";
	this.is_all = (document.all) ? "true":"false";
// cookies - 990624 - abk
	document.cookie = "cookies=true";
	this.is_cookie = (document.cookie) ? "true" : "false";
	this.is_images = (document.images) ? "true":"false";
	this.is_layers = (document.layers) ? "true":"false"; // gecko m7 bug?
// new doc obj tests 990624-abk
	this.is_forms = (document.forms) ? "true" : "false";
	this.is_links = (document.links) ? "true" : "false";
	this.is_frames = (window.frames) ? "true" : "false";
	this.is_screen = (window.screen) ? "true" : "false";

// java
	this.is_java = (navigator.javaEnabled());
}
