function selectGnisRow(data) {
  if (checkInstr('gnis_instr')) {
    var instr = '&';
    var f = document.forms['gnis_instr'];
    for (i=0; i<f.elements.length; i++) {
      el = f.elements[i];
      if ((el.type == 'checkbox') && el.checked && (el.name.substr(0, 6) == 'instr_')) instr += el.name + '=' + el.value + '&';
    }
    instr = instr.substr(0, instr.length - 1);
    var row = data.split(':');
    window.location = 'results.phtml?searchtype=coords&x=' + row[5] + '&y=' + row[4] + instr;
  }
}
function validateCoords() {
  var re = /^(-)?(\d+)(\.?)(\d*)$/;
  if (!(document.searchcoords.x.value.match(re) && document.searchcoords.y.value.match(re))) {
    alert('Both latitude and longitude must be numbers.');
    return false;
  }
  return checkInstr('searchcoords');
}
function validateWrs() {
  var f = document.forms['searchwrs'];
  var re = /^\d+$/;
  if (!(f.path.value.match(re) && f.row.value.match(re))) {
    alert('Both path and row must be integers.');
    return false;
  } else return true;
}
function checkInstr(form_name) {
  theForm = document.forms[form_name];
  for (e=0;e<theForm.elements.length;e++) {
    ele = theForm.elements[e];
    if ((ele.type=='checkbox') && (ele.checked) && (ele.name.substr(0, 6) == 'instr_')) return true;
  }
  alert('You must select at least one type of imagery to search for.');
  return false;
}
