/*
----------- FundSys.net(TM) Copyright SySys(R) Corp 2002 ------------
====================================================================
  Created By: BH
  Last Edited By: BH
  Inception Date: 1/1/2002
  Last Edited Date: 1/1/2002
  Description:  None
  File Dependencies: None
===================================================================''*/

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "BD_is_" variables indicating:
// (1) browser vendor:
//     BD_is_nav, BD_is_ie, BD_is_opera
// (2) browser version number:
//     BD_is_major (integer indicating major version number: 2, 3, 4 ...)
//     BD_is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     BD_is_nav2, BD_is_nav3, BD_is_nav4, BD_is_nav4up, BD_is_nav5, BD_is_nav5up, BD_is_nav6, BD_is_nav6up, BD_is_ie3, BD_is_ie4, BD_is_ie4up
// (4) JavaScript version number:
//     BD_is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     BD_is_win, BD_is_win16, BD_is_win32, BD_is_win31, BD_is_win95, BD_is_winnt, BD_is_win98
//     BD_is_os2
//     BD_is_mac, BD_is_mac68k, BD_is_macppc
//     BD_is_unix
//        BD_is_sun, BD_is_sun4, BD_is_sun5, BD_is_suni86
//        BD_is_irix, BD_is_irix5, BD_is_irix6
//        BD_is_hpux, BD_is_hpux9, BD_is_hpux10
//        BD_is_aix, BD_is_aix1, BD_is_aix2, BD_is_aix3, BD_is_aix4
//        BD_is_linux, BD_is_sco, BD_is_unixware, BD_is_mpras, BD_is_reliant
//        BD_is_dec, BD_is_sinix, BD_is_freebsd, BD_is_bsd
//     BD_is_vms
//
// 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 Nav5 and IE5 (or later) are released, so
// in conditional code forks, use BD_is_nav4up ("Nav4 or greater")
// and BD_is_ie4up ("IE4 or greater") instead of BD_is_nav4 or BD_is_ie4
// to check version in code which you want to work on future
// versions.
//

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();
    var appVer = navigator.appVersion.toLowerCase();

    // *** BROWSER VERSION ***

    var BD_is_minor = parseFloat(appVer);
    var BD_is_major = parseInt(BD_is_minor);

    // 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

    var iePos  = appVer.indexOf('msie');
    if (iePos !=-1) {
       BD_is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
       BD_is_major = parseInt(BD_is_minor);
    }

    // Netscape6 is mozilla/5 + Netscape6/6.0!!!
    // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
    var nav6Pos = agt.indexOf('netscape6');
    if (nav6Pos !=-1) {
       BD_is_minor = parseFloat(agt.substring(nav6Pos+10))
       BD_is_major = parseInt(BD_is_minor)
    }

    var BD_is_getElementById   = (document.getElementById) ? "true" : "false"; // 001121-abk
    var BD_is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false"; // 001127-abk
    var BD_is_documentElement = (document.documentElement) ? "true" : "false"; // 001121-abk

    var BD_is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var BD_is_nav2 = (BD_is_nav && (BD_is_major == 2));
    var BD_is_nav3 = (BD_is_nav && (BD_is_major == 3));
    var BD_is_nav4 = (BD_is_nav && (BD_is_major == 4));
    var BD_is_nav4up = (BD_is_nav && BD_is_minor >= 4);  // changed to BD_is_minor for
                                                // consistency - dmr, 011001
    var BD_is_navonly      = (BD_is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );

	  var BD_is_nav6   = (BD_is_nav && BD_is_major==6);    // new 010118 mhp
	  var BD_is_nav6up = ((BD_is_nav && BD_is_minor >= 6)||(BD_is_nav && navigator.userAgent.indexOf("Netscape/7")>-1)); // new 010118 mhp

    var BD_is_nav5   = (BD_is_nav && BD_is_major == 5 && !BD_is_nav6); // checked for ns6
    var BD_is_nav5up = (BD_is_nav && BD_is_minor >= 5);

    var BD_is_ie   = (iePos!=-1);
    var BD_is_ie3  = (BD_is_ie && (BD_is_major < 4));

    var BD_is_ie4   = (BD_is_ie && BD_is_major == 4);
    var BD_is_ie4up = (BD_is_ie && BD_is_minor >= 4);
    var BD_is_ie5   = (BD_is_ie && BD_is_major == 5);
    var BD_is_ie5up = (BD_is_ie && BD_is_minor >= 5);

    var BD_is_ie6   = (BD_is_ie && BD_is_major == 6);
    var BD_is_ie6up = (BD_is_ie && BD_is_minor >= 6);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables BD_is_aol, BD_is_aol3, and BD_is_aol4 aren't 100% reliable.

    var BD_is_aol   = (agt.indexOf("aol") != -1);
    var BD_is_aol3  = (BD_is_aol && BD_is_ie3);
    var BD_is_aol4  = (BD_is_aol && BD_is_ie4);

    var BD_is_opera = (agt.indexOf("opera") != -1);
    var BD_is_webtv = (agt.indexOf("webtv") != -1);

    // *** JAVASCRIPT VERSION CHECK ***
    // Useful to workaround Nav3 bug in which Nav3
    // loads <SCRIPT LANGUAGE="JavaScript1.2">.
    var BD_is_js;
    if (BD_is_nav2 || BD_is_ie3) BD_is_js = 1.0
    else if (BD_is_nav3 || BD_is_opera) BD_is_js = 1.1
    else if ((BD_is_nav4 && (BD_is_minor <= 4.05)) || BD_is_ie4) BD_is_js = 1.2
    else if ((BD_is_nav4 && (BD_is_minor > 4.05)) || BD_is_ie5) BD_is_js = 1.3
    else if (BD_is_nav5 && !(BD_is_nav6)) BD_is_js = 1.4
    else if (BD_is_nav6) BD_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 (BD_is_nav && (BD_is_major > 5)) BD_is_js = 1.4
    else if (BD_is_ie && (BD_is_major > 5)) BD_is_js = 1.3
    // HACK: no idea for other browsers; always check for JS version with > or >=
    else BD_is_js = 0.0;

    // *** PLATFORM ***
    var BD_is_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.
    var BD_is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var BD_is_win16 = ((agt.indexOf("win16")!=-1) ||
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
               (agt.indexOf("windows 16-bit")!=-1) );

    var BD_is_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".
    var BD_is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var BD_is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var BD_is_win32 = (BD_is_win95 || BD_is_winnt || BD_is_win98 ||
                    ((BD_is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var BD_is_os2   = ((agt.indexOf("os/2")!=-1) ||
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var BD_is_mac    = (agt.indexOf("mac")!=-1);
    var BD_is_mac68k = (BD_is_mac && ((agt.indexOf("68k")!=-1) ||
                               (agt.indexOf("68000")!=-1)));
    var BD_is_macppc = (BD_is_mac && ((agt.indexOf("ppc")!=-1) ||
                                (agt.indexOf("powerpc")!=-1)));

    var BD_is_sun   = (agt.indexOf("sunos")!=-1);
    var BD_is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var BD_is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var BD_is_suni86= (BD_is_sun && (agt.indexOf("i86")!=-1));
    var BD_is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var BD_is_irix5 = (agt.indexOf("irix 5") !=-1);
    var BD_is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var BD_is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var BD_is_hpux9 = (BD_is_hpux && (agt.indexOf("09.")!=-1));
    var BD_is_hpux10= (BD_is_hpux && (agt.indexOf("10.")!=-1));
    var BD_is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var BD_is_aix1  = (agt.indexOf("aix 1") !=-1);
    var BD_is_aix2  = (agt.indexOf("aix 2") !=-1);
    var BD_is_aix3  = (agt.indexOf("aix 3") !=-1);
    var BD_is_aix4  = (agt.indexOf("aix 4") !=-1);
    var BD_is_linux = (agt.indexOf("inux")!=-1);
    var BD_is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var BD_is_unixware = (agt.indexOf("unix_system_v")!=-1);
    var BD_is_mpras    = (agt.indexOf("ncr")!=-1);
    var BD_is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var BD_is_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));
    var BD_is_sinix = (agt.indexOf("sinix")!=-1);
    var BD_is_freebsd = (agt.indexOf("freebsd")!=-1);
    var BD_is_bsd = (agt.indexOf("bsd")!=-1);
    var BD_is_unix  = ((agt.indexOf("x11")!=-1) || BD_is_sun || BD_is_irix || BD_is_hpux ||
                 BD_is_sco ||BD_is_unixware || BD_is_mpras || BD_is_reliant ||
                 BD_is_dec || BD_is_sinix || BD_is_aix || BD_is_linux || BD_is_bsd || BD_is_freebsd);

    var BD_is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
// additional checks, abk
	var BD_is_anchors = (document.anchors) ? "true":"false";
	var BD_is_regexp = (window.RegExp) ? "true":"false";
	var BD_is_option = (window.Option) ? "true":"false";
	var BD_is_all = (document.all) ? "true":"false";
// cookies - 990624 - abk
	document.cookie = "cookies=true";
	var BD_is_cookie = (document.cookie) ? "true" : "false";
	var BD_is_images = (document.images) ? "true":"false";
	var BD_is_layers = (document.layers) ? "true":"false"; // gecko m7 bug?
// new doc obj tests 990624-abk
	var BD_is_forms = (document.forms) ? "true" : "false";
	var BD_is_links = (document.links) ? "true" : "false";
	var BD_is_frames = (window.frames) ? "true" : "false";
	var BD_is_screen = (window.screen) ? "true" : "false";

// java
	var BD_is_java = (navigator.javaEnabled());



/*'''-------------------------
'' Global Variables:
------------------------------
     <script src=''></script>
     isNS4 (<script type="text/javascript">document.write(isNS4);</script>)


--------'''*/


/*'''-------------------------
'' writeDBInfo()
------------------------------
  Writes all Global Variable information(HTML formated ) in to a variable that is returned by the function.

--------'''*/
function writeBDInfo(){
  var outputText
  outputText = '';

  outputText += "<hr><h3>Browser Detect Information</h3><strong>Origoanl Location:</strong> http://www.webreference.com/tools/browser/javascript.html</p>";
  
 
  outputText += "<P>Note, Netscape 6 now supports the W3C standards -DOM1 and some of DOM2-, so it does not support the";
  outputText += "LAYER tag (and the popular document.layers test gives false) so ";
  outputText += "many old DHTML scripts that depend on this test to determine if the client is running Netscape ";
  outputText += "do not run. These scripts will have to be rewritten to use the DOM.  ";
  outputText += "You can use document.getElementById and BD_is_nav (see below for test and short example ";
  outputText += "code snippet) when testing for NS6+ and/or other DOM-compliant browsers.</P>";

  outputText += "<B>Navigator Object Data</B><br/>";
  outputText += "navigator.appCodeName: " + navigator.appCodeName + "<br/>";
  outputText += "navigator.appName: " + navigator.appName + "<br/>";
  outputText += "navigator.appVersion: " + navigator.appVersion + "<br/>";
  outputText += "navigator.userAgent: " + navigator.userAgent + "<br/>";
  outputText += "navigator.platform: " + navigator.platform + "<br/>";
  outputText += "navigator.javaEnabled(): " + BD_is_java + "<br/>";

  outputText += "<B>Version Number</B><br/>";
  outputText += "<TT>parseInt(navigator.appVersion) - major:" + BD_is_major + "</TT><br/>";
  outputText += "<TT>parseFloat(navigator.appVersion) - minor:" + BD_is_minor + "</TT><br/>";


  outputText += "<B>Browser Version</B><br/>";
  outputText += "<table borders=1 width=100%><tr><td valign=top>";
  outputText += "nav: " + BD_is_nav + "<br/>";
  outputText += "nav2: " + BD_is_nav2 + "<br/>";
  outputText += "nav3: " + BD_is_nav3 + "<br/>";
  outputText += "nav4: " + BD_is_nav4 + "<br/>";
  outputText += "nav4up: " + BD_is_nav4up + "<br/>";
  outputText += "nav5: " + BD_is_nav5 + "<br/>";
  outputText += "nav5up: " + BD_is_nav5up + "<br/>";
  outputText += "nav6: " + BD_is_nav6 + "<br/>";
  outputText += "nav6up: " + BD_is_nav6up;
  outputText += "</td><td valign=top>" ;
  outputText += "ie: " + BD_is_ie + "<br/>";
  outputText += "ie3: " + BD_is_ie3 + "<br/>";
  outputText += "ie4: " + BD_is_ie4 + "<br/>";
  outputText += "ie4up: " + BD_is_ie4up + "<br/>";
  outputText += "ie5: " + BD_is_ie5 + "<br/>";
  outputText += "ie5up: " + BD_is_ie5up + "<br/>";
  outputText += "ie6: " + BD_is_ie6 + "<br/>";
  outputText += "ie6up: " + BD_is_ie6up;
  outputText += "</td><td valign=top>" ;
  outputText += "aol: " + BD_is_aol + "<br/>";
  outputText += "aol3: " + BD_is_aol3 + "<br/>";
  outputText += "aol4: " + BD_is_aol4 + "<br/>";
  outputText += "opera: " + BD_is_opera + "<br/>";
  outputText += "webtv: " + BD_is_webtv + "<br/>";
  outputText += "</td></tr></table>" ;

  outputText += "<B>JavaScript Version</B><br/>";
  outputText += "js: " + BD_is_js + "<br/>";

    if(document.all) {
    	outputText += "<P>IE 4/5/6 Script Engines Installed: " + ScriptEngine() + "<br/>";
    	outputText += "Version: " + ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion() + "." + ScriptEngineBuildVersion() + "<br/>";
    }

  outputText += "<B>OS</B><br/>";
  outputText += "<table borders=1 width=100%><tr><td valign=top>";
  outputText += "win: " + BD_is_win + "<br/>";
  outputText += "os2: " + BD_is_os2 + "<br/>";
  outputText += "mac: " + BD_is_mac + "<br/>";
  outputText += "unix: " + BD_is_unix + "<br/>";
  outputText += "sun: " + BD_is_sun + "<br/>";
  outputText += "irix: " + BD_is_irix + "<br/>";
  outputText += "hpux: " + BD_is_hpux + "<br/>";
  outputText += "aix: " + BD_is_aix + "<br/>";
  outputText += "linux: " + BD_is_linux + "<br/>";
  outputText += "</td><td valign=top>" ;
  outputText += "sco: " + BD_is_sco + "<br/>";
  outputText += "unixware: " + BD_is_unixware + "<br/>";
  outputText += "mpras: " + BD_is_mpras + "<br/>";
  outputText += "reliant: " + BD_is_reliant + "<br/>";
  outputText += "dec: " + BD_is_dec + "<br/>";
  outputText += "sinix: " + BD_is_sinix + "<br/>";
  outputText += "bsd: " + BD_is_bsd + "<br/>";
  outputText += "freebsd: " + BD_is_freebsd + "<br/>";
  outputText += "vms: " + BD_is_vms + "<br/>";
  outputText += "</td></tr></table>" ;

  outputText += "<B>Object Detection Tests</B><br/>";
  outputText += "document.all: " + BD_is_all + "<br/>";
  outputText += "document.anchors: " + BD_is_anchors + "<br/>";
  outputText += "document.cookie: " + BD_is_cookie + "<br/>";
  outputText += "document.forms: " + BD_is_forms + "<br/>";
  outputText += "document.getElementById: " + BD_is_getElementById + "<br/>";
  outputText += "document.getElementsByTagName: " + BD_is_getElementsByTagName + "<br/>";
  outputText += "document.documentElement: " + BD_is_documentElement + "<br/>";
  outputText += "document.images: " + BD_is_images + "<br/>";
  outputText += "document.layers: " + BD_is_layers + " - NS6 gives false here*" + "<br/>";
  outputText += "document.links: " + BD_is_links + "<br/><br/>";
  outputText += "window.frames: " + BD_is_frames + "<br/>";
  outputText += "window.length: " + window.length +"<br/>";


  outputText += "<B>Method Detection Tests</B><br/>";
  outputText += "window.RegExp: " + BD_is_regexp + "<br/>";
  outputText += "window.Option: " + BD_is_option + "<br/>";

  outputText += "<B>Screen Properties</B><br/>";
  outputText += "window.screen: " + BD_is_screen + "<br/>";
    if (window.screen) {
    outputText += 'screen.height: ' + screen.height + "<br/>";
    outputText += 'screen.width: ' + screen.width + "<br/>";
    outputText += 'screen.availHeight: ' + screen.availHeight + "<br/>";
    outputText += 'screen.availWidth: ' + screen.availWidth + "<br/>";
    outputText += 'screen.colorDepth: ' + screen.colorDepth + "<br/>";
    }
    if (window.screen) {
    	outputText += "fontSmoothingEnabled: " + screen.fontSmoothingEnabled + "<br/>";
    }

  outputText += "<B>Document Properties</B><br/>";
  outputText += 'document.URL: ' + document.URL + "<br/>";

  outputText += "<H3>NS6+ Addendum</H3><br/>";

  outputText += "<P>*<EM>Note</EM>: Old DHTML scripts can fail in NS6 and above with the document.layers test, as NS6 does not support layers, ";
  outputText += "but the W3C's standard DOM. Gecko m7 does not support the document.layers test. Use document.getElementById instead ";
  outputText += "(note: ie5+ supports document.getElementById, so you'll need to allow for this in your code). Note also that Netscape ";
  outputText += "6 supports IE's innerHTML property for convenience, but it is not in the W3C DOM. So to make your DHTML scripts work in DOM-compliant browsers use DIVs, example:";
  outputText += "<br/><br/>";
  outputText += "<PRE><br/>";
  outputText += "&lt;div id='MYDIV' style='position:absolute; left:200; top:100; visibility:hidden;'&gt;<br/>";
  outputText += "myElement = document.getElementById('MYDIV');<br/>";
  outputText += "myElement.style.visibility = 'visible';<br/>";
  outputText += "myElement.style.left = x + 'px'; // note ie uses pixelLeft, NS4 uses moveTo(x,y)<br/>";
  outputText += "myElement.style.top  = y + 'px'; // note ie uses pixelTop<br/>";
  outputText += "myElement.style.innerHTML = newcontent; // not in W3C dom but in NS6+<br/>";
  outputText += "<br/><br/>";
  outputText += "Example browser branching logic:<br/>";
  outputText += "<br/><br/>";
  outputText += "if (document.all) { // note, this code would also run in IE5+, which has partial support<br/>";
  outputText += "  IE4+ code         // for the W3C DOM. You could also add check for !DOM <br/>";
  outputText += "                    // here (&& !(document.getElementById)) and equate dissimilar IE/W3C<br/>";
  outputText += "                    // DOMs with prototype function, and run all IE5+/NS6+ browsers with<br/>";
  outputText += "                    // only DOM-standards-compliant code. IE5+ browsers would then drop <br/>";
  outputText += "                    // down to third elseif below. <br/>";
  outputText += "} else if (document.layers) {<br/>";
  outputText += "  NS4+ code <br/>";
  outputText += "} else if (document.getElementById) {<br/>";
  outputText += "  NS6+ code         // and IE5+ code you flatten differences between MS DOM and W3C DOM<br/>";
  outputText += "} <br/>";
  outputText += "<br/><br/><br/><br/>";
  outputText += "</PRE><hr>";
 return outputText;
}//end writeBDInfo


