function openFrame(frName,anUrl) {
  for (i=0; i<parent.frames.length; i++) {
    if(frName==parent.frames[i].name) {
      parent.frames[i].location.href=anUrl;
      return true;
    }
  }
}

function checkForm1(aForm) {
  //AD:
  if(aForm.rSearch[0].checked) {
    if(aForm.tKeyword.value.length<3) {
      alert('To search Aerodrome,\n ICAO (4 letters code) or IATA (3 letters code)\n or Name or City (3 letters or more) required.');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  //NAVAID:
  else if(aForm.rSearch[1].checked) {
    if(aForm.tKeyword.value.length<2) {
      alert('To search Navigation Aid,\n NAVAID ID (2 letters or more) required.');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  //Route:
  else if(aForm.rSearch[2].checked) {
    if(aForm.tKeyword.value.length<2) {
      alert('To search Airway,\n Route/Point Name (2 letters or more) required.');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  //Airspace:
  else if(aForm.rSearch[3].checked) {
    if(aForm.tKeyword.value.length<3) {
      alert('To search Airspace,\n Name (3 letters or more) required.');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  //Permit:
  else if(aForm.rSearch[4].checked) {
    if(aForm.tKeyword.value.length<3) {
      alert('To search Country Permit,\n Country Name (3 letters or more) required.');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  //NOTAM:
  else if(aForm.rSearch[5].checked) {
    if(aForm.tKeyword.value.length<4) {
      alert('To search NOTAM,\n One or more ICAOs (4 letters code) required, separated by comma (,).');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  //Weather
  else if(aForm.rSearch[6].checked) {
    if(aForm.tKeyword.value.length!=4) {
      alert('To search Weather,\n ICAO (4 letters code) required.');
      aForm.tKeyword.focus();
      aForm.tKeyword.select();
      return false;
    }
  }
  return true;
}

function checkForm2(aForm) {
  if(aForm.req_username.value.length<1) {
    alert('user name required.');
    aForm.req_username.focus();
    return false;
  }
  if(aForm.req_password.value.length<1) {
    alert('password required.');
    aForm.req_password.focus();
    return false;
  }
  return true;
}

function checkForm3(aForm) {
  if((aForm.tDep.value.length<3)||(aForm.tDep.value.length>4)) {
    alert('ICAO (4 letters code) or IATA (3 letters code) for Departure required.');
    aForm.tDep.focus();
    return false;
  }
  if((aForm.tArr.value.length<3)||(aForm.tArr.value.length>4)) {
    alert('ICAO (4 letters code) or IATA (3 letters code) for Arrival required.');
    aForm.tArr.focus();
    return false;
  }
  return true;
}

function showList(qry) {
  if(qry==undefined) qry='';
  fmSearch.tKeyword.value="";
  var anUrl='poplist.php?frm=fmSearch&obj=tKeyword';
  var wX=event.x-10-390;
  if(wX<10) wX=10;
  //AD:
  if(fmSearch.rSearch[0].checked) anUrl+='&tbl=ad_2_01&ret=ICAO,IATA,name,city&fld=country&q='+qry;
  //NAVAID:
  else if(fmSearch.rSearch[1].checked) anUrl+='&tbl=ad_2_19&ret=identification&fld=ICAO,RNAV_type,frequency';
  //Route:
  else if(fmSearch.rSearch[2].checked) anUrl+='&tbl=enr_3&ret=name&fld=&fld=COUNT(point)+AS+points&q=name%21%3D%27%27+GROUP+BY+name';
  //Airspace:
  else if(fmSearch.rSearch[3].checked) anUrl+='&tbl=ad_2_17&ret=name&fld=ICAO,designation,airspace_class,call_sign';
  //Permit:
  else if(fmSearch.rSearch[4].checked) anUrl+='&tbl=dict_country&ret=name&fld=code';
  //NOTAM:
  else if(fmSearch.rSearch[5].checked) anUrl+='&tbl=ad_2_01&ret=ICAO&fld=IATA,city,name&mul=1&q='+qry;
  //Weather:
  else if(fmSearch.rSearch[6].checked) anUrl+='&tbl=ad_2_01&ret=ICAO&fld=IATA,city,name&q='+qry;

  var pop=window.open(anUrl,'list','toolbar=no,location=no,directories=no,status=yes,'
  +'menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=390,height=640,top=80,left='+wX);
  try {pop.focus();}
  catch(e) {throw e;}
}

function showList2(tObj,optMul) {
  fmSearch.tKeyword.value="";
  var anUrl='poplist.php?frm=fmFltPlan&obj='+tObj+'&tbl=ad_2_01&ret=ICAO,IATA&fld=city,name&mul='+optMul+'&ns=1';
  var wX=event.x-10-390;
  if(wX<10) wX=10;
  var pop=window.open(anUrl,'list','toolbar=no,location=no,directories=no,status=yes,'
  +'menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=390,height=640,top=80,left='+wX);
  try {pop.focus();}
  catch(e) {throw e;}
}