function CBrowserDetect() 
{
   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);
}
with (CBrowserDetect)
{
  prototype.IsIE = function CBrowserDetect_IsIE() { return this._isIE;  }
  prototype.IsFF = function CBrowserDetect_IsFF() { return this._isGecko;  }

  prototype.IsWin32 = function CBrowserDetect_IsWin32() { return this._isWin32; } 
  prototype.IsLinux = function CBrowserDetect_IsLinux() { return this._isLinux; }
}
