<?php

$file = __FILE__;
include ("inc/inc_common.php");
include ("inc/inc_connect.php");
include ("inc/inc_admincheck.php");
include ("inc/inc_getdate.php");
include ("inc/inc_forumname.php");
$page = "Calendar";
$pagelink = $file;
include("inc/inc_setonline.php");
$title = "$name1 Calendar";
include ("inc/inc_head.php");
include ("inc/inc_body.php");
$title = "Calendar";
include ("inc/inc_title.php");

print "</centeR><table border=0 width=\"100%\" cellpadding=1 cellspacing=0><tr><td  width=\"20%\">
<table border=0 cellpadding=1 cellspacing=0><tr><td>
<font face=\"$font\" size=$fontsize><image src=\"images/folder_icon.gif\">&nbsp;<a href=\"index.php\">$name1&nbsp;Home</a>
</td></tr>
<tr><td><image src=\"images/folder_line.gif\">
<font face=\"$font\" size=$fontsize><image src=\"images/open_folder_icon.gif\">&nbsp;Calendar</td></tr>
</table>
</td><td><center>";

include ("inc/inc_navigation.php");
include ("inc/inc_newmailsdisplay.php");
print "</td></tr></table><br><center>";

//end of include files...

//check incoming date for validity

if (!isset($cmonth))
{
    $cmonth = $smonth;
}

if (!isset($cyear))
{
    $cyear = $year;
}

if ($cmonth == "")
{
    $cmonth = $smonth;
}


if ($cyear == "")
{
    $cyear = $year;
}

if (checkdate($cmonth, 20, $cyear) == false)
{
  $cmonth = $smonth;
  $cyear = $year;
}

//how many days in this month?

$daysinmonth = 31;
while (checkdate($cmonth, $daysinmonth, $cyear) == false)
{
   $daysinmonth -= 1;
}

$daysinmonth ++;

//expand month...

if ( $cmonth == 1 )
{
    $fullmonth = "January";
}
if ( $cmonth == 2 )
{
    $fullmonth = "Febuary";
}
if ( $cmonth == 3 )
{
    $fullmonth = "March";
}
if ( $cmonth == 4 )
{
    $fullmonth = "April";
}
if ( $cmonth == 5 )
{
    $fullmonth = "May";
}
if ( $cmonth == 6 )
{
    $fullmonth = "June";
}
if ( $cmonth == 7 )
{
    $fullmonth = "July";
}
if ( $cmonth == 8 )
{
    $fullmonth = "August";
}
if ( $cmonth == 9 )
{
    $fullmonth = "September";
}
if ( $cmonth == 10 )
{
    $fullmonth = "October";
}
if ( $cmonth == 11 )
{
    $fullmonth = "November";
}
if ( $cmonth == 12 )
{
    $fullmonth = "December";
}

//display calander
$counter = 1;
$count = 1;
print "<table border=1 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=25% bgcolor=$fgcolour><tr><td width=100%><center><font face=$font size=3><b>$fullmonth $cyear</b></td></tr></table>";
print "<table border=1 cellpadding=0 cellspacing=0 style=\"border-collapse: collapse\" bordercolor=#111111 width=25% bgcolor=$fgcolour><tr>";

while ( $counter < $daysinmonth )
{
    $result = mysql_query( "SELECT * FROM $calendartable WHERE strName = '$gfcookie[1]' AND intDay = '$counter' AND intMonth = '$cmonth' AND intYear = '$cyear'" );
    $num_rows = mysql_num_rows( $result );

    $result = mysql_query( "SELECT * FROM $calendartable WHERE intDay = '$counter' AND intMonth = '$cmonth' AND intYear = '$cyear'" );
    $num_rowsb = mysql_num_rows( $result );

    if ( $count == 8)
    {
        $count = 1;
        print "</td></tr><tr>";
    }
    if ( $num_rows > 0 )
    {
        print "<td width=14% bgcolor=$afgcolour><font face=$font size=2><center><a href=\"calendarday.php?cmonth=$cmonth&cday=$counter&cyear=$cyear\"><font color=$ratecolor>$counter</a></td>";
    }
    else
    {
        if ( $num_rowsb > 0)
        {
            print "<td width=14%><font face=$font size=2><center><a href=\"calendardayall.php?cmonth=$cmonth&cday=$counter&cyear=$cyear\"><font color=$ratecolor>$counter</a></td>";
        }
        else
        {
            print "<td width=14%><font face=$font size=2><center><a href=\"calendardayall.php?cmonth=$cmonth&cday=$counter&year=$cyear\">$counter</a></td>";
        }
    }
    $counter ++;
    $count ++;
}

    //finish up calander

if ( $daysinmonth == 29 )
{
    print "</tr><tr>";
}


while ( $counter < 35 )
{
    print "<td width=14%>&nbsp;</td>";
    $counter ++;
}

$yearback = $cyear;
$yearon = $cyear;
$monthback = $cmonth - 1;
$monthon = $cmonth + 1;
if ($monthback == 0)
{
    $monthback = 12;
    $yearback -= 1;
}

if ($monthon == 13)
{
    $monthon = 1;
    $yearon ++;
}

print "</tr></table><br><center><table border=0 width=25%><tr><td width=50%>
<a href=\"calendar.php?cmonth=$monthback&cyear=$yearback\"><font face=$font size=2><center>&lt;&lt;Back&lt;&lt;</td>
<td width=50%>
<a href=\"calendar.php?cmonth=$monthon&cyear=$yearon\"><font face=$font size=2><centeR>&gt;&gt;Forward&gt;&gt;</td></tr></table><br><font face=$font size=2><form method=post action=\"calendar.php\">Go to: Month <input type=\"text\" name=\"cmonth\" size=3> Year <input type=\"text\" name=\"cyear\" size=3> <input type=\"submit\" value=\"&nbsp;Go!&nbsp;\">";

include ("inc/inc_footer.php")
?>