function af() {
  // work around apparent bug in windows mobile 6 IE
  if (document.forms) {
    document.forms['af_form'].elements['autofocus'].focus()
  } else if (document.getElementById) {
    document.getElementById('autofocus').focus();
  } else if (document.all) {
    document.all['autofocus'].focus();
  }
}

/**
 * If the keypress is Enter, blocks the form submission and redirects focus.
 * Otherwise, does nothing.
 *
 * Use: onKeyPress="return disableEnterKey(event)"
 * Use: onKeyPress="return disableEnterKey(event, 'btnG')"
 * @param e the event
 * @param focusInstead the id or name of the element to focus
 */
function disableEnterKey(e, focusInstead)
{
  var key, el;

  if (window.event)
    key = window.event.keyCode;
  else if (e.which)
    key = e.which;
  else
    key = 0;
  if (key != 13) {
    return true;
  }

  if (document.getElementById) {
    el = document.getElementById(focusInstead);
    if (el) {
      el.focus();
      return false;
    }
  }

  if (document.getElementsByName) {
    el = document.getElementsByName(focusInstead);
    if (el && el.length > 0) {
      el[0].focus();
      return false;
    }
  }

  return false;
}

