function getMoney(s)
{
  var c, d, i, m, n, p;

  n = s.length;
  m = 0;
  d = 0;
  p = -1;
  for (i = 0; i < n; ++i) {
    c = s.charCodeAt(i);
    if (c == 36) {
      if (i != 0) {
        return -1;
      }
    } else if (c == 46) {
      if (p == -1) {
        p = 0;
      } else {
        return -1;
      }
    } else if ((c >= 48) && (c <= 57)) {
      m = m * 10 + c - 48;
      d = 1;
      if (p != -1) {
        ++p;
      }
    } else {
      return -1;
    }
  }
  if ((d == 0) || (p > 2)) {
    return -1;
  } else if (p == 2) {
    return m;
  } else if (p == 1) {
    return m * 10;
  } else {
    return m * 100;
  }
}

function checkTeeShirtForm()
{
  var f;

  f = document.getElementById('TeeShirtForm');
  if (f.os0.value == 'none selected') {
    alert('Please choose a tee shirt size.');
    return false;
  }
  return true;
}

function checkTaxpayersAssociationForm()
{
  var f, g, q, s;

  f = document.getElementById('TaxpayersAssociationForm');
  s = f.amount.value;
  if (s == '') {
    alert('Please enter a dollar amount.');
    return false;
  }
  g = getMoney(s);
  if (g == -1) {
    alert('invalid dollar amount: ' + s);
    return false;
  }
  if ((g < 2500) || (g > 10000)) {
    alert('Please enter a dollar amount between 25 and 100.');
    return false;
  }
  if (g % 100 != 0) {
    alert('Please enter a whole dollar amount.');
    return false;
  }
  q = g / 100;
  if (q == 25) {
    f.item_name.value = 'GST Annual Dues - Taxpayers Association, 25 or less members';
  } else if (q == 100) {
    f.item_name.value = 'GST Annual Dues - Taxpayers Association, 100 or more members';
  } else {
    f.item_name.value = 'GST Annual Dues - Taxpayers Association, ' + q + ' members';
  }
  return true;
}

function checkAdditionalContributionFormA()
{
  var f;

  f = document.getElementById('AdditionalContributionFormA');
  if (f.amount.value == '0.00') {
    alert('Please choose a dollar amount.');
    return false;
  }
  return true;
}

function checkAdditionalContributionFormB()
{
  var f, g, s;

  f = document.getElementById('AdditionalContributionFormB');
  s = f.amount.value;
  if (s == '') {
    alert('Please enter a dollar amount.');
    return false;
  }
  g = getMoney(s);
  if (g == -1) {
    alert('invalid dollar amount: ' + s);
    return false;
  }
  if (g == 0) {
    alert('Please enter a dollar amount greater than 0.');
    return false;
  }
  return true;
}
