/*                                               */
/* Detecta browser e Sistema Operacional em uso  */
/*                                               */
function Browser() {
   var usag = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (usag.indexOf('gecko') != -1 && usag.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && usag.indexOf('gecko/') + 14 == usag.length);
   this.isNS        = ( (this.isGecko) ? (usag.indexOf('netscape') != -1) : ( (usag.indexOf('mozilla') != -1) && (usag.indexOf('spoofer') == -1) && (usag.indexOf('compatible') == -1) && (usag.indexOf('opera') == -1) && (usag.indexOf('webtv') == -1) && (usag.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (usag.indexOf('msie') != -1) && (usag.indexOf('opera') == -1) && (usag.indexOf('webtv') == -1) ); 
   this.isSafari    = (usag.indexOf('safari') != - 1);
   this.isOpera     = (usag.indexOf('opera') != -1); 
   this.isKonqueror = (usag.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (usag.indexOf('icab') != -1); 
   this.isAol       = (usag.indexOf('aol') != -1); 
   
   // alias browser name
   this.isNetscape=this.isNS;

   // spoofing and compatible browsers
   this.isIECompatible = ( (usag.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (usag.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.getVersion = parseFloat(this.version,10);
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( usag.substring( usag.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( usag.substring( usag.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( usag.substring( usag.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( usag.substring( usag.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (usag.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( usag.substring( usag.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( usag.substring( usag.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( usag.substring( usag.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (usag.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( usag.substring( usag.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( usag.substring( usag.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? usag.substring( (usag.lastIndexOf('gecko/') + 6), (usag.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // 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   = (usag.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( usag.indexOf('95') != -1 || usag.indexOf('98') != -1 || usag.indexOf('nt') != -1 || usag.indexOf('win32') != -1 || usag.indexOf('32bit') != -1 || usag.indexOf('xp') != -1) );
   this.isWin95 = (usag.indexOf("win95")!=-1 || usag.indexOf("windows 95")!=-1);
   this.isWin98 = (usag.indexOf("win98")!=-1 || usag.indexOf("windows 98")!=-1);
   this.isWinNT = (usag.indexOf("winnt")!=-1 || usag.indexOf("windows nt")!=-1);
   this.isWinME = (usag.indexOf("win 9x 4.90")!=-1);
   this.isWin2k = (usag.indexOf("windows nt 5.0")!=-1 || usag.indexOf("windows 2000")!=-1);
   this.isWinXP = (usag.indexOf("windows nt 5.1")!=-1 || usag.indexOf("windows xp")!=-1);
   this.isMac   = (usag.indexOf('mac') != -1);
   this.isUnix  = (usag.indexOf('unix') != -1 || usag.indexOf('sunos') != -1 || usag.indexOf('bsd') != -1 || usag.indexOf('x11') != -1)
   this.isLinux = (usag.indexOf('linux') != -1);
   
   // alias platform name
   this.isWindows=this.isWin;

   // 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);
}
