function gDisableFormControls(roForm, vbDisable)
{
  for (var i = 0; i < roForm.elements.length; i++)
  {
    if (roForm.elements[i].type != 'hidden')
      roForm.elements[i].disabled = vbDisable;
  }
}

function gbTestContent(vbShow, roSource, vsName)
{
  //validate the content of roSource has content
  //show an alert message if necessary

  var lbTest = (roSource.value != '');

  return gbTestShowMessage(vbShow, roSource, vsName, lbTest, '');
}

function gbTestEMail(vbShow, roSource, vsName)
{
  //validate the content of roSource as an email address (xx@xx.xx)
  //show an alert message if necessary

  var lbTest = false;
  var lsValue = new String(roSource.value);

  //check for valid email address formatting characters
  lbTest = (lsValue.indexOf('@') > 0);
  if (lbTest)
    lbTest = ((lsValue.indexOf('.') > 2) && (lsValue.lastIndexOf('.') != lsValue.length - 1));

  return gbTestShowMessage(vbShow, roSource, vsName, lbTest, '');
}

function gbTestSelected(vbShow, roSource, vsName)
{
  //validate that roSource (select) has a selection
  //show an alert message if necessary

  var lbTest = false;
  var liIndex = roSource.selectedIndex;
  var lsValue = '';

  if (liIndex >= 0)
  {
    lsValue = roSource.options[liIndex].value;
    if (lsValue != '')
      lbTest = true;
  }

  return gbTestShowMessage(vbShow, roSource, vsName, lbTest, 'must have a selection');
}

function gbTestShowMessage(vbShow, roSource, vsName, vbTest, vsMessage)
{
  roSource.style.color = '';

  if (!vbTest)
  {
    roSource.style.color = 'red';
    if (vbShow)
      if (!roSource.disabled)
      {
        if (vsMessage == '')
          alert('Invalid ' + vsName + '.');
        else
          alert(vsName + ' ' + vsMessage + '.');
        roSource.focus();
      }
    return false;
  }
  return true;
}

