/*********************************
* Class Browser                  *
*                                *
* Properties: code               *
*               Input: -         *
*               Output: (String) *
*             name               *
*               Input: -         *
*               Output: (String) *
*             version            *
*               Input: -         *
*               Output: (String) *
*********************************/

function Browser()
{
  this.code = '';
  this.name = 'Unknown';
  this.version = '';

  if (navigator.userAgent.indexOf('Chrome') != -1)
  {
    this.code = 'CR';
    this.name = 'Chrome';
    this.version = extract('Chrome', '/', ' ');
  }
  else if (navigator.userAgent.indexOf('Firefox') != -1)
  {
    this.code = 'FF';
    this.name = 'Firefox';
    this.version = extract('Firefox', '/', ' ');
  }
  else if (navigator.userAgent.indexOf('MSIE') != -1)
  {
    this.code = 'IE';
    this.name = 'Internet Explorer';
    this.version = extract('MSIE', ' ', ';');
  }
  else if (navigator.userAgent.indexOf('Opera') != -1)
  {
    this.code = 'OP';
    this.name = 'Opera';
    this.version = extract('Version', '/', ' ');
  }

  function extract(str, delimiter1, delimiter2)
  {
    var arr = new Array();
    var position;
    position = navigator.userAgent.indexOf(str);
    if (position != -1)
    {
      str = navigator.userAgent.concat(delimiter2);
      arr = str.substring(position, str.indexOf(delimiter2, position)).split(delimiter1);
      return arr[1];
    }
    else
      return '';
  }
}

