/********************************************************************
**	file:	client.js
**	date:	08052000
**
**	author:	Robert Barlow
**			Copyright © 2000
**
**	description:
**	Module contains object that will represent the browser, containing
**	methods and properties for detection of client attributes. This
**	file then creates a global variable, "client" that may be used
**	throughout a page.
**
*********************************************************************
**	FUNCTION/OBJECT DESCRIPTIONS
*********************************************************************
**
**	Client()
**		This object has several properties to easily detect browser
**		(client) settings.
**
**		Properties
**		----------
**		*)	agent
**			Contains the full user agent string of the browser,
**			converted to lower case.
**		*)	name
**			Contains the application name of the browser, converted to all
**			lower case.
**		*)	majorVer
**			Property holds the major version number for the browser
**			(for example, 3 or 4 or 5... no decimals)
**		*)	version
**			Contains the complete version number.
**		*)	opSys
**			Contains the operating system for the browser, or "unknown"
**			if not reported.
**		*)	isMac
**			Returns true if the client is a Mac.
**		*)	isWin
**			Returns true if the client is a flavor of windows.
**		*)	isNt
**			Returns true if the client is a browser built for Windows NT.
**		*)	ns, ns2, ns3, ns4, ns5, ns6
**			These properties are set to true for Netscape browsers
**			of the appropriate level browser.  For example, if the
**			client is Netscape 4, ns, ns2, ns3 and ns4 will be true,
**			while ns5 and ns6 will be false. (Note that since 5 & 6
**			for Navigator are not backward compatible, if the Netscape
**			browser is 5 or 6, ns, ns2, ns3, n4 will be false).
**		*)	ie, ie3, ie4, ie5
**			Reports the appropriate Internet Explorer version or
**			higher (example, Internet Explorer 4 will make ie3 and
**			ie4 true, but ie5 will be false).
**		*)	op
**			Returns true if the browser is opera.
**		*)	ActiveXEnabled
**			Returns true if the browser should be ActiveX (OCX) control
**			enabled.
**		*)	DHTMLEnabled
**			Returns true for DHTML versions of ie and ns browsers.
**		*)	JavaEnabled
**			Returns true for Java Enabled ie and ns browsers.
**		*)	JSEnabled
**			Returns true for JavaScript enabled versions of ie
**			and ns browsers.
**		*)	VBEnabled
**			Returns true for vbscript enabled browsers (IE).
**
*********************************************************************
**	REVISION HISTORY
*********************************************************************
**
**	date		author		description
**	----------------------------------------------------------------
**	
**
********************************************************************/

function Client()
{
	this.agent    = navigator.userAgent.toLowerCase();
	this.name     = navigator.appName.toLowerCase();
	this.majorVer = parseInt(navigator.appVersion);
	this.version  = parseFloat(navigator.appVersion);

	if (navigator.platform)
		this.opSys = navigator.platform;
	else
		this.opSys = "unknown";

	// do some operating system detection
	this.isMac = (this.opSys.indexOf("Mac") != -1);
	this.isWin = (this.opSys.indexOf("Win") != -1);
	this.isNt  = ((this.agent.indexOf("windows nt") != -1) ||
						((this.agent.toLowerCase().indexOf("winnt") != -1)));

	// detect netscape
	this.ns  = (this.name == "netscape");
	this.ns2 = (this.ns && ((this.majorVer >= 2) && (this.majorVer < 5)));
	this.ns3 = (this.ns && ((this.majorVer >= 3) && (this.majorVer < 5)));
	this.ns4 = (this.ns && (this.majorVer == 4));
	this.ns5 = (this.ns && (this.majorVer >= 5));
	this.ns6 = (this.ns && (this.majorVer >= 6));

	// detect explorer -- NOTE: my IE5 version gave up a 4
	// as the majorVer and version above, so the agent string
	// was used to grab the "MSIE 5.0", as well.
	this.ie  = (this.name == "microsoft internet explorer");
	this.ie3 = ( this.ie && (this.majorVer >= 3) );
	this.ie4 = ( this.ie && (
		(this.agent.indexOf("msie 4") > -1) || (this.majorVer >= 4) ) );
	this.ie5 = ( this.ie && (
		(this.agent.indexOf("msie 5") > -1) || (this.majorVer >= 5) ) );

	// detect other browsers
	this.op  = (this.agent.indexOf("opera") != -1);

	// MEMBER PROPERTIES
	this.ActiveXEnabled = (this.ie3 && !this.isMac);
	this.DHTMLEnabled   = (this.ns4 || this.ns5 || this.ie4);
	this.JavaEnabled    = (this.ns3 || this.ns5 || this.ie3);
	this.JSEnabled      = (this.ns2 || this.ns5 || this.ie3);
	this.VBEnabled      = (this.ie3);

	return this;
}

var client = new Client();


