function onlandCheckHandler()
{   
  //alert('onlandCheckHandler');
  // Make sure the request is loaded (readyState = 4)
  if (req.readyState == 4)
  {
    // Make sure the status is "OK"
    if (req.status == 200)
    {
      var notes = req.responseXML.getElementsByTagName('note');
      //alert('selectDateHandler(): 200 - notes.length = ' + notes.length);
      var noteNode = notes.item(0);
      onland = noteNode.firstChild.nodeValue;
      //alert('onland = ' + onland);
      if (onland == "0")
      {
        //alert('The selected location is OK');
        noteNode = notes.item(1);
        lat = noteNode.firstChild.nodeValue-0;
        noteNode = notes.item(2);
        lon = noteNode.firstChild.nodeValue-0;
        //alert('showTideSubImage() - lat=' + lat + ';lon=' + lon);
        i = document.pwsform.selectedi.value-0;
        j = document.pwsform.selectedj.value-0;
        showSelectionTideLocation(i, j, lat, lon);
      }
      else
      {
        alert('The selected location is on land');
      }
    }
  }
}

function showSelectionTideLocation(i, j, lat, lon)
{
  //alert('showSelectionTideLocation() - i=' + i + ' & j = ' + j + ' ; lat = ' + lat + ' & lon = ' + lon);
  year  = document.pwsform.selectedYear.value;
  month = document.pwsform.selectedMonth.value;
  day   = document.pwsform.selectedDay.value;
  option = "year=" + year + "&month=" + month + "&day=" + day + "&x=" + j + "&y=" + i;
  //alert('showSelectionTideLocation():: option = ' + option);
  setWait(true);
  xmlPost('/PWS/servlet/PlotTideLocation', option, plotTideLocationHandler);
}

function plotTideLocationHandler()
{
  //alert('plotTideLocationHandler');
  // Make sure the request is loaded (readyState = 4)
  if (req.readyState == 4)
  {
    // Make sure the status is "OK"
    if (req.status == 200)
    {
      setWait(false);
      var notes = req.responseXML.getElementsByTagName('note');
      //alert('selectDateHandler(): 200 - notes.length = ' + notes.length);
      var noteNode = notes.item(0);
      filename = noteNode.firstChild.nodeValue;
      //alert('filename = ' + filename);
      if (filename != "error")
      {
        filename = '/myocean/PWS/data/images/tide/output/' + filename + '.jpg';
        //alert('filename = ' + filename);
        showSubImage(filename, 'visible');
      }
      else
      {
        alert('Can not get info from the selected location');
      }
    }
  }
}

