function Browser(name, version) {
    this.name = name;
    this.version = version;
}

var supportedBrowsers = new Array();
supportedBrowsers[0] = new Browser("Internet Explorer", 5.5);
supportedBrowsers[1] = new Browser("Mozilla Firefox", 1.0);
supportedBrowsers[2] = new Browser("Mozilla", 1.3);
supportedBrowsers[3] = new Browser("Netscape", 7.1);
supportedBrowsers[4] = new Browser("Opera", 8.0);

// based on 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)
function BrowserDetect()
{
   var ua = navigator.userAgent.toLowerCase();
   this.ua = ua;

   // 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.isFirefox     = (this.isGecko && ua.indexOf('firefox') != -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) ));
   this.isMozilla     = (this.isGecko && !this.isFirefox && !this.isNS);
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

   // browser version
   this.version = parseFloat(navigator.appVersion);

   // correct version number
   if (this.isFirefox) {
      this.version = parseFloat( ua.substring( ua.indexOf('firefox/') + 8 ) );
   }
   else if (this.isGecko && !this.isMozilla) {
      this.version = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.version = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.version >= 4) {
      this.version = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.version = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.version = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.version = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.version = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.version = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }

   // 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);

   // methods
   this.isBrowserCompatible = BrowserDetect_isBrowserCompatible;
   this.getBrowserName      = BrowserDetect_getBrowserName;
   this.getPlatform         = BrowserDetect_getPlatform;
   this.detected            = BrowserDetect_detected;
   this.getVersion          = BrowserDetect_getVersion;
}

function BrowserDetect_getBrowserName()
{
    if(this.isIE) return "Internet Explorer";
    else if(this.isOpera) return "Opera";
    else if(this.isKonqueror) return "Konqueror";
    else if(this.isSafari) return "Safari";
    else if(this.isOmniweb) return "OmniWeb";
    else if(this.isIcab) return "iCab";
    else if(this.isMozilla) return "Mozilla";
    else if(this.isFirefox) return "Mozilla Firefox";
    else if(this.isNS) return "Netscape";
    else return "cannot detect";
}

function BrowserDetect_isBrowserCompatible()
{
    for(i = 0; i <= 4; i++)
    {
        if(supportedBrowsers[i].name == this.getBrowserName() && supportedBrowsers[i].version <= this.version)
        {
            return true;
        }
    }
    return false;
}

function BrowserDetect_getPlatform()
{
    if(this.isWin || this.isWin32) return "Windows";
    else if(this.isMac) return "MacOS";
    else if(this.isLinux) return "Linux";
    else if(this.isUnix) return "Unix";
    else return "cannot detect";
}

function BrowserDetect_detected()
{
    return (this.isIE || this.isOpera || this.isKonqueror || this.isSafari || this.isOmniweb || this.isIcab ||
            this.isMozilla || this.isFirefox || this.isNS);
}

function BrowserDetect_getVersion()
{
    if(this.version - parseInt(this.version) < 0.0001)
        return this.version + ".0";
    else
        return this.version;
}




