// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)

/*========= HELP - Instructions and var names ===================================
---------------------------------------------------------------------------------
Browser Engine Name
===========================
	- browser.isGecko 
		true if the browser uses the Gecko layout engine (such as Mozilla or 
		Netscape 6.x); false otherwise.
	
	- browser.isAppleWebKit 
		true if the browser uses the AppleWebKit layout engine (based on Konqueror's 
		KHTML engine); false otherwise.

Browser Name
===========================
	- browser.isMozilla 
		true if the browser is Mozilla (and not Netscape 6.x); false otherwise. Note, no 
		revision version information is available for Mozilla browsers (Mozilla 0.9.8 will 
		have a navigator.versionMinor of 5) - for Mozilla and all Gecko-based browsers, 
		use the navigator.geckoVersion for version information.
	
	- browser.isNS 
		true if the browser is any version of Netscape; false otherwise.
	
	- browser.isNS4x 
		true if the browser is any version of Netscape 4.x; false otherwise.
	
	- browser.isNS40x 
		true if the browser is any version of Netscape 4.0x (4.00 to 4.08); false otherwise.
	
	- browser.isNS47x 
		true if the browser is any version of Netscape 4.7x (4.70 - 4.79); false otherwise.
	
	- browser.isNS4up 
		true if the browser is any version of Netscape 4.00 or higher; false otherwise.
	
	- browser.isNS6x 
		true if the browser is any version of Netscape 6.x; false otherwise.
	
	- browser.isNS6up 
		true if the browser is any version of Netscape 6.00 or higher; false otherwise.
	
	- browser.isNS7x 
		true if the browser is any version of Netscape 7.x; false otherwise.
	
	- browser.isNS7up 
		true if the browser is any version of Netscape 7.00 or higher; false otherwise.
	
	- browser.isIE 
		true if the browser is any version of IE; false otherwise.
	
	- browser.isIE4x 
		true if the browser is any version of IE 4.x; false otherwise.
	
	- browser.isIE4xMac 
		true if the browser is any version of IE 4.x on the Mac; false otherwise.
	
	- browser.isIE4up 
		true if the browser is any version of IE 4.00 or greater; false otherwise.
	
	- browser.isIE5x 
		true if the browser is any version of IE 5.x; false otherwise.
	
	- browser.isIE55 
		true if the browser is IE 5.5; false otherwise.
	
	- browser.isIE5up 
		true if the browser is any version of IE 5.00 or greater; false otherwise.
	
	- browser.isIE6x 
		true if the browser is any version of IE 6.x; false otherwise.
	
	- browser.isIE6up 
		true if the browser is any version of IE 6.00 or greater; false otherwise.
	
	- browser.isOpera 
		true if the browser is any version of Opera; false otherwise.
	
	- browser.isSafari 
		true if the browser is any version of Safari; false otherwise.
	
	- browser.isOmniweb 
		true if the browser is any version of OmniWeb; false otherwise.
	
	- browser.isKonqueror 
		true if the browser is any version of Konqueror (assuming a default 
		user-agent configuration); false otherwise.
	
	- browser.isIcab 
		true if the browser is any version of iCab (assuming a default user-agent 
		configuration); false otherwise.
	
	- browser.isAol 
		true if the browser is any version of AOL; false otherwise.
	
	- browser.isNSCompatible 
		true if the browser reports itself to be Netscape or Mozilla but isn't; false 
		otherwise.
	
	- browser.isIECompatible 
		true if the browser reports itself to be IE but isn't; false otherwise.

Browser Engine Version
===========================
	- browser.geckoVersion 
		Contains the Gecko version date (in YYYYMMDD format) for Gecko-based browsers; 
		for non-Gecko browsers, it will evaluate to -1.
	
	- browser.equivalentMozilla 
		Contains the version number of Mozilla that would be equivalent to current 
		browser for Gecko-based browsers (NS6+, Firebird, K-Meleon, Camino, Galeon, etc); 
		for non-Gecko browsers, it will evaluate to -1.
	
	- browser.appleWebKitVersion 
		Contains the AppleWebKit build number for AppleWebKit-based browsers 
		(Safari, OmniWeb4.5+); for non-AppleWebKit browsers, it will evaluate to -1.

Browser Version
===========================
	- browser.versionMajor 
		Contains the integer version number for the browser (for instance, the value 
		of navigator.versionMajor for Netscape 4.07 is 4).
	
	- browser.versionMinor 
		Contains the full version number for the browser (for instance, the value 
		of navigator.versionMajor for Netscape 4.07 is 4.07).
	
Browser Capabilities
===========================
	- browser.isDOM1 
		true if the browser supports DOM level 1; false otherwise.
	
	- browser.isDOM2Event 
		true if the browser supports DOM level 2 events; false otherwise.
	
	- browser.mode 
		Mirrors document.compatMode but available in all browsers - BackCompat for 
		quirks mode or CSS1Compat for Strict mode.

Platform / Operating System
===========================
	- browser.isWin 
		true if the platform is Windows-based; false otherwise.
	
	- browser.isWin32 
		true if the platform is Windows 32bit (Win95, Win98, WinNT, Win2000, WinME); 
		false otherwise.
	
	- browser.isMac 
		true if the platform is a Macintosh; false otherwise.
	
	- browser.isUnix 
		true if the platform is a Unix, SunOS or BSD variant; false otherwise. 
		Because of the huge number of *nix operating systems, this property isn't 
		foolproof.
	
	- browser.isLinux 
		true if the platform is a Linux variant; false otherwise. Because of the huge 
		number of *nix operating systems, this property isn't foolproof.
---------------------------------------------------------------------------------
===============================================================================*/

function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();