// -----------------------------------------------------------------------------
// Advansys product download verification script
// Copyright (C) 1999 Advansys Pty Limited
//
// History
// 3/11/99  GPJ Initial Version
// 27/9/00  GJB Updated for eSync Warehouse and Ericsson R380
// -----------------------------------------------------------------------------


function isseries3(s)
{
  if ((s == 'psion series 3mx') || (s == 'psion siena') || (s == 'psion series 3c') || (s == 'psion series 3a'))
    return true
  else
    return false;
}

function is_er3(s)
{
  if (s == 'psion series 5')
    return true
  else
    return false;
}

function is_er5(s)
{
  if ((s == 'psion series 5mx') || (s == 'psion series 7') || (s == 'psion netbook') || (s == 'psion revo') || (s == 'psion revoplus') || (s == 'ericsson mc218') || (s == 'diamond mako'))
    return true
  else
    return false;
}

function is_ec5(s)
{
  if ((s == 'psi2.3') || (s == 'eec1.0') || (s == 'ec5'))
    return true
  else
    return false;
}

function er5list(s)
{
  return 'Warning:\n\nThe product you have selected only supports the following devices:\n' + s + '5mx, Revo, Revo PLUS, 7, netBook, Ericsson MC218 and Diamond Mako.\nPlease download the product which supports your specific device.';
}

function is_r380(s)
{
  if (s == 'ericsson r380')
    return true
  else
    return false;
}

function is_9210(s)
{
  if (s == 'nokia 9210')
    return true
  else
    return false;
}

function devicesupport(s)
{
  return 'Warning:\n\nThe product you have selected only supports the ' + s + '.\nPlease download the product which supports your specific device.';
}

function devicenotsupported(s)
{
  return 'Warning:\n\nThe product you have selected does not support the ' + s + '.\nPlease download the product which supports your specific device.';
}

function reset(form)
{
  form.device.options[0].selected = true;
  form.epocconnect.options[0].selected = true;
}


// Display the bad EC version alert
function badecversion(s)
{
  return 'Warning:\n\nThe product you have selected requires ' + s + '.\nPlease download the product specific to your version of PsiWin.';
}


// Verify the user has selected a valid combination of products
// Alert them if not
function verify(form)
{

  var selectedproduct = '';
  selectedproduct = form.product.value;
  var device = form.device[form.device.selectedIndex];
  var epocconnect = form.epocconnect[form.epocconnect.selectedIndex];


  // Check if product has been selected
  if (selectedproduct == 'none')
  {
      alert('Warning:\n\nPlease select an Advansys product to download from the drop down list.');
      reset(form);
      return;
  }


  // LinkWise 2.0
  if ((selectedproduct == 'LW2_GW5x') || (selectedproduct == 'LW2_GW41a'))
  {
    if (!isseries3(device.value))
    {
      alert('Warning:\n\nLinkWise 2.0 is only for use with the Psion Series 3a, 3c, 3mx or Siena.\nIt will NOT work with any other device.');
      reset(form);
      return;
    }
  }


  // LinkWise Plugin for PsiWin 2.1 (GW5/4 versions)
  if ((selectedproduct == 'LPI_GW5x') || (selectedproduct == 'LPI_GW41a'))
  {
    if (isseries3(device.value))
    {
      alert('Warning:\n\nPsiWin 2.1 does not support the Psion Series 3x family of devices.\nWe recommend you download our LinkWise 2.0 product.');
      reset(form);
      return;
    }
    if (is_er5(device.value) || is_r380(device.value))
    {
      alert(devicesupport('Psion Series 5'));
      reset(form);
      return;
    }
    if (epocconnect.value != 'psi2.1')
    {
      alert(badecversion('PsiWin 2.1'));
      reset(form);
      return;
    }
  }


  // LinkWise Plugin for PsiWin 2.2 (GW5/4 versions)
  if ((selectedproduct == 'LPI22_GW5x') || (selectedproduct == 'LPI22_GW41a'))
  {
    if (isseries3(device.value))
      alert('Hint:\n\nLinkWise 2.0 (GroupWise 5.x version) is our recommended solution for Series 3x users.\nLinkWise 2.0 provides more functionality for Series 3x users.');

    if (is_er5(device.value) || is_r380(device.value))
    {
      alert(devicesupport('Psion Series 5, 3x and Siena'));
      reset(form);
      return;
    }
    if (epocconnect.value != 'psi2.2')
    {
      alert(badecversion('PsiWin 2.2'));
      reset(form);
      return;
    }
  }


  // LinkWise 2000 - Novell GroupWise Edition
  if ((selectedproduct == 'LPI23_GW5x') || (selectedproduct == 'LPI23_GW41a'))
  {
    if (!is_er5(device.value) && !is_er3(device.value))
    {
      alert(er5list('Psion Series 5, '));
      reset(form);
      return;
    }
    if (!is_ec5(epocconnect.value))
    {
      alert('Warning:\n\nThe product you have selected requires EPOC Connect 5.0 (PsiWin 2.3 or Ericsson EPOC Connect 1.0).\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }


  // LinkWise 2000 - Novell Directory Services Edition
  if (selectedproduct == 'lw2knds')
  {
    if (!is_ec5(epocconnect.value))
    {
      alert('Warning:\n\nThe product you have selected requires EPOC Connect 5.0 (PsiWin 2.3 or Ericsson EPOC Connect 1.0).\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
    if (!is_er5(device.value) && !is_er3(device.value))
    {
      alert(er5list('Psion Series 5, '));
      reset(form);
      return;
    }
  }


  // ACT! Plugin for PsiWin 2.1
  if (selectedproduct == 'ACTPI')
  {
    if (isseries3(device.value))
    {
      alert('Warning:\n\nPsiWin 2.1 does not support the Psion Series 3x family of devices.');
      reset(form);
    }
    if (is_er5(device.value) || is_r380(device.value))
    {
      alert(devicesupport('Psion Series 5, 3x and Siena'));
      reset(form);
      return;
    }
    if (epocconnect.value != 'psi2.1')
    {
      alert(badecversion('PsiWin 2.1'));
      reset(form);
      return;
    }
  }


  // ACT! Plugin for PsiWin 2.2
  if (selectedproduct == 'ACTPI22')
  {
    if (is_er5(device.value) || is_r380(device.value))
    {
      alert(devicesupport('Psion Series 5, 3x and Siena'));
      reset(form);
      return;
    }
    if (epocconnect.value != 'psi2.2')
    {
      alert(badecversion('PsiWin 2.2'));
      reset(form);
      return;
    }
  }


  // LinkWise 2000 - Symantec ACT! Edition
  if (selectedproduct == 'ACTPI23')
  {
    if (!is_er5(device.value) && !is_er3(device.value))
    {
      alert(er5list('Psion Series 5, '));
      reset(form);
      return;
    }
    if (!is_ec5(epocconnect.value))
    {
      alert('Warning:\n\nThe product you have selected requires EPOC Connect 5.0 (PsiWin 2.3 or Ericsson EPOC Connect 1.0).\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }


  // eSync 4.1
  if (selectedproduct == 'eSync')
  {
    if ((epocconnect.value != 'psi2.1') && (epocconnect.value != 'psi2.2') && (!is_ec5(epocconnect.value)))
    {
      alert('Warning:\n\nThe product you have selected requires PsiWin 2.1 or higher (Including Ericsson EPOC Connect 1.0).\nYou may download PsiWin 2.1 from the Psion web site.');
      reset(form);
      return;
    }
    if (!is_er5(device.value) && !is_er3(device.value))
    {
      alert(er5list('Psion Series 5, '));
      reset(form);
      return;
    }
  }


  // eSync 2000 - Novell GroupWise Edition
  if (selectedproduct == 'eSync2kngw')
  {
    if (is_r380(device.value))
    {
      alert(er5list(''));
      reset(form);
      return;
    }
    if (!is_er5(device.value))
    {
      alert('Warning:\n\nNative email synchronization is not supported by your selected device.\nWe suggest that Psion Series 5 users download eSync 4.1.');
      reset(form);
      return;
    }
    if (!is_ec5(epocconnect.value))
    {
      alert('Warning:\n\nThe product you have selected requires EPOC Connect 5.0 (PsiWin 2.3 or Ericsson EPOC Connect 1.0).\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }


  // eSync 2000 - Eudora Pro Edition
  if (selectedproduct == 'eSync2kqep')
  {
    if (is_r380(device.value))
    {
      alert(er5list(''));
      reset(form);
      return;
    }
    if (!is_er5(device.value))
    {
      alert('Warning:\n\nNative email synchronization is not supported by your selected device.\nWe suggest that Psion Series 5 users download eSync 4.1.');
      reset(form);
      return;
    }
    if (!is_ec5(epocconnect.value))
    {
      alert('Warning:\n\nThe product you have selected requires EPOC Connect 5.0 (PsiWin 2.3 or Ericsson EPOC Connect 1.0).\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }


  // eSync Warehouse
  if ((selectedproduct == 'eswh-ou') || (selectedproduct == 'eswh-ngw'))
  {
    if (is_r380(device.value))
    {
      alert(er5list(''));
      reset(form);
      return;
    }
    if (!is_er5(device.value) && !is_er3(device.value))
    {
      alert(er5list('Psion Series 5, '));
      reset(form);
      return;
    }
    if (!is_ec5(epocconnect.value))
    {
      alert('Warning:\n\nThe product you have selected requires EPOC Connect 5.0 (PsiWin 2.3 or Ericsson EPOC Connect 1.0).\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }

  // LinkWise R380 - Novell GroupWise Edition
  if (selectedproduct == 'lwR380gw')
  {
    if (!is_r380(device.value))
    {
      alert('Warning:\n\nThis software will only work with the Ericsson R380 Smartphone.');
      reset(form);
      return;
    }
    if (epocconnect.value != 'ecs1.0')
    {
      alert('Warning:\n\nThe product you have selected requires Ericsson R380 Communications Suite 1.0.\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }

  // LinkWise R380 - ACT! Edition
  if (selectedproduct == 'lwR380act')
  {
    if (!is_r380(device.value))
    {
      alert('Warning:\n\nThis software will only work with the Ericsson R380 Smartphone.');
      reset(form);
      return;
    }
    if (epocconnect.value != 'ecs1.0')
    {
      alert('Warning:\n\nThe product you have selected requires the Ericsson R380 Communications Suite 1.0.\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }

  // LinkWise 9210 - Novell GroupWise Edition
  if (selectedproduct == 'lw9210gw')
  {
    if (!is_9210(device.value))
    {
      alert('Warning:\n\nThis software will only work with the Nokia 9210 Communicator.');
      reset(form);
      return;
    }
    if (epocconnect.value != 'pcsnc1.02')
    {
      alert('Warning:\n\nThe product you have selected requires the PC Suite for the Nokia 9210 Communicator 1.02.\nIt cannot be used with any other version of EPOC Connect.');
      reset(form);
      return;
    }
  }

}

