function doG1SSTCheck()
{
  //alert('doG1SSTCheck()');
  var year  = document.pwsform.selectedYear.value;
  var month = document.pwsform.selectedMonth.value;
  var day   = document.pwsform.selectedDay.value;
  var datestr = '' + year + month.pad(2,"0",2) + day.pad(2,"0",2);
  //SST_20090511_blended_Global.png
  var iname = 'http://sst.jpl.nasa.gov/myocean/PWS/images/SST/' + datestr + '/blended_' + datestr + '_masked.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=\"blue12\">Sea Surface Temperature</td></tr>";
  text += "<tr><td class=\"comment\"><p style='text-align:justify'>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="ROMS" onClick="doSSTDisplay(this,\'sst0\')">ROMS';
  text += '<input type="checkbox" id="sstbox1" value="blended" onClick="doSSTDisplay(this,\'sst1\')">Blended';
  text += '&nbsp;<input type="checkbox" id="sstbox2" value="GOES" onClick="doSSTDisplay(this,\'sst2\')">GOES 11+12';
  text += '&nbsp;<input type="checkbox" id="sstbox3" value="SEVIRI" onClick="doSSTDisplay(this,\'sst3\')">SEVIRI-E';
  text += '&nbsp;<input type="checkbox" id="sstbox4" value="TMI" onClick="doSSTDisplay(this,\'sst4\')">TMI+AMSRE';
  text += '&nbsp;<input type="checkbox" id="sstbox5" value="MODIS" onClick="doSSTDisplay(this,\'sst5\')">MODIS';
  text += '&nbsp;<input type="checkbox" id="sstbox6" value="AVHRR" onClick="doSSTDisplay(this,\'sst6\')">AVHRR';
  text += '&nbsp;<input type="checkbox" id="sstbox7" value="AATSR" onClick="doSSTDisplay(this,\'sst7\')">AATSR';
  text += '&nbsp;<input type="checkbox" id="sstbox8" value="InSitu" onClick="doSSTDisplay(this,\'sst8\')">In-Situ';
  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 += '<tr>';
  text += '<td id="sst7"></td>';
  text += '</tr>';
  text += '<tr>';
  text += '<td id="sst8"></td>';
  text += '</tr>';
  text += '</table>';
  text += '</td>';
  text += '</tr>';
  text += '</table>';
  text += '</td>';
  text += '</tr>';
  text += '</table>';
  setInnerHTML('content', text);
  setVisible('content','visible');
  //alert('doG1SST():: text = ' + text);

  var doc = document.getElementById("sstbox0");
  doc.checked = true;
  doSSTDisplay(doc,'sst0');
  doc = document.getElementById("sstbox1");
  doc.checked = true;
  doSSTDisplay(doc,'sst1');
}

function doSSTDisplay(what, divname)
{
  //alert('doSSTDisplay()::what.value = ' + what.value + '; divname = ' + divname);
  var s = '';
  var year  = document.pwsform.selectedYear.value;
  var month = document.pwsform.selectedMonth.value;
  var day   = document.pwsform.selectedDay.value;
  var datestr = '' + year + month.pad(2,"0",2) + day.pad(2,"0",2);
  var romsstr = '' + month.pad(2,"0",2) + day.pad(2,"0",2);
  var iname = '<image src="http://sst.jpl.nasa.gov/myocean/PWS/images/SST/' + datestr + '/';
  var romsname = '<image src="http://sst.jpl.nasa.gov/myocean/PWS/data/images/sst/' + year + '/';
  var val = what.value;
  if (what.checked)
  {
    if (val == "ROMS")
      s =  romsname + 'pws_sst' + romsstr + '.jpg" border="1" width="560">';
    else if (val == "blended")
      s =  iname + 'blended_' + datestr + '_masked.png" border="1">';
    if (val == "GOES")
      s =  iname + 'GOES_' + datestr + '.png" border="1">';
    else if (val == "SEVIRI")
      s =  iname + 'SEVIRI_' + datestr + '.png" border="1">';
    else if (val == "TMI")
      s =  iname + 'TMI_AMSRE_' + datestr + '.png" border="1">';
    else if (val == "MODIS")
      s =  iname + 'MODIS_' + datestr + '.png" border="1">';
    else if (val == "AVHRR")
      s =  iname + 'AVHRR_' + datestr + '.png" border="1">';
    else if (val == "AATSR")
      s =  iname + 'ATS_NR_' + datestr + '.png" border="1">';
    else if (val == "InSitu")
      s =  iname + 'SHIP_' + datestr + '.png" border="1">';
    else if (val == "All")
    {
      for (var i=0; i<=8; 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<=8; 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.pwsform.selectedYear.value;
  var month = document.pwsform.selectedMonth.value;
  var day   = document.pwsform.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);
}

