
function getBrowserInfo(ua)
{
   function findName(){
      var m;
      if(ua.match(/cs\s*2000/)){
         browser.name="compuserve";
         if(ua.match(/gecko/)){
            browser.version=7;
         } else {
            browser.version=2000;
         }
         return;
      }
      
      var names=["opera","aol","konqueror","netscape","safari","msie"];
      for(var i=0;i<names.length;i++){
         var ns=names[i];
         if((m=ua.indexOf(ns))>=0){
            browser.name=ns;
            m=ua.substr(m+ns.length).match(/[ \/]*(\d+(\.\d+)?)/);
            if(m){ browser.version=parseFloat(m[1]);}
            return;
         }
      }
      if(ua.indexOf("gecko")>=0){
         if(ua.indexOf("firefox")>=0){
            browser.name="firefox";
         }else{
            browser.name="mozilla";
         }
         m=ua.match(/rv:(\d+(\.\d+)?)/);
         if(m){ browser.version=parseFloat(m[1]);}
         return;
      }
      m=ua.match(/mozilla[^\/]*\/(\d+(\.\d+)?)/);
      if(m){
         browser.name="mozcompat";
         browser.version=parseFloat(m[1]);
      }
   }
   function findOS(){
      ua=ua.replace(/[^a-z0-9.]+/g,"")
      ua="**" + ua.replace(/windows/g,"win");

      browser.platform="win";
      if(0<ua.indexOf("win9"))     { return browser.os="9x";}
      if(0<ua.indexOf("winnt5.1")){ return browser.os="xp";}
      if(0<ua.indexOf("winnt5.2")){ return browser.os="xp";}
      if(0<ua.indexOf("winxp"))    { return browser.os="xp";}
      if(0<ua.indexOf("winnt"))    { return browser.os="nt";}
      if(0<ua.indexOf("win"))      { return browser.os="";}

      if(0<ua.indexOf("macosx"))   { return (browser.platform="mac",browser.os="osx");}
      if(0<ua.indexOf("mac"))      { return (browser.platform="mac",browser.os="classic");}
      if(0<ua.indexOf("linux"))    { return browser.platform="linux";}
   }

   var browser={platform:"",os:"",name:"",version:0};
   if(!ua){
      ua=navigator.userAgent;
   }
   ua=ua.toLowerCase();
   findName();
   findOS();
   return browser;
}

// http://www.quirksmode.org/js/flash.html

function getFlashInfo(){
   var flash={ version : 0,versionString: "" }
   if(navigator.plugins && navigator.plugins.length){
      var plugin=navigator.plugins["Shockwave Flash"];
      if (plugin){
         flash.version=1;
         var p=plugin.description && plugin.description.match(/\d+.*/);
         if(p){
            flash.version=parseInt(p[0]);
            flash.versionString=p[0];
         }
      }
   }
   else if(navigator.mimeTypes && navigator.mimeTypes.length){
      var plugin=navigator.mimeTypes['application/x-shockwave-flash'];
      if (plugin && plugin.enabledPlugin){
         flash.version=1;
      }
   }
   else if (window.ActiveXObject){
      try {
         var t=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
         var v=t.GetVariable("$version");
         var m=v.match(/\d+.*/);
         flash.version=parseInt(m[0]);
         flash.versionString=v;
      } catch(e){}
   }
   return flash;
}

// http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14201

function hasWmode(){
   var browser=getBrowserInfo();
   var flash=getFlashInfo();

   if(flash.version<8){ return false;}
   if(browser.platform != "win" && browser.os != "osx"){ return false;}
      
   //Internet Explorer 3 or higher (Windows)
   if(browser.name == "msie" && browser.platform == "win" && browser.version > 6)
      { return true;}
   //Internet Explorer 5.1* and 5.2* (Macintosh)
   if(browser.name == "msie" && browser.os == "osx" && browser.version > 5)
      { return true;}
   //Netscape 7.0*
   if(browser.name == "netscape" && browser.version > 7)
      { return true;}
   //Mozilla 1.0 or higher*
   if(browser.name == "mozilla" && browser.version > 1.0)
      { return true;}
   //AOL*
   if(browser.name == "aol")
      { return true;}
   //compuserve
   if(browser.name == "compuserve")
      { return true;}
   // Safari 1.3+ (build 312=version 1.3)
   if(browser.name == "safari" && browser.version > 520)
      { return true;}
      
   //firefox 1.3+
   if(browser.name == "firefox" && browser.version > 1.7)
      { return true;}
      
   //opera 8+
   if(browser.name == "opera" && browser.version > 8)
      { return true;}


   return false;
} 
