/* 
 * support.js
 * IMPORTANTE: asegúrate que lo guardas con codificación UTF-8!!!
 */
function ZNavigator()
{
  z_navigator_init (this);
  this.DoTest = z_navigator_do_test;
  this.Is = z_navigator_is;
  this.CheckVersion = z_navigator_check_version;
  this.HasWindowInnerInfo = z_navigator_has_window_inner_info;
}

function z_navigator_init (self)
{
  self.zName = undefined;
  self.zVersion = undefined;
}

function z_navigator_is (name)
{
  return (this.zName.localeCompare (name) == 0);
}

function z_navigator_check_version (version)
{
  return (this.zVersion.localeCompare (version) <= 0);
}

function z_navigator_has_window_inner_info()
{
  /* En teoria est propiedad la soportan todos los navegadores, con la
   * excepción de IExplorer < 9.0
   */
  if (this.Is('MSIE') && this.CheckVersion ('8.0'))
  {
    return false;
  }
  return true;
}

function z_navigator_do_test()
{
  var s = navigator.userAgent;
  
  /* Internet Explorer */
  var k = s.indexOf ('MSIE');
  if (k != -1)
  {
    this.zName = "MSIE";
    if (s.indexOf ('MSIE 9.0', k) == k)
    {
      this.zVersion = "9.0";
    }
    else if (s.indexOf ('MSIE 8.0', k) == k)
    {
      this.zVersion = "8.0";
    }
    else if (s.indexOf ('MSIE 7.0', k) == k)
    {
      this.zVersion = "7.0";
      alert ('Está utilizando Internet Explorer 7.0, mientras que la versión vigente en el momento de escribir esta página era la 9.0 para Windows Vista y sucesivos y la 8.0 para Windows XP SP3.\nEste portal está optimizado para la versión 8.0:\nse le recomienda que actualice su navegador lo antes posible.');
    }
    else if (s.indexOf ('MSIE 6.0') == k)
    {
      this.zVersion = "6.0";
      alert ('Está utilizando Internet Explorer 6.0, que ha sido declarado'
              +' obsoleto por Microsoft.\nEste portal está optimizado para'
              +' la versión 8.0:\nse le recomienda que actualice su navegador'
              +' lo antes posible.');
    } 
    else
    {
      alert ('Está utilizando una versión de Internet Explorer no evaluada.');
    }
    return;
  }

  /* WebKit */
  k = s.indexOf ('AppleWebKit');
  if (k != -1)
  {
    this.zName = 'WebKit';
    if (s.indexOf ('AppleWebKit/535.', k) == k)
    {
      this.zVersion = "535.0";
    }
    else
    {
      var i = s.indexOf ('/', k);
      var j = s.indexOf ('.', k+1);
      if (i > j)
      {
        this.zVersion = s.substring (i, j) + ".0";
        if (this.zVersion.localeCompare ('535.0') < 0)
        {
          alert ('Está utilizando una versión antiquada de un navegador basado en WebKit (Safari, Chrome, etc.).');
        }
      }
      else
      {
        /* Aqui tenemos un error que notificar */
      }
    }
    return;
  }
  /* Gecko */
  k = s.indexOf ('Gecko');
  if (k != -1)
  {
    this.zName = 'Gecko';
    if (s.indexOf ('Gecko/20100101', k) == k)
    {
      this.zVersion = "20100101";
    }
    else
    {
      var i = s.indexOf ('/', k);
      var j = s.indexOf (' ', k+1);
      if (i > j)
      {
        this.zVersion = s.substring (i, j);
        if (this.zVersion.localeCompare ('20100101') < 0)
        {
          alert ('Está utilizando una versión antiquada de un navegador basado en Gecko (Firefox, Mozilla, etc.).');
        }
      }
      else
      {
        /* Aqui tenemos un error que notificar */
      }
    }
    return;
  }
}

zNavigator = new ZNavigator();



