// Notes
// - OS should be accurate, that is the primary purpose of this code.
// - Mozilla (from Mozilla.org) can't be reliably discriminated from Netscape,
//   so it will get flagged as 'Netscape'.  
var agent = navigator.userAgent.toLowerCase();
var OS, platform, browser, version, lastString;
if (findString(agent, 'konqueror')) {
   browser = "Konqueror";
   OS = "Linux";
}
else if (findString(agent, 'omniweb')) browser = "OmniWeb";
else if (findString(agent, 'opera')) browser = "Opera";
else if (findString(agent, 'webtv')) browser = "WebTV";
else if (findString(agent, 'icab')) browser = "iCab";
else if (findString(agent, 'msie')) browser = "Internet Explorer"; 
else if (!findString(agent, 'compatible')) {
   browser = "Netscape Navigator";
   version = agent.charAt(8);
}
else browser = "An unknown browser"; 
if (!version) version = agent.charAt(place + lastString.length);
if (!OS) {
   if (findString(agent, 'linux')) OS = "Linux";
   else if (findString(agent, 'x11')) OS = "Unix";
   else if (findString(agent, 'mac')) OS = "Mac"
   else if (findString(agent, 'win')) OS = "Windows"
   else if (platform = navigator.platform) {
      platform = navigator.platform.toLowerCase();
      if (findString(platform, 'linux')) OS = "Linux";
      else if (findString(platform, 'unix')) OS = "Unix";
      else if (findString(platform, 'mac')) OS = "Mac"
      else if (findString(platform, 'win')) OS = "Windows"
      else OS = "an unknown operating system";
   }
}
function findString(target, string) {
   place = target.indexOf(string) + 1;
   lastString = string;
   return place;
}
 