<!--

/*
browser.js 2001-12-05

Contributor(s): Bob Clary, Netscape Communications, Copyright 2001

Netscape grants you a royalty free license to use or modify this
software provided that this copyright notice appears on all copies.
This software is provided "AS IS," without a warranty of any kind.

Properties set by browser.js

navigator.OS
 - "win" for all Windows platforms
 - "mac" for all Macintosh platforms
 - "nix" for all Unix like platforms
 - "" if platform is not one of the above

navigator.org
 - "opera" for Opera based browsers
 - "netscape" for Netscape browsers
 - "microsoft" for Microsoft browsers
 - "compuserve" for Compuserve browsers
 - "sun" for HotJava
 - "" if organization is not one of the above

navigator.version
 If the browser organization is one of the above, then the version will be reported in navigator.version as a floating point number. 
 Otherwise, the version will be 0. Note that Gecko based browser will report the Release Version from the UserAgent string and not actual 
 version reported by the vendor.
 
navigator.family
 navigator.family contains a string that groups browsers into families that can be reasonably treated in a similar fashion. 
 Different versions of a browser within a family can be distinguished by the navigator.version property. 
 Current families that are detected are:
 - "hotjava" HotJava browsers from Sun
 - "opera" Opera Browsers
 - "ie3" Internet Explorer versions before 4
 - "ie4" Internet Explorer versions 4 and later
 - "gecko" browsers based upon the Mozilla Open Source browser such as Netscape 6
 - "nn3" Netscape Navigator 3.x browsers
 - "nn4" Netscape Navigator 4.x browsers
 - "aol" AOL browsers
*/

function xbDetectBrowser()
{
	var oldOnError = window.onerror;
	var element = null;

	window.onerror = null;
  
	// work around bug in xpcdom Mozilla 0.9.1
	window.saveNavigator = window.navigator;

	navigator.OS = '';
	navigator.version = parseFloat( navigator.appVersion );
	navigator.org = '';
	navigator.family = '';

	var platform;
	
	if ( typeof( window.navigator.platform ) != 'undefined' ) {
		platform = window.navigator.platform.toLowerCase();
		if ( platform.indexOf( 'win' ) != -1 )
			navigator.OS = 'win';
		else if ( platform.indexOf( 'mac' ) != -1 )
			navigator.OS = 'mac';
		else if ( platform.indexOf( 'unix' ) != -1 || platform.indexOf( 'linux' ) != -1 || platform.indexOf( 'sun' ) != -1 )
			navigator.OS = 'nix';
	}

	var i = 0;
	var ua = window.navigator.userAgent.toLowerCase();
  
	if ( ua.indexOf( 'opera' ) != -1 ) {
		i = ua.indexOf( 'opera' );
		navigator.family = 'opera';
		navigator.org = 'opera';
		navigator.version  = parseFloat( '0' + ua.substr( i+6 ), 10 );
		
	} else if (( i = ua.indexOf( 'msie' )) != -1 ) {
		navigator.org = 'microsoft';
		navigator.version = parseFloat( '0' + ua.substr( i+5 ), 10 );
		if ( navigator.version < 4 )
			navigator.family = 'ie3';
		else
			navigator.family = 'ie4';
			
	} else if ( ua.indexOf( 'gecko' ) != -1 ) {
		navigator.family = 'gecko';
		var rvStart = navigator.userAgent.indexOf( 'rv:' ) + 3;
		var rvEnd = navigator.userAgent.indexOf( ')', rvStart );
		var rv = navigator.userAgent.substring( rvStart, rvEnd );
		var decIndex = rv.indexOf( '.' );
		if ( decIndex != -1 ) {
			rv = rv.replace( /\./g, '' )
			rv = rv.substring( 0, decIndex-1 ) + '.' + rv.substr( decIndex );
		}
		navigator.version = parseFloat( rv );

		if ( ua.indexOf( 'netscape' ) != -1 )
			navigator.org = 'netscape';
		else if ( ua.indexOf( 'compuserve' ) != -1 )
			navigator.org = 'compuserve';
		else
			navigator.org = 'mozilla';
	
	} else if (( ua.indexOf( 'mozilla' ) != -1 ) && ( ua.indexOf( 'spoofer' ) == -1 ) && ( ua.indexOf( 'compatible' ) == -1 ) 
		&& ( ua.indexOf( 'opera' ) == -1 ) && ( ua.indexOf( 'webtv' ) == -1 ) && ( ua.indexOf( 'hotjava' ) == -1 )) {
		var is_major = parseFloat( navigator.appVersion );
		if ( is_major < 4 )
			navigator.version = is_major;
		else {
			i = ua.lastIndexOf( '/' )
			navigator.version = parseFloat( '0' + ua.substr( i+1 ), 10 );
		}
		navigator.org = 'netscape';
		navigator.family = 'nn' + parseInt( navigator.appVersion );
		
	} else if (( i = ua.indexOf( 'aol' )) != -1 ) {
		navigator.family = 'aol';
		navigator.org = 'aol';
		navigator.version = parseFloat( '0' + ua.substr( i+4 ), 10 );
		
	} else if (( i = ua.indexOf( 'hotjava' )) != -1 ) {
		navigator.family = 'hotjava';
		navigator.org = 'sun';
		navigator.version = parseFloat( navigator.appVersion );
	}
	
	window.onerror = oldOnError;
}

xbDetectBrowser();

// set some 'shortcuts' for DOM browsers
var IS_MOZ = ( navigator.family == 'gecko' ? 1 : 0 );				// Mozilla and NN6+
var IS_IE = ( navigator.family == 'ie4' && navigator.version > 5 ? 1 : 0 );	// IE5+

//-->
