// ************************************************************************************ //
//
// File name: BrowserCheck.js
// Version: 1.01
// Date: 03/08/2005
// Author: Matt McMahon 
// 
// ************************************************************************************ //

// ************************************************************************************ //
// Function to provide basic browser and platform identification for use by 
// other Javascript functions.  This file should be included first on all pages that make 
// use of it.
// ************************************************************************************ //
/* ************************************************************************** */
// BrowserCheck -- Global config parameters
/* ************************************************************************** */
var _NETSCAPE_APPNAME = "Netscape";
var _IE_APPNAME = "Microsoft Internet Explorer";
var _SAFARI_APPNAME = "Safari";
var _FIREFOX_APPNAME = "Firefox";
var _BROWSERCHECK_DEBUG = false;

function BrowserCheck() 
{
	this.setAppName();
	this.setAppVersion();
	this.setUserAgent();
	this.setPlatform();
	
	// Set IE related flags
	this.ie = ( this.appName == _IE_APPNAME && this.version >= 4 );
	this.ie4 = ( this.ie && ( this.userAgent.indexOf('MSIE 4') > 0 ) );
	this.ie5 = ( this.ie && ( this.userAgent.indexOf('MSIE 5') > 0 ) );
	this.ie55 = ( this.ie && ( this.userAgent.indexOf('MSIE 5.5') > 0 ) );
	this.ie6 = ( this.ie && ( this.userAgent.indexOf('MSIE 6') > 0 ) );
	
	// Both Firefox and Safari report as Netscape in navigator.appName
	// Need to check further
	this.firefox = navigator.userAgent.indexOf(_FIREFOX_APPNAME) > 0;
	this.safari = navigator.userAgent.indexOf(_SAFARI_APPNAME) > 0;
	
	// Set NS related flags
	this.ns = ( this.appName == _NETSCAPE_APPNAME && ! this.firefox && ! this.safari );
	this.ns = ( this.ns && this.version >= 4 );
	this.ns4 = ( this.ns && this.version == 4 );
	this.ns5 = ( this.ns && this.version == 5 );
	this.ns6 = ( this.ns && this.version == 6 );
	this.ns7 = ( this.ns && this.version == 7 );
	
	// Set platform flags
	this.mac = (this.platform.indexOf("Mac") != -1);
	this.win = (this.platform.indexOf("Win") != -1);
	this.otherOS = (!this.mac && !this.win );
	
	// Determine if the browser is modern, DOM compatible
	this.dom = this.isDomCompatible();

}
// ************************************************************************************ //

/* ************************************************************************** */
// Public interface

// Internal
BrowserCheck.prototype.setPlatform = BrowserCheck_setPlatform;
BrowserCheck.prototype.setAppVersion = BrowserCheck_setAppVersion;
BrowserCheck.prototype.setAppName = BrowserCheck_setAppName;
BrowserCheck.prototype.setUserAgent = BrowserCheck_setUserAgent;
BrowserCheck.prototype.isDomCompatible = BrowserCheck_isDomCompatible;
/* ************************************************************************** */

/* ************************************************************************** */
// Function to set the user browser platform
// Args:
// 	None
// 
/* ************************************************************************** */
function BrowserCheck_setPlatform()
{
	this.platform = navigator.platform;
	if( this.platform == null ) { this.platform = "unknown"; }
}
/* ************************************************************************** */

/* ************************************************************************** */
// Function to set the user browser app version
// Args:
// 	None
// 
/* ************************************************************************** */
function BrowserCheck_setAppVersion()
{
	this.version = parseInt(navigator.appVersion);
	if( this.version == null ) { this.version = 0; }
}
/* ************************************************************************** */

/* ************************************************************************** */
// Function to set the user browser app name
// Args:
// 	None
// 
/* ************************************************************************** */
function BrowserCheck_setAppName()
{
	this.appName = navigator.appName;
	if( this.appName == null ) { this.appName = "unknown"; }
}
/* ************************************************************************** */

/* ************************************************************************** */
// Function to set the user browser user agent
// Args:
// 	None
// 
/* ************************************************************************** */
function BrowserCheck_setUserAgent()
{
	this.userAgent = navigator.userAgent;
	if( this.userAgent == null ) { this.userAgent = "unknown"; }
}
/* ************************************************************************** */

/* ************************************************************************** */
// Function to set the user browser dom compatibility flag
// Args:
// 	None
// 
/* ************************************************************************** */
function BrowserCheck_isDomCompatible()
{
	// Determine if the browser is modern, DOM compatible
	var dom = (document.getElementById) ? true : false;
	// Fix dom detection for Mac IE5
	if(! dom )
	{
		dom = (this.mac && this.ie5);
	}
	return dom;
}
/* ************************************************************************** */


// Create the "is" object for use by other scripts
var is = new BrowserCheck(); 




