// typically, the parameters are hidden form elements
function GetBrowserAndOSType(oBrowserFormElement, oOSFormElement)
{
var bMSIE = false;
var bFirefox = false;
var bNetscape = false;
var iBrowserType = -1;
var iOSType = -1;

var ua = window.navigator.userAgent;
var an = window.navigator.appName;

// Is it IE?
bMSIE = (ua.indexOf("MSIE") >= 1);
if (bMSIE)
  {
    // IE4
    if (ua.indexOf("MSIE 4.0")>=1)
      iBrowserType = 0;

    // IE5
     if (ua.indexOf("MSIE 5.0")>=1)
       iBrowserType = 1;

    // IE5.5
    if (ua.indexOf("MSIE 5.5")>=1)
      iBrowserType = 2;

    //IE6
    if (ua.indexOf("MSIE 6.0")>=1)
      iBrowserType = 3;

    //IE7
    if (ua.indexOf("MSIE 7.0")>=1)
      iBrowserType = 4;

  }
else if (ua.indexOf("Firefox") > 0)
  {
    bFirefox = true;
    
    if (ua.indexOf("Firefox/1.0") > 0)
      iBrowserType = 7;

    if (ua.indexOf("Firefox/1.5") > 0)
      iBrowserType = 8;

    if (ua.indexOf("Firefox/2.0") > 0)
      iBrowserType = 9;
  }
else if (an == "Netscape")
  {
    bNetscape = true;
    var appVer = parseInt(navigator.appVersion);
    if (appVer >= 6)
      iBrowserType = 13;
    else if (appVer >= 4)
      iBrowserType = 12;
    else if (appVer >= 3)
      iBrowserType = 11;
    else
      iBrowserType = 10;
  }


if (bMSIE)
  {
   //IE supported OS's
   if (ua.indexOf("Windows 95")>=1)
     iOSType = 1;
   else if (ua.indexOf("Windows 98")>=1)
     iOSType = 2;
   else if (ua.indexOf("Windows NT")>=1)
     iOSType = 3;
   else if (ua.indexOf("Windows NT 5.0")>=1)
     iOSType = 4;
   else if (ua.indexOf("Windows NT 5.1")>=1)
     iOSType = 5;
   else if (ua.indexOf("Windows NT 6.0")>=1)
     iOSType = 6;
   else if (ua.indexOf("Windows 3.1")>=1)
     iOSType = 0;
   else if (ua.indexOf("Mac")>=1)
     {
       iOSType = 10;
       if (ua.indexOf("Mac_68000")>=1)
         iOSType = 11;
       else if (ua.indexOf("Mac_PowerPC")>=1)
         iOSType = 12;
     }
   else if (ua.indexOf("SunOS")>=1)
     iOSType = 20;
   else if (ua.indexOf("Solaris")>=1)
     iOSType = 21;
   else if (ua.indexOf("nix")>=1)
     iOSType = 30;
   else if (ua.indexOf("Linux")>=1)
     iOSType = 40;
   else
     iOSType = 50;
 }
else if (bNetscape || bFirefox)
 {
   // NSCP supporte OS's
   if (ua.indexOf("Win95")>=1 || ua.indexOf("Windows 95")>=1)
     iOSType = 1;
   else if (ua.indexOf("Win98")>=1 || ua.indexOf("Windows 98")>=1)
     iOSType = 2;
   else if (ua.indexOf("WinNT")>=1 || ua.indexOf("Windows NT")>=1)
     iOSType = 3;
   else if (ua.indexOf("Windows NT 5.0")>=1)
     iOSType = 4;
   else if (ua.indexOf("Windows NT 5.1")>=1)
     iOSType = 5;
   else if (ua.indexOf("Windows NT 6.0")>=1)
     iOSType = 6;
   else if (ua.indexOf("Win16")>=1)
     iOSType = 0;
   else if (ua.indexOf("Mac")>=1)
     {
       iOSType = 10;
       if (ua.indexOf("68K")>=1)
         iOSType = 11;
       else if (ua.indexOf("PPC")>=1)
         iOSType = 12;
     }
  }


if (oBrowserFormElement != null)
  {
    oBrowserFormElement.value = "" + iBrowserType;
  }
if (oOSFormElement != null)
  {
    oOSFormElement.value = "" + iOSType;
  }
}



function SetBrowserAndOSTypeFields(oForm, cBrowserFormElementName, cOSFormElementName)
{
  if (oForm == null)
    oForm = document.forms[0];

  var oBrowserFormElement = oForm.elements[cBrowserFormElementName];
  var oOSFormElement = oForm.elements[cOSFormElementName];


  GetBrowserAndOSType(oBrowserFormElement, oOSFormElement)
}
