<? 

require("calendar-functions.php3");
 /* commonHeader("Calendar for $month/$year");  */
commonHeader("Calendrier COSNAZ pour $month/$year");

if (empty($year))
	$year=date("Y");
if (empty($month))
	$month=date("m");

/*  Reset some variables  */
$date=01;
$day=01;
$off=0;

/*  Figure out how many days are in this month  */
while (checkdate($month,$date,$year)):
$date++;
endwhile;

/*  Figure out what month it is, convert the number to words, and then create 
    a table with days of the week headers  */
echo "<center><h2><font face='Arial' color='blue'>";
$curMonth="";
if ($month == '01') {
$curMonth=$strJanuary;
echo "$strJanuary, $year";
} elseif ($month == '02') {
$curMonth=$strFebruary;
echo "$strFebruary, $year";
} elseif ($month == '03') {
$curMonth=$strMarch;
echo "$strMarch, $year";
} elseif ($month == '04') {
$curMonth=$strApril;
echo "$strApril, $year";
} elseif ($month == '05') {
$curMonth=$strMay;
echo "$strMay, $year";
} elseif ($month == '06') {
$curMonth=$strJune;
echo "$strJune, $year";
} elseif ($month == '07') {
$curMonth=$strJuly;
echo "$strJuly, $year";
} elseif ($month == '08') {
$curMonth=$strAugust;
echo "$strAugust, $year";
} elseif ($month == '09') {
$curMonth=$strSeptember;
echo "$strSeptember, $year";
} elseif ($month == '10') {
$curMonth=$strOctober;
echo "$strOctober, $year";
} elseif ($month == '11') {
$curMonth=$strNovember;
echo "$strNovember, $year";
} else {
$curMonth=$strDecember;
echo "$strDecember, $year";
}
echo "</font></h2></center><br><br>";

echo "<table border='1' cellpaddig='5' cellspacing='5' width='100%'><tr>";
echo "<th><b><font face='Arial' color='blue'>$strSunday</font></b></th>";
echo "<th><b><font face='Arial' color='blue'>$strMonday</font></b></th>";
echo "<th><b><font face='Arial' color='blue'>$strTuesday</font></b></th>";
echo "<th><b><font face='Arial' color='blue'>$strWednesday</font></b></th>";
echo "<th><b><font face='Arial' color='blue'>$strThursday</font></b></th>";
echo "<th><b><font face='Arial' color='blue'>$strFriday</font></b></th>";
echo "<th><b><font face='Arial' color='blue'>$strSaturday</font></b></th>";
/*B.S.*/
echo "</tr>";

/*  Start the table data and make sure the number of days does not exceed
    the total for the month  - $date will always be one more than the total
    number of days in the momth  */
echo "<tr>";
while ($day<$date):

/*  Figure what day of the week the first falls on and set the number of 
    preceding and trailing cells accordingly  */
if ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Sunday') {
echo "<td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off = '01';
} 
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Monday') {
echo "<td></td><td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off= '02';
} 
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Tuesday') {
echo "<td></td><td></td><td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off= '03';
} 
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Wednesday') {
echo "<td></td><td></td><td></td><td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off= '04';
} 
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Thursday') {
echo "<td></td><td></td><td></td><td></td><td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off= '05';
} 
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Friday') {
echo "<td></td><td></td><td></td><td></td><td></td><td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off= '06';
} 
elseif ($day =='01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Saturday') {
echo "<td></td><td></td><td></td><td></td><td></td><td></td><td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
$off= '07';
} 
else {
echo "<td valign='top' height='100' width='100'><font face='Arial' color='red'>$day</font></td>";
}

/*  Increment the day and the cells to go before the end of the row and end the
    row when appropriate */
$day++;
$off++;

if ($off>7) {
/* add </tr> B.S. */
echo "</tr><tr>";
$off='01';
} else {
echo "";
}

endwhile;


echo "</table>";


echo "<br>";
$lm = $month - 1;
$ly = $year - 1;
if ($month == '01') {
echo "<font face='Arial'><a href='simpleCalendar.php3?month=12&year=$ly'>$strViewPMonth</a></font>";
} elseif ($month > 1 AND $month < 11) { 
echo "<font face='Arial'><a href='simpleCalendar.php3?month=0$lm&year=$year'>$strViewPMonth</a></font>";
} else {
echo "<font face='Arial'><a href='simpleCalendar.php3?month=$lm&year=$year'>$strViewPMonth </a></font>";
}

echo "&nbsp;&nbsp;&nbsp;";

$nm = $month + 1;
$ny = $year + 1;
if ($month == '12') {
echo "<font face='Arial'><a href='simpleCalendar.php3?month=01&year=$ny'>$strViewNMonth</a></font>";
} elseif ($month >= 1 AND $month <= 8) {
echo "<font face='Arial'><a href='simpleCalendar.php3?month=0$nm&year=$year'>$strViewNMonth</a></font>";
} else {
echo "<font face='Arial'><a href='simpleCalendar.php3?month=$nm&year=$year'>$strViewNMonth</a></font>";
}

echo "&nbsp;&nbsp;&nbsp;";

$NumMonth =date("m");
$NameMonth=date("F");
$NumYear  =date("Y");
echo "<form action='simpleCalendar.php3' method='post'>";
echo "<select name='month'>";
echo "<option value='$NumMonth'> $curMonth </option>";
echo "<option value='$NumMonth'> ---------- </option>";
echo "<option value='01'> $strJanuary </option>";
echo "<option value='02'> $strFebruary </option>";
echo "<option value='03'> $strMarch </option>";
echo "<option value='04'> $strApril </option>";
echo "<option value='05'> $strMay </option>";
echo "<option value='06'> $strJune </option>";
echo "<option value='07'> $strJuly </option>";
echo "<option value='08'> $strAugust </option>";
echo "<option value='09'> $strSeptember </option>";
echo "<option value='10'> $strOctober </option>";
echo "<option value='11'> $strNovember </option>";
echo "<option value='12'> $strDecember </option>";
echo "</select>";

echo "&nbsp;&nbsp;&nbsp;";
echo "<select name='year'>";
echo "<option value='$NumYear'> $NumYear </option>";
echo "<option value='$NumYear'> ---------- </option>";
echo "<option value='1998'> 1998 </option>";
echo "<option value='1999'> 1999 </option>";
echo "<option value='2000'> 2000 </option>";
echo "</select>";

echo "&nbsp;&nbsp;&nbsp;";
echo "<input type='submit' name='submit' value='$strShowTMonth'>";
echo "</form>";

commonFooter($strViewCalendar, $strAddEvent);
?> 

