// client-side JavaScript client sniffer. Version 3.05
// Revised 02 Oct 01 to add IE6 detection
// Revised 04 Sep 02 to add NS7 detection
// Revised 23 Sep 04 to correct JavaScript version detection
// Revised 07 Feb 08 to add several new browsers
function browserType()
{
  var bType = "";

  if (is.nav)
	bType = "Netscape";
  else if (is.ie)
	bType = "Internet Explorer";
  else if (is.opera)
	bType = "Opera";
  else if (is.hotjava)
  	bType = "HotJava";
  else if (is.webtv)
  	bType = "WebTV";
  else if (is.TVNavigator)
  	bType = "TV Navigator";
  else if (is.aol)
		bType = "AOL";
  else if (is.konq)
        bType = "Konqueror";
  else if (is.safari)
        bType = "Safari";
  else if (is.moz)
        bType = "Mozilla";
  else if (is.fx)
        bType = "Firefox";
  else if (is.fb)
        bType = "Firebird";
	else if (is.safari)
	      bType = "Safari";
  else
  	bType = "Unknown";
  	
	if (is.mac)
	  bType = bType + " [MAC]";

  if (is.gecko)
  	bType =  bType + " (Netscape Gecko Engine version " + is.gver + ")";

  return(bType);
}


function Is ()
{
    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***

    this.minor = parseFloat(appVer);
    this.major = parseInt(this.minor);

	this.chrome = (agt.indexOf("chrome") != -1); // 01-16-2009 LWP

    this.opera = (agt.indexOf("opera") != -1);
    this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    this.opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); // 020128- abk
    this.opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1); // 021205- dmr
    this.opera8 = (agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1); // 09-19-2006 jonw
    this.opera9 = (agt.indexOf("opera 9") != -1 || agt.indexOf("opera/9") != -1); // 09-19-2006 jonw

    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
    this.opera6up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4 && !this.opera5); // new020128
    this.opera7up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4 && !this.opera5 && !this.opera6); // new021205 -- dmr
    this.opera8up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4 && !this.opera5 && !this.opera6 && !this.opera7); // 09-19-2006 - jonw
    this.opera9up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4 && !this.opera5 && !this.opera6 && !this.opera7 &&!this.opera8); // 09-19-2006 - jonw

    // Note: On IE, start of 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
    // And on Mac IE5+, we look for is.minor in the ua; since
    // it appears to be more accurate than appVersion

    this.mac = (agt.indexOf("mac")!=-1);
    var iePos  = appVer.indexOf('msie');
    // fix this to correctly find the IE version on the Mac -- jmv 02072008
    if (iePos !=-1)
		{
       if(this.mac)
			 {
           iePos = agt.indexOf('msie');
           this.minor = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
       }
       else
			 	this.minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));

       this.major = parseInt(this.minor);
    }

    // ditto Konqueror

    this.konq = false;
    var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1)
		{
       this.konq  = true;
       this.minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
       this.major = parseInt(this.minor);
    }

    this.getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    this.getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    this.documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    this.safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
    this.khtml  = (this.safari || this.konq);

    this.gecko = ((!this.khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
    this.gver  = 0;
    if (this.gecko) this.gver=navigator.productSub;

    this.fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                 (this.gecko) && (navigator.vendor=="Firebird"));
    this.fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                 (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                 (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                 (this.gecko) && ((navigator.vendor=="Firefox")||(agt.indexOf('firefox')!=-1)));
    this.moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                    (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                    (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                    (this.gecko) && (!this.fb) && (!this.fx) &&
                    ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
    if ((this.moz)||(this.fb)||(this.fx))
    {
       this.moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
       if(this.fx &&! this.moz_ver)
			 {
           this.moz_ver = agt.indexOf('firefox/');
           this.moz_ver = agt.substring(this.moz_ver+8);
//           this.moz_ver = parseFloat(this.moz_ver);
       }
       if(!(this.moz_ver))
			 {
           this.moz_ver = agt.indexOf('rv:');
           this.moz_ver = agt.substring(this.moz_ver+3);
           this.paren   = this.moz_ver.indexOf(')');
           this.moz_ver = this.moz_ver.substring(0,this.paren);
       }

       this.minor = this.moz_ver;
       this.major = parseInt(this.moz_ver);
    }

   	this.fb_ver = this.moz_ver;
   	this.fx_ver = this.moz_ver;

    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.khtml) && (!(this.moz)) && (!this.fb) && (!this.fx));

    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    // Changed this to use navigator.vendor/vendorSub - dmr 060502
    // var nav6Pos = agt.indexOf('netscape6');
    // if (nav6Pos !=-1) {
    if ((navigator.vendor)&& ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&& (this.nav))
		{
       this.major = parseInt(navigator.vendorSub);
       // here we need this.minor as a valid float for testing. We'll
       // revert to the actual content before printing the result.
       this.minor = parseFloat(navigator.vendorSub);
    }

    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.minor >= 4);  // changed to this.minor for
                                                // consistency - dmr, 011001
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

    this.nav6   = (this.nav && this.major==6);    // new 010118 mhp
    this.nav6up = (this.nav && this.minor >= 6) // new 010118 mhp

    this.nav5   = (this.nav && this.major == 5 && !this.nav6); // checked for ns6
    this.nav5up = (this.nav && this.minor >= 5);

    this.nav7   = (this.nav && this.major == 7);
    this.nav7up = (this.nav && this.minor >= 7);

    this.nav8   = (this.nav && this.major == 8);
    this.nav8up = (this.nav && this.minor >= 8);

    this.ie   = ((iePos!=-1) && (!this.opera) && (!this.khtml));
    this.ie3  = (this.ie && (this.major < 4));

    this.ie4   = (this.ie && this.major == 4);
    this.ie4up = (this.ie && this.minor >= 4);
    this.ie5   = (this.ie && this.major == 5);
    this.ie5up = (this.ie && this.minor >= 5);

    this.ie5_5  = (this.ie && (agt.indexOf("msie 5.5") !=-1)); // 020128 new - abk
    this.ie5_5up =(this.ie && this.minor >= 5.5);                // 020128 new - abk

    this.ie6   = (this.ie && this.major == 6);
    this.ie6up = (this.ie && this.minor >= 6);

    this.ie7   = (this.ie && this.major == 7);
    this.ie7up = (this.ie && this.minor >= 7);

		// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables this.aol, this.aol3, and this.aol4 aren't 100% reliable.

    this.aol   = (agt.indexOf("aol") != -1);
    this.aol3  = (this.aol && this.ie3);
    this.aol4  = (this.aol && this.ie4);
    this.aol5  = (agt.indexOf("aol 5") != -1);
    this.aol6  = (agt.indexOf("aol 6") != -1);
    this.aol7  = ((agt.indexOf("aol 7")!=-1) || (agt.indexOf("aol7")!=-1));
    this.aol8  = ((agt.indexOf("aol 8")!=-1) || (agt.indexOf("aol8")!=-1));

    this.webtv = (agt.indexOf("webtv") != -1);

    this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
    this.AOLTV = this.TVNavigator;

    this.hotjava = (agt.indexOf("hotjava") != -1);
    this.hotjava3 = (this.hotjava && (this.major == 3));
    this.hotjava3up = (this.hotjava && (this.major >= 3));

    // *** JAVASCRIPT VERSION CHECK ***
    // Useful to workaround Nav3 bug in which Nav3
    // loads <SCRIPT LANGUAGE="JavaScript1.2">.
    // updated 020131 by dragle
    this.js;
    if (this.nav2 || this.ie3)
			this.js = 1.0;
    else if (this.nav3)
			this.js = 1.1;
    else if ((this.opera5)||(this.opera6))
			this.js = 1.3; // 020214 - dmr
    else if (this.opera7up)
			this.js = 1.5; // 031010 - dmr
    else if (this.khtml)
			this.js = 1.5;   // 030110 - dmr
    else if (this.opera)
			this.js = 1.1;
    else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4)
			this.js = 1.2;
    else if ((this.nav4 && (this.minor > 4.05)) || this.ie5)
			this.js = 1.3;
    else if (this.nav5 && !(this.nav6))
			this.js = 1.4;
    else if (this.hotjava3up)
			this.js = 1.4; // new 020128 - abk
    else if (this.nav6up)
			this.js = 1.5;
    else if (this.ie)
    {
        // get the script engine version and base JS version on that
        var jsmaj = ScriptEngineMajorVersion();
        var jsmin = ScriptEngineMinorVersion();
        
				this.jscript = jsmaj + '.' + jsmin + '.' + ScriptEngineBuildVersion();

				if (jsmaj == 1)
          this.js = 1.0;
        else if (jsmaj == 2)
          this.js = 1.1;
        else if (jsmaj == 3)
          this.js = 1.3;
        else if (jsmaj == 4)
          this.js = 0.0;        // never released to browsers
        else if ((jsmaj == 5) && (jsmin >= 5))
          this.js = 1.5;
        else if (jsmaj == 5)
          this.js = 1.3;
        else
          this.js = 1.3;
    }
    else if (this.moz)
			this.js = 1.5;
    else if (this.fb||this.fx)
			this.js = 1.5; // 032504 - dmr
    else
			this.js = 1.5;  // 02072008 jmv -- any modern browser will be 1.5 or better, so assume that
			
	if (this.chrome)
		this.js = 1.5; // 01-16-2009 LWP
			
    // HACK FOR IE5 MAC = js vers = 1.4 (if put inside if/else jumps out at 1.3)
    if ((agt.indexOf("mac")!=-1) && this.ie5up)
			this.js = 1.4; // 020128 - abk

    // check for existance of the encodeURI() and decodeURI() functions.  If
    // they are present, it is probably JS 1.5 -- 23sep04 jmv
    if ((typeof(encodeURIComponent) == "function") && (typeof(decodeURIComponent) == "function"))
        this.js = 1.5;

    // Done with this.minor testing; revert to real for N6/7
    if (this.nav6up)
		{
       this.minor = navigator.vendorSub;
    }

    // *** 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));

		this.winme = ((agt.indexOf("win 9x 4.90")!=-1));    // new 020128 - abk
    this.win2k = ((agt.indexOf("windows nt 5.0")!=-1) || (agt.indexOf("windows 2000")!=-1)); // 020214 - dmr
    this.winxp = ((agt.indexOf("windows nt 5.1")!=-1) || (agt.indexOf("windows xp")!=-1)); // 020214 - dmr

    // 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.os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    this.mac    = (agt.indexOf("mac")!=-1);
    if (this.mac)
		{
			this.win = !this.mac;
		} // dmr - 06/20/2002
		
    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.sun   = (agt.indexOf("sunos")!=-1);
    this.sun4  = (agt.indexOf("sunos 4")!=-1);
    this.sun5  = (agt.indexOf("sunos 5")!=-1);
    this.suni86= (this.sun && (agt.indexOf("i86")!=-1));
    this.irix  = (agt.indexOf("irix") !=-1);    // SGI
    this.irix5 = (agt.indexOf("irix 5") !=-1);
    this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    this.hpux  = (agt.indexOf("hp-ux")!=-1);
    this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
    this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1));
    this.aix   = (agt.indexOf("aix") !=-1);      // IBM
    this.aix1  = (agt.indexOf("aix 1") !=-1);
    this.aix2  = (agt.indexOf("aix 2") !=-1);
    this.aix3  = (agt.indexOf("aix 3") !=-1);
    this.aix4  = (agt.indexOf("aix 4") !=-1);
    this.linux = (agt.indexOf("inux")!=-1);
    this.sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    this.unixware = (agt.indexOf("unix_system_v")!=-1);
    this.mpras    = (agt.indexOf("ncr")!=-1);
    this.reliant  = (agt.indexOf("reliantunix")!=-1);
    this.dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
    this.sinix = (agt.indexOf("sinix")!=-1);
    this.freebsd = (agt.indexOf("freebsd")!=-1);
    this.bsd = (agt.indexOf("bsd")!=-1);
    this.unix  = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux ||
                 this.sco ||this.unixware || this.mpras || this.reliant ||
                 this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);

    this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));

		if (this.nav4)
		{
			this.anchors = true;
			this.regexp = true;
			this.option = true;
			this.all = false;
			this.cookie = true;
			this.images = true;
			this.layers = true;
			this.forms = true;
			this.links = false;
			this.frames = true;
			this.screen = false;
		}
		else
		{
			// additional checks, abk
			this.anchors = (document.anchors) ? "true":"false";
			this.regexp = (window.RegExp) ? "true":"false";
			this.option = (window.Option) ? "true":"false";
			this.all = (document.all) ? "true":"false";
			// cookies - 990624 - abk
			document.cookie = "cookies=true";
			this.cookie = (document.cookie) ? "true" : "false";
			this.images = (document.images) ? "true":"false";
			this.layers = (document.layers) ? "true":"false"; // gecko m7 bug?
			// new doc obj tests 990624-abk
			this.forms = (document.forms) ? "true" : "false";
			this.links = (document.links) ? "true" : "false";
			this.frames = (window.frames) ? "true" : "false";
			this.screen = (window.screen) ? "true" : "false";
		}

		// java
		this.java = (navigator.javaEnabled());

		// Flash checking code adapted from Doc JavaScript information;
		// see http://webref.com/js/column84/2.html

   this.Flash        = false;
   this.FlashVersion = 0;

   if ((this.nav||this.opera||this.moz||this.fb||this.fx||this.safari)|| (this.mac&&this.ie5up))
	 {
      var plugin = (navigator.mimeTypes &&
                    navigator.mimeTypes["application/x-shockwave-flash"] &&
                    navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) ?
                    navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
      if (plugin && plugin.description)
			{
         this.Flash = true;
         this.FlashVersion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
      }
   }
} // end function Is()

var is;
var ieFver;
var ieFbool;
var isIE3Mac = false;
// this section is designed specifically for IE3 for the Mac

if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) && (parseInt(navigator.appVersion)==3))
	isIE3Mac = true;
else
	is = new Is();

if (is.win && is.ie4up)
{
	document.write(
	'<scr' + 'ipt language=VBScript>' + '\n' +
	'Dim hasPlayer, playerversion' + '\n' +
	'hasPlayer = false' + '\n' +
	'playerversion = 12' + '\n' +
	'Do While playerversion > 0' + '\n' +
	'On Error Resume Next' + '\n' +
	'hasPlayer = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & playerversion)))' + '\n' +
	'If hasPlayer = true Then Exit Do' + '\n' +
	'playerversion = playerversion - 1' + '\n' +
	'Loop' + '\n' +
	'ieFver = playerversion' + '\n' +
	'ieFbool = hasPlayer' + '\n' +
	'<\/sc' + 'ript>'
	);
        is.FlashVersion = ieFver;
        is.Flash = ieFbool;
}
