// JavaScript for res_browser.htm - Copyright (C) 1998-2011 Charles A Upsdell, All Rights Reserved; www.upsdell.com


// This is called by the onload event
function myResBrowserPage ( )
{
myBrowserInfo.resBrowser_Browser( 'ins_browser' );
if ( typeof(conditionalCommentsVersion) != 'undefined' )
  {
	o_cc = getElement( 'ins_cc' );
	if ( o_cc )
	  {
		o_cc.innerHTML = '<p>Conditional comments indicate that this is Internet Explorer ' + conditionalCommentsVersion + '</p>\n';
	  }
  }
myBrowserInfo.resBrowser_Options( 'ins_options' );
myBrowserInfo.resBrowser_PCdetails( 'ins_pcdetails' );
myBrowserInfo.resBrowser_Plugins( 'ins_plugins' );
}


// This inserts info identifying the browser
cBrowserInfo.prototype.resBrowser_Browser = function ( id )
{
var o = getElement( id );
if ( o == null )
	return;
var sHTML = '<table class="grid3d tdtop indent small">\n<thead>\n<tr><th class="left">Property</th><th class="left">Value</th></tr>\n</thead>\n<tbody>\n';
sHTML += '<tr class="h"><td>navigator.userAgent</td><td>' + this.nav_ua + '</td></tr>\n';
sHTML += '<tr class="h"><td>navigator.appName</td><td>' + navigator.appName + '</td></tr>\n';
sHTML += '<tr class="h"><td>navigator.appCodeName</td><td>' + navigator.appCodeName + '</td></tr>\n';
sHTML += '<tr class="h"><td>navigator.appVersion</td><td>' + this.nav_version + '</td></tr>\n';
sHTML += '</tbody>\n</table>\n';
sHTML += '<p>This author&rsquo;s browser sniffer thinks your browser is:</p>\n';
var verBrowser = '';
if ( this.verBrowser.comp('0') != 0 )
	verBrowser = this.verBrowser.toString();
sHTML += '<p class="indent">' + this.browser + ' ' + verBrowser + '</p>\n';
if ( this.engine )
  {
	var verEngine = '';
	if ( this.verEngine.comp('0') != 0 )
		verEngine = this.verEngine.toString();
	sHTML += '<p>Moreover, it would appear that your browser uses this browser engine:</p>\n';
	sHTML += '<p class="indent">' + this.engine + ' ' + verEngine + '</p>\n';
  }
o.innerHTML = sHTML;
}


// This inserts info about the browser options
cBrowserInfo.prototype.resBrowser_Options = function ( id )
{
var o = getElement( id );
if ( o == null )
	return;
var sHTML = '<table class="grid3d tdtop indent small">\n<thead>\n<tr><th class="left">Property</th><th class="left">Value</th></tr>\n</thead>\n<tbody>\n';
sHTML += '<tr class="h"><td>navigator.cookieEnabled</td><td>' + this.nav_cookies + '</td></tr>\n';
sHTML += '<tr class="h"><td>navigator.javaEnabled()</td><td>' + navigator.javaEnabled() + '</td></tr>\n';
sHTML += '</tbody>\n</table>\n';
o.innerHTML = sHTML;
}


// This inserts info about the browser's PC
cBrowserInfo.prototype.resBrowser_PCdetails = function ( id )
{
var o = getElement( id );
if ( o == null )
	return;
this.resBrowser_PCgeometry();
var sHTML = '<table class="grid3d tdtop indent small">\n<thead>\n<tr><th class="left">Information</th><th class="left">Value</th></tr>\n</thead>\n<tbody>\n';
sHTML += '<tr class="h"><td>Display resolution</td><td>' + window.screen.width + ' x ' + window.screen.height + '</td></tr>\n';
sHTML += '<tr class="h"><td>Colour depth</td><td>' + Math.pow(2,window.screen.colorDepth) + ' (2<sup>' + window.screen.colorDepth + '<\/sup>)</td></tr>\n';
sHTML += '<tr class="h"><td>Platform</td><td>' + this.resBrowser_PCplatform() + '</td></tr>\n';

if ( this.outerWidth != null )
	sHTML += '<tr class="h"><td>Browser window size</td><td>' + this.outerWidth + ' x ' + this.outerHeight + '</td></tr>\n';
if ( this.getWindowX != null )
	sHTML += '<tr class="h"><td>Browser window position</td><td>' + this.getWindowX() + ', ' + this.getWindowY() + '</td></tr>\n';
if ( this.getViewportWidth != null )
	sHTML += '<tr class="h"><td>Browser canvas size</td><td>' + this.getViewportWidth() + ' x ' + this.getViewportHeight() + '</td></tr>\n';

sHTML += '</tbody>\n</table>\n';
o.innerHTML = sHTML;
}


// This gets the name of the browser's platform
cBrowserInfo.prototype.resBrowser_PCplatform = function ()
{
var platform = this.nav_platform;
if ( this.osMac )
	platform = 'Macintosh';
else if ( this.UA.indexOf('windows ce') != -1 )
	platform = 'Windows CE';
else if ( (this.UA.indexOf('windows 95') != -1) || (this.UA.indexOf('win95') != -1) )
	platform = 'Windows 95';
else if ( this.UA.indexOf('windows 98; win 9x 4.90') != -1 )
	platform = 'Windows ME';
else if ( (this.UA.indexOf('windows 98') != -1) || (this.UA.indexOf('win98') != -1) )
	platform = 'Windows 98';
else if ( this.UA.indexOf('winnt3.5') != -1 )
	platform = 'Windows NT 3';
else if ( (this.UA.indexOf('windows nt 4') != -1) || (this.UA.indexOf('winnt4') != -1) )
	platform = 'Windows NT 4';
else if ( this.UA.indexOf('windows nt 5.0') != -1 )
	platform = 'Windows 2000';
else if ( this.UA.indexOf('windows nt 5.1') != -1 )
	platform = 'Windows XP';
else if ( this.UA.indexOf('windows nt 5.2') != -1 )
	platform = 'Windows Server 2003 or Windows XP x64';
else if ( this.UA.indexOf('windows nt 6.0') != -1 )
	platform = 'Windows Vista';
return( platform );
}

cBrowserInfo.prototype.resBrowser_PCgeometry = function ()
{
if ( window.outerWidth )
  {
	this.outerWidth = window.outerWidth;
	this.outerHeight = window.outerHeight;
  }
else
  {
	this.outerWidth = null;
	this.outerHeight = null;
  }

if ( (this.engine == 'Internet Explorer') && typeof(window.screenLeft) != 'undefined' )
  {
	if ( window.screenLeft )
	  {	// IE and others
    	this.getWindowX = function() { return window.screenLeft; };
    	this.getWindowY = function() { return window.screenTop; };
	  }
  }
else if ( typeof(window.screenX) != 'undefined' )
  {
	if ( window.screenX )
	  {	// Firefox and others
    	this.getWindowX = function() { return window.screenX; };
    	this.getWindowY = function() { return window.screenY; };
	  }
  }
else
  {
    this.getWindowX = null;
    this.getWindowY = null;
  }

if (window.innerWidth)
  { // All browsers but IE
    this.getViewportWidth = function() { return window.innerWidth; };
    this.getViewportHeight = function() { return window.innerHeight; };
    this.getHorizontalScroll = function() { return window.pageXOffset; };
    this.getVerticalScroll = function() { return window.pageYOffset; };
  }
else if (document.documentElement && document.documentElement.clientWidth)
  {
    // These functions are for IE6 when there is a DOCTYPE
    this.getViewportWidth =
        function() { return document.documentElement.clientWidth; };
    this.getViewportHeight = 
        function() { return document.documentElement.clientHeight; };
    this.getHorizontalScroll = 
        function() { return document.documentElement.scrollLeft; };
    this.getVerticalScroll = 
        function() { return document.documentElement.scrollTop; };
  }
else if (document.body.clientWidth)
  {
    // These are for IE4, IE5, and IE6 without a DOCTYPE
    this.getViewportWidth =
        function() { return document.body.clientWidth; };
    this.getViewportHeight =
        function() { return document.body.clientHeight; };
    this.getHorizontalScroll =
        function() { return document.body.scrollLeft; };
    this.getVerticalScroll = 
        function() { return document.body.scrollTop; };
  }
else
  {
    this.getViewportWidth = null;
    this.getViewportHeight = null;
    this.getHorizontalScroll = null;
    this.getVerticalScroll = null;
  }
}

// This inserts info about the browser plugins
cBrowserInfo.prototype.resBrowser_Plugins = function ( id )
{
var o = getElement( id );
if ( o == null )
	return;
var sHTML = '<ul class="slist">\n';
if ( (navigator.plugins != null) && (navigator.plugins.length > 0) )
  {
	for ( var i = 0; i < navigator.plugins.length; ++i )
	  {
		sHTML += '<li><a href="#plugin' + i.toString() + '">&ldquo;' + navigator.plugins[i].name + '&rdquo;</a></li>\n';
	  }
  }
sHTML += '</ul>\n';
sHTML += '<p><em class="note">Note</em> : the same name may appear several times above; each has somewhat different properties.</p>';
sHTML += '<p>Further details are available for each plugin:</p>\n';
if ( (navigator.plugins != null) && (navigator.plugins.length > 0) )
  {
	for ( var i = 0; i < navigator.plugins.length; ++i )
	  {
		sHTML += '<h4>' + navigator.plugins[i].name + '<a id="plugin' + i.toString() + '" name="plugin' + i.toString() + '"></a></h4>\n';
		sHTML += '<table class="grid3d tdtop indent small">\n<tbody>\n';
		sHTML += '<tr class="h"><th>Name</th><td>' + navigator.plugins[i].name + '</td></tr>\n';
		sHTML += '<tr class="h"><th>Description</th><td>' + navigator.plugins[i].description + '</td></tr>\n';
		sHTML += '<tr class="h"><th>Filename</th><td>' + navigator.plugins[i].filename + '</td></tr>\n';
		sHTML += '<tr class="h"><th>MIME Types<br />(and filename suffixes)</th><td>';
		for ( var j = 0; j < navigator.plugins[i].length; ++j )
		  {
			sHTML += navigator.plugins[i][j].type;
			if ( ('' != navigator.plugins[i][j].suffixes) && (' ' != navigator.plugins[i][j].suffixes) )
				sHTML += ' (' + navigator.plugins[i][j].suffixes + ')';
			sHTML += '<br />';
		  }
		sHTML += '</td></tr>\n';
		sHTML += '</tbody>\n</table>\n';
	  }
  }
o.innerHTML = sHTML;
}

