// Loop through all divs of class "new"
// Each should have an id of the form YYMML, representing creation date
// Place the text "New!" within only those divs representing "new" pieces
// Newnewss is defined by oldWhenOlderThanDays.
function markNew() {
  var oldWhenOlderThanDays = 365;
  var divId;
  var divDate;
  var yy;
  var mm;
  var thresholdDate = new Date();
  thresholdDate.setDate(thresholdDate.getDate()-oldWhenOlderThanDays);

  var newDivs = getElementsByClassName('new', 'div');
  for ( var ii=0; ii<newDivs.length; ii++ ) {
    divId = newDivs[ii].id;
    divId = divId.substr(0,4);

    divDate = new Date();
    if ( divId.substr(0,1) == "0" ) {
      yy = 2000+parseInt(divId.substr(1,1));
    } else {
      yy = 2000+parseInt(divId.substr(0,2));
    }
    if ( divId.substr(2,1) == "0" ) {
      mm = parseInt(divId.substr(3,1))-1;
    } else {
      mm = parseInt(divId.substr(2,2))-1;
    }
    divDate.setFullYear(yy, mm, 1);
    if ( divDate > thresholdDate ) {
        newDivs[ii].innerHTML = "New!";
    }
  }
}
