/**
 * Sets focus to first field on page
 */
function focusFirstField() {
  try {
    for (var f = 0; f < document.forms.length; f++) {
      var form = document.forms[f];
      for (var i = 0; i < form.length; i++) {
        var field = form[i];
        if (field.type != "hidden" && !field.disabled) {
          field.focus();
          return;
        }
      }
    }
  } catch (e) {
    // do nothing
  }
}

/**
 * Turns every other row white.  Assumes the table color is
 * initially set to the non-white color.
 */
function stripeTables() {
  var tables = document.getElementsByTagName("table");
  for (var i = 0; i < tables.length; i++) {
    if (tables[i].parentNode.className == "stripeTable") {
      table = tables[i];
      for (var j = 1; j < table.rows.length; j++) {
        if (j % 2 == 0) {
          table.rows[j].style.backgroundColor = "white";
        }
      }
    }
  }
}

function selectTown(pic) {
  newpic = "/images/map/glow/" + pic;
  document.worldmap.image.value = newpic;
  document.worldmap.pic.src = newpic;
}
