// Browser sniffing utility JavaScript Snippet
// File:    browsercheck.js
// Author:  Eric Baars
// WEBCAT:  2.1
// Version: 1.0
// History:
//    17 Jan 2001  Initial creation
//	  28 Mar 2002  Updated to distinguish between newer browser version (IE 5, 5.5 and 6)...CJF
//	   9 Sep 2002  Added netscape 7.  TODO: Clean up netscape to provide uniform browserType...CJF
//	  10 Sep 2002  Added uniform browserType.  All Netscape browsers are referred to as 'nn'.
//					All MSIE browsers are refered to as ie.  browserVersion tells the difference between
//					different versions of browsers...CJF
//    19 Jul 2007  Added check for ie 7...Derek Lam (turns out this is all that needed to fix in order to fix help focus
//    		(currently, every time ie has a new version, checkbrowser must be modified otherwise help focus won't work
//    22 Jul 2008  Found some code on msdn for proper detection...Derek Lam

// Browser sniffing
//-------------------------------------------------------------------
// browserType is assigned by this snippet
// No function needs to be called.

// Global variable
var browserType = '';
var browserVersion = '';
var isSafari = false;

// Perform check
var agent = navigator.userAgent.toLowerCase();
isSafari = agent.indexOf("safari") != -1;

if ((agent.indexOf('mozilla') != -1) &&
			(agent.indexOf('spoofer') == -1) &&
			(agent.indexOf('compatible') == -1)) {
	// AOL Netscape
	browserType = 'nn';
	browserVersion = parseInt( navigator.appVersion ) ;
} else {
	// Microsoft Internet Explorer
	var appVersion = navigator.appVersion ;
	browserType = 'ie';
        browserVersion = getInternetExplorerVersion();
/*
        if ( appVersion.indexOf( "MSIE 7" ) > -1 ) {
                browserVersion = 7;
        }
	else if ( appVersion.indexOf( "MSIE 6" ) > -1 ) {
		browserVersion = 6 ;
	} else if ( appVersion.indexOf( "MSIE 5" ) > -1 ) {
		browserVersion = 5 ;
	} else {
		browserVersion = parseInt( navigator.appVersion ) ;
	}
*/
}

//taken from http://msdn.microsoft.com/en-us/library/ms537509.aspx#ParsingUA
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseInt( RegExp.$1 );
  }
  return rv;
}

