// Current month anchor already found and output
var currentMonthSeen=false;

// Current gig for prog already found and anchor output
var currentProgSeen=new Array();

// string-comparable date representation of 'now'
var now = new Date();
var nownum = '' + now.getFullYear() + '-' + TwoDig(now.getMonth()+1) + '-' +
 TwoDig(now.getDate()) + ' ' + TwoDig(now.getHours()) + ':' +
 TwoDig(now.getMinutes()) + ':' + TwoDig(now.getSeconds());
var nowMonth = '' + now.getFullYear() + '-' + TwoDig(now.getMonth()+1);

// Return a string from number 'num', padded with a zero if less than 10
function TwoDig( num)
{
 if (num < 10)
  return '0' + num;
 else
  return num;
}

// Check whether the month in the arguments is the currently interesting
// month and output an anchor, if it is
function MR_TellCurrentMonth( month)
{
 if (currentMonthSeen)
  // Current month passed
  return;
 if (month < nowMonth)
  // This month is too far back
  return;
 // This is the current month.
 document.write( '<a name="CurrentMonth"></a>');
 currentMonthSeen = true;
}

// Check whether this is the next date this program will be shown
// and output an anchor, if it is
function MR_TellCurrentProg( datenum, prog)
{
 if (currentProgSeen[prog])
  // Anchor for 'prog' already output
  return;
 if (datenum < nownum)
  // This date lies in the past
  return;
 // Output anchor for this program
 document.write( '<a name="' + prog + '"></a>');
 currentProgSeen[prog] = true;
}

