function doG1SSTCheck()
{
  //alert('doG1SSTCheck()');
  var year  = document.scbform.selectedYear.value;
  var month = document.scbform.selectedMonth.value;
  var day   = document.scbform.selectedDay.value;
  var datestr = '' + year + month.pad(2,"0",2) + day.pad(2,"0",2);
  var iname = 'http://sst.jpl.nasa.gov/myocean/SCB/images/SST/' + datestr + '/GOES_' + datestr + '.png';
  //alert('doG1SSTCheck():: iname = ' + iname);
  myNewImage = new Image();
  myNewImage.onerror = noG1SST;
  myNewImage.onload  = doG1SST;
  myNewImage.src = iname;
}

function doG1SST()
{
  //alert('doG1SST()');
  var text = "<table><tr><td class=\"bluebold14\">Sea Surface Temperature</td></tr>";
  text += "<tr><td class=\"comment\"><p style='text-align:justify'><br>A daily, global Sea Surface Temperature (SST) data set is produced at 1-km (also known as ultra-high resolution) by the JPL ROMS (Regional Ocean Modeling System) group.  The input SST data sets are derived from the Global High-Resolution Sea Surface Temperature (SST) Pilot Project (GHRSST-PP).  More descriptions of the SST input data and the blending algorithm can be find <a href=\"javascript:void(null);\" onclick=\"doInfo()\">here</a>.<br></p></td></tr></table>";
  //alert('doG1SST():: text = ' + text);
  setInnerHTML('description', text);

  text = '<table width="100%" cellspacing="0" cellpadding="0" border="0">';
  text += '<tr>';
  text += '<td>';
  text += '<table>';
  text += '<tr>';
  text += '<td class="bold10" nowrap>';
  text += '<input type="checkbox" id="sstbox0" value="blended" onClick="doSSTDisplay(this,\'sst0\')">Blended';
  text += '&nbsp;<input type="checkbox" id="sstbox1" value="GOES" onClick="doSSTDisplay(this,\'sst1\')">GOES 11+12';
  text += '&nbsp;<input type="checkbox" id="sstbox2" value="AMSR" onClick="doSSTDisplay(this,\'sst2\')">AMSR-E';
  text += '&nbsp;<input type="checkbox" id="sstbox3" value="TMI" onClick="doSSTDisplay(this,\'sst3\')">TMI';
  text += '&nbsp;<input type="checkbox" id="sstbox4" value="AVHRR" onClick="doSSTDisplay(this,\'sst4\')">AVHRR 17+18';
  text += '&nbsp;<input type="checkbox" id="sstbox5" value="MODISA4" onClick="doSSTDisplay(this,\'sst5\')">MODIS 4A+T4';
  text += '&nbsp;<input type="checkbox" id="sstbox6" value="MODIS" onClick="doSSTDisplay(this,\'sst6\')">MODIS A+T';
  text += '&nbsp;<input type="checkbox" id="sstall" value="All" onClick="doSSTDisplay(this,\'\')">All';
  text += '&nbsp;<input type="checkbox" id="sstnone" value="None" onClick="doSSTDisplay(this,\'\')">None';
  text += '</td>';
  text += '</tr>';
  text += '</table>';
  text += '</td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td>';
  text += '<table border="0">';
  text += '<tr>';
  text += '<td>';
  text += '<table>';
  text += '<tr>';
  text += '<td id="sst0"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst1"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst2"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst3"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst4"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst5"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst6"></td>';
  text += '</tr>';
  text += '</table>';
  text += '</td>';
  text += '</tr>';
  text += '</table>';
  text += '</td>';
  text += '</tr>';
  text += '</table>';
  //alert('doG1SST():: text = ' + text);
  setInnerHTML('mycontent', text);

  var doc = document.getElementById("sstall");
  doc.checked = true;
  doSSTDisplay(doc,'');
}

function doSSTDisplay(what, divname)
{
  //alert('doSSTDisplay()::what.value = ' + what.value);
  var s = '';
  var year  = document.scbform.selectedYear.value;
  var month = document.scbform.selectedMonth.value;
  var day   = document.scbform.selectedDay.value;
  var datestr = '' + year + month.pad(2,"0",2) + day.pad(2,"0",2);
  var iname = '<image src="http://sst.jpl.nasa.gov/myocean/SCB/images/SST/' + datestr + '/';
  var val = what.value;
  if (what.checked)
  {
    if (val == "blended")
      s =  iname + 'blended_' + datestr + '.png" border="1">';
    if (val == "GOES")
      s =  iname + 'GOES_' + datestr + '.png" border="1">';
    else if (val == "AMSR")
      s =  iname + 'AMSRE_' + datestr + '.png" border="1">';
    else if (val == "TMI")
      s =  iname + 'TMI_' + datestr + '.png" border="1">';
    else if (val == "AVHRR")
      s =  iname + 'AVHRR_' + datestr + '.png" border="1">';
    else if (val == "MODISA4")
      s =  iname + 'MODIS4_' + datestr + '.png" border="1">';
    else if (val == "MODIS")
      s =  iname + 'MODIS_' + datestr + '.png" border="1">';
    else if (val == "All")
    {
      for (var i=0; i<=6; i++)
      {
        var doc = document.getElementById("sstbox"+i);
	doc.checked = true;
        //document.getElementById("sstbox"+i).checked = true;  
        doSSTDisplay(doc,'sst'+i)
      }
      document.getElementById("sstnone").checked = false;  
      document.getElementById("sstall").checked = true;  
    }
    else if (val == "None")
    {
      for (var i=0; i<=6; i++)
      {
        var doc = document.getElementById("sstbox"+i);
	doc.checked = false;
        //var doc = document.getElementById("sstbox"+i).checked = false;
        doSSTDisplay(doc,'sst'+i)
      }
      document.getElementById("sstall").checked = false;  
      document.getElementById("sstnone").checked = true;  
    }
  }
  else
  {
  }
  //alert(s);
  if (val != "All" && val != "None")
  {
    document.getElementById(divname).innerHTML = s;
    document.getElementById("sstall").checked = false;  
    document.getElementById("sstnone").checked = false;  
  }
}

function noG1SST()
{
  //alert('noG1SST()');
  var year  = document.scbform.selectedYear.value;
  var month = document.scbform.selectedMonth.value;
  var day   = document.scbform.selectedDay.value;
  var datestr = month.pad(2, "0", 0) + "/" + day.pad(2,"0", 2) + "/" + year;
  var tablehtml = "<table>";
  tablehtml += "<tr>";
  tablehtml += "<td class=\"bluebold14\" align='center'>Sorry, no data found for the selected date.</td>";
  tablehtml += "</tr>";
  tablehtml += "<tr>";
  tablehtml += "<td class=\"bluebold14\" align='center'>" + datestr + "</td>";
  tablehtml += "</tr>";
  //alert('tablehtml = [' + tablehtml + ']');
  tablehtml += "</table>";
  setInnerHTML('clicknote', tablehtml);
}

/* function doInfo()
{
  var url = 'introduction.html';
  var infopopWindow=open(url,'infopopWindow','scrollbars=yes,esizable=yes,width=500,height=400');
  infopopWindow.focus();
} */


