
// writes technote table to the page  
function buildSortedTechnoteTable (data) {
  var months = ["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];
  var notes = new Array();
  var j = 0;

  // Strip out TechNote instances, put them into notes array.
  for (var i = data.length; --i >=0; ) {
    if (data[i].constructor == TechNote) {
      notes[j++] = data[i];
    }
  }

  // Sort notes array by date.
  notes.sort(chronSortTechnotes);

  // Write table
  document.write('<A HREF="index.html?sort=category">by category</A> | by date<BR><BR>');
  var table = '<TABLE BORDER="0" CELLPADDING=0 cellspacing=0>'
  for (var i = 0; i < notes.length; i++) {
    table += '<TR><TD valign="top">'
          +  '<img src="../images/bullet-star.gif" width="12" height="12" alt="*" border="0">'
          +  '</TD><TD valign="top">'
          +  months[notes[i].dateadded.getMonth()] + "."
          +  notes[i].dateadded.getDate() + "."
          +  notes[i].dateadded.getFullYear() + "<BR>"
          + '<a href="' +  notes[i].folder + '">' + notes[i].name + '</a></TD></TR>';
  }
  table += '</table>';
  document.write(table);

  // Custom chronological sort function.
  function chronSortTechnotes (tn1, tn2) {
    return tn2.dateadded.getTime() - tn1.dateadded.getTime();
  }

  return data;

}


