$theYear = nuDateFormat($theDay, 'Y');
$theMonth = nuDateFormat($theDay, 'm');
$lastYear = nuDateAddDays("{$theYear}-{$theMonth}-01", -360);
$lastMonth = nuDateAddDays("{$theYear}-{$theMonth}-01", -2);
$nextYear = nuDateAddDays("{$theYear}-{$theMonth}-01", 370);
$nextMonth = nuDateAddDays("{$theYear}-{$theMonth}-01", 32);
print "   </tr>\n";
print "   <tr>\n";
print "        <td colspan='2' id='m1' onclick='reload({$dq}" . nuDateFormat($lastMonth, $returnDateFormat6) . "{$dq})' onmouseover='MIN(this)' onmouseout='MOUT(this)' align='center' style='background-color:lightgrey' >" . nuDateFormat($lastMonth, 'M') . "</td>\n";
print "        <td colspan='3' align='center'><b>" . nuDateFormat($theDay, 'M') . "</b></td>\n";
print "        <td colspan='2' id='m2' onclick='reload({$dq}" . nuDateFormat($nextMonth, $returnDateFormat6) . "{$dq})' onmouseover='MIN(this)' onmouseout='MOUT(this)' align='center' style='background-color:lightgrey' >" . nuDateFormat($nextMonth, 'M') . "</td>\n";
print "   </tr>\n";
print "   <tr>\n";
print "        <td colspan='2' id='y1' onclick='reload({$dq}" . nuDateFormat($lastYear, $returnDateFormat6) . "{$dq})' onmouseover='MIN(this)' onmouseout='MOUT(this)' align='center' style='background-color:lightgrey' >" . nuDateFormat($lastYear, 'Y') . "</td>\n";
print "        <td colspan='3' align='center'><b>" . nuDateFormat($theDay, 'Y') . "</b></td>\n";
print "        <td colspan='2' id='y2' onclick='reload({$dq}" . nuDateFormat($nextYear, $returnDateFormat6) . "{$dq})' onmouseover='MIN(this)' onmouseout='MOUT(this)' align='center' style='background-color:lightgrey' >" . nuDateFormat($nextYear, 'Y') . "</td>\n";
print "   </tr>\n";
print "<table>\n";
$s = "function MIN(pthis){//---mouse over menu\n";
$s = $s . "      document.getElementById(pthis.id).style.backgroundColor='gray';\n";
$s = $s . "}\n\n";
$s = $s . "function reload(pvalue){//---reload calendar\n";
$s = $s . "      document.forms[0].action='calendar.php?theFormat={$theFormat}&dir={$dir}&theDay='+pvalue+'&target={$target}';\n";
$s = $s . "      document.forms[0].submit();\n";
$s = $s . "}\n\n";
$s = $s . "function pick(pvalue){//---select date\n";
$s = $s . "      if(pvalue==''){return;}\n";
if ($target == '') {
    $s = $s . "      alert('no target was specified in URL');\n";
} else {
    //----next bit (setAttribute) worked in ie but not ff
function formatTextValue($pValue, $pFormatNumber)
{
    if ($pFormatNumber == '') {
        return $pValue;
    }
    $format = textFormatsArray();
    if ($format[$pFormatNumber]->type == 'number') {
        if ($pValue == '') {
            return '';
        } else {
            return number_format($pValue, $format[$pFormatNumber]->format, $format[$pFormatNumber]->decimal, $format[$pFormatNumber]->separator);
        }
    }
    if ($format[$pFormatNumber]->type == 'date') {
        if ($pValue == '' or $pValue == '0000-00-00') {
            return '';
        } else {
            return nuDateFormat($pValue, $format[$pFormatNumber]->phpdate);
        }
    }
    return $pValue;
}