/var/www/(Del)skdb.hk/calendar.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
<?php 
require("configure.php");
$catid = (int)$_GET['catid'];
$pid   = (int)$_GET['pid']; 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SK Dragon Boat</title>
<link rel="stylesheet" type="text/css" href="css/calstyle.css" />
<link rel="stylesheet" type="text/css" href="css/ddlevelsmenu-base.css" />
<link rel="stylesheet" type="text/css" href="css/ddlevelsmenu-topbar.css" />
<script type="text/javascript" src="css/ddlevelsmenu.js"></script>
<link rel="stylesheet" type="text/css" href="css/calendar.css" />
<script>
<!--

var newwindow;
function popwin(url)
{
    newwindow=window.open(url,'name1','width=350,height=150,scrollbars=no');
    if (window.focus) {newwindow.focus()}
}
//-->
</script>
<script>
<!--
/*
Live Date Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions, 100's more DHTML scripts, and Terms Of Use,
visit http://www.dynamicdrive.com
*/


var dayarray=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
//var cdate="<small><font color='C1272D' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn+"</b></font></small>"
var cdate="<small><font color='C1272D' face='Arial'><b>"+hours+":"+minutes+":"+seconds+" "+dn+" "+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" </b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" onLoad="goforit()">
<table width="1000" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="1000" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="250" align="left" valign="top" background="images/logobg.jpg"><img src="images/logo.jpg" width="250" height="633" /></td>
        <td width="750" align="left" valign="top"><table width="750" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="105" colspan="2" align="left" valign="top" background="images/menubg.jpg"><table width="750" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td height="50" align="right" valign="middle" class="langtxt">請選擇語言
                    <select name="menu1" onchange="MM_jumpMenu('parent',this,0)">
                      <option value="tc">繁體中文</option>
                      <option value="en">English</option>
                    </select>&nbsp;&nbsp;
                  </td>
              </tr>
              <tr>
                <td align="right" valign="top">
                <div id="ddtopmenubar" class="mattblackmenu">
                <ul>
                <?
                    load
(00);
            
                    function 
load($p$space)
                    {
                        
$sql "SELECT * ";
                        
$sql .= "FROM categories ";
                        
//$sql .= "ON template.templateid = categories.templateid ";
                        
$sql .= "where parentid = $p ";
                        
$sql .= "order by sortby desc ";
            
//            echo $sql;
                        
$result1 mysql_query($sql);
                        
$n=1;
                        
$count mysql_num_rows($result1); 
            
                        while (
$row mysql_fetch_array($result1,MYSQL_ASSOC))
                        {
                                if (
$space <> && $n == 1)
                                echo 
"<ul id='"$row{'parentid'} ."' class='ddsubmenustyle'>";
            
                                if(
$row{'link'} == '') {
                                    
$str "<li><a href='template1.php?pid=".$row{'catid'}."&catid="$row{'catid'} ."'";
                                } else {
                                    
$str "<li><a href='"$row{'link'} ."'";
                                }    
                                    
$sql2 " select * from categories where parentid = ".$row{'catid'};
                                    
$res2 mysql_query($sql2);
                                    if (
mysql_num_rows($res2) > 0)        
                                        
$str .= "rel='"$row{'catid'} ."' ";
                                    
$str .= ">"$row{'catname'} . "</a>";                        
                                    echo 
$str;                        
            
                            
$n++;
                            
load($row{'catid'}, $space+1);
                            echo 
"</li>";
                            if (
$space <> && $count $n)
                                echo 
"</ul>";
            
                        }
            
                    }
            
?>
                    </ul>
                    </div>
                    
                    <script type="text/javascript">
                    ddlevelsmenu.setup("ddtopmenubar", "topbar") //ddlevelsmenu.setup("mainmenuid", "topbar|sidebar")
                    </script>
                    
                </td>
              </tr>
            </table></td>
            </tr>
          <tr>
            <td width="35" align="left" valign="top"><img src="images/titlespace.jpg" width="35" height="70" /></td>
            <td width="715" align="left" valign="top"><table width="715" border="0" cellpadding="0" cellspacing="0">
              <? 
                $sql 
"SELECT * ";
                
$sql .= "FROM categories ";
                
$sql .= "where categories.catid = '"$catid ."' ";
                
                
$result mysql_query($sql);
                
$row mysql_fetch_array($result,MYSQL_ASSOC)
              
?>
              <tr>
                <td height="80" align="left" class="titletxt"><? echo $row{'catname'?></td>
                <td align="right"><span id="clock"></span><br>
                  <a href="http://www.hko.gov.hk/wxinfo/currwx/fndc.htm" target="_blank"><img src="images/weatherlogo.jpg" width="119" height="31" border="0" /></a></td>
              </tr>
              <tr>
                <td colspan="2" class="txt"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td align="center">
<?
$day 
= (int)$_GET['day'];
$month = (int)$_GET['month'];
$year = (int)$_GET['year'];
?>
<?    
class MyCalendar extends Calendar
{
    function 
getCalendarLink($month$year)
    {
        
// Redisplay the current page, but with some parameters
        // to set the new month and year
        
$s getenv('SCRIPT_NAME');
        return 
"$s?month=$month&year=$year";
    }
}

// If no month/year set, use current month/year

$d getdate(time());

if (
$month == "")
{
    
$month $d["mon"];
}

if (
$year == "")
{
    
$year $d["year"];
}

$cal = new MyCalendar;
echo 
$cal->getMonthView($month$year);

?>
<?

// PHP Calendar Class Version 1.4 (5th March 2001)
//  
// Copyright David Wilkinson 2000 - 2001. All Rights reserved.
// 
// This software may be used, modified and distributed freely
// providing this copyright notice remains intact at the head 
// of the file.
//
// This software is freeware. The author accepts no liability for
// any loss or damages whatsoever incurred directly or indirectly 
// from the use of this script. The author of this software makes 
// no claims as to its fitness for any purpose whatsoever. If you 
// wish to use this software you should first satisfy yourself that 
// it meets your requirements.
//
// URL:   http://www.cascade.org.uk/software/php/calendar/
// Email: davidw@cascade.org.uk


class Calendar
{
    
/*
        Constructor for the Calendar class
    */
    
function Calendar()
    {
    }
    
    
    
/*
        Get the array of strings used to label the days of the week. This array contains seven 
        elements, one for each day of the week. The first entry in this array represents Sunday. 
    */
    
function getDayNames()
    {
        return 
$this->dayNames;
    }
    

    
/*
        Set the array of strings used to label the days of the week. This array must contain seven 
        elements, one for each day of the week. The first entry in this array represents Sunday. 
    */
    
function setDayNames($names)
    {
        
$this->dayNames $names;
    }
    
    
/*
        Get the array of strings used to label the months of the year. This array contains twelve 
        elements, one for each month of the year. The first entry in this array represents January. 
    */
    
function getMonthNames()
    {
        return 
$this->monthNames;
    }
    
    
/*
        Set the array of strings used to label the months of the year. This array must contain twelve 
        elements, one for each month of the year. The first entry in this array represents January. 
    */
    
function setMonthNames($names)
    {
        
$this->monthNames $names;
    }
    
    
    
    
/* 
        Gets the start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
      
function getStartDay()
    {
        return 
$this->startDay;
    }
    
    
/* 
        Sets the start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
    
function setStartDay($day)
    {
        
$this->startDay $day;
    }
    
    
    
/* 
        Gets the start month of the year. This is the month that appears first in the year
        view. January = 1.
    */
    
function getStartMonth()
    {
        return 
$this->startMonth;
    }
    
    
/* 
        Sets the start month of the year. This is the month that appears first in the year
        view. January = 1.
    */
    
function setStartMonth($month)
    {
        
$this->startMonth $month;
    }
    
    
    
/*
        Return the URL to link to in order to display a calendar for a given month/year.
        You must override this method if you want to activate the "forward" and "back" 
        feature of the calendar.
        
        Note: If you return an empty string from this function, no navigation link will
        be displayed. This is the default behaviour.
        
        If the calendar is being displayed in "year" view, $month will be set to zero.
    */
    
function getCalendarLink($month$year)
    {
        return 
"";
    }
    
    
/*
        Return the URL to link to  for a given date.
        You must override this method if you want to activate the date linking
        feature of the calendar.
        
        Note: If you return an empty string from this function, no navigation link will
        be displayed. This is the default behaviour.
    */
    /////////////////////////////////////////////////////////////
    
/*     function getDateLink($day, $month, $year)     
    {
        $sql = "SELECT * ";
        $sql .= "FROM Calendar ";
        $sql .= "WHERE calDay=". $day ." and calMonth=" . $month ." and calYear=" . $year ."";
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result,MYSQL_ASSOC);
        if ($row{'calendarId'}<>'')
        {
            //$class = "calendarToday";
            $class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar";            
            //return "<td class=\"calendarlink\" align=\"center\" valign=\"center\" width=\"31\" bgcolor=\"#990000\"><a href=link1.htm class=\"calendarlink\">$day</a>";
            if ($row{'categoryId'} == "1")
            { 
            return "<td class=\"calendarlink\" align=\"center\" valign=\"center\" width=\"31\" bgcolor=\"#990000\"><a href=link1.htm class=\"calendarlink\">$day</a>";
            }
            elseif ($row{'categoryId'} == "2")
            {
            return "<td class=\"calendarlink\" align=\"center\" valign=\"center\" width=\"31\" bgcolor=\"#002E99\"><a href=link1.htm class=\"calendarlink\">$day</a>";
            }
            else
            {
            return "<td class=\"calendarlink\" align=\"center\" valign=\"center\" width=\"31\" bgcolor=\"#666666\"><a href=link1.htm class=\"calendarlink\">$day</a>";
            }
        }
        else
        {
            return "<td class=\"$class\" align=\"center\" valign=\"center\" width=\"31\">". $day;
        }
        
    }
*/    /////////////////////////////////////////////////////////////

     
function getDateLink($day$month$year)
        {
        
$day substr("0"$day,strlen("0"$day)-2);
        
$month substr("0"$month,strlen("0"$month)-2);

        
$d $year.$month.$day;

        
// Only link the first day of every month 
        
$link "";
        
//$sql = "select * from Calendar where calDay = ". $day ." and calMonth = ". $month ." and calYear = ". $year ." ";
        //$sql = "select * from Calendar where '". $d ."' between datefr and dateto"; 
        
$sql "select * from Calendar where categoryId = 1 and '"$d ."' between datefr and dateto";

        
$result=mysql_query($sql);
        
$row mysql_fetch_array($result,MYSQL_ASSOC);
        
$count mysql_num_rows($result);  
        if (
$count == )
        {
            if (
$row{'categoryId'} == 2)
            {
                
$link "$day";
            }
            elseif (
$row{'categoryId'} == 1)
            {
                
//$link = "<a href=\"#".$row{'calDay'}."/".$row{'calMonth'}."/".$row{'calYear'}."\" class=\"calendarlink2\">$day</a>";
                //$link = "<a href=\"#".$day."/".$month."/".$year."\" class=\"calendarlink1\">$day</a>";
                
if ($row{'calType'} == 1)
                {
                    
//$link = "<a href=\"#".$day."/".$month."/".$year."\" class=\"calendarlink1\">$day</a>";
                    //echo "<a name=".$row{'calendarId'}."></a>";
                    
$link "<div align=\"center\"><a href=\"#".$row{'calendarId'}."\" class=\"calendarlink1\">$day</a></div>";    
                }
                elseif (
$row{'calType'} == 2)
                {
                    
$link "<div align=\"center\"><a href=\"#".$row{'calendarId'}."\" class=\"calendarlink2\">$day</a></div>";
                }
            }
        }
        elseif (
$count )
        {

            
$link "<div align=\"center\"><a href=\"#".$row{'calendarId'}."\" class=\"calendarlink3\">$day</a></div>";
        }    
        return 
$link;
    }

    
/////////////////////////////////////////////////////////////

    /*
        Return the HTML for the current month
    */
    
function getCurrentMonthView()
    {
        
$d getdate(time());
        return 
$this->getMonthView($d["mon"], $d["year"]);
    }
    

    
/*
        Return the HTML for the current year
    */
    
function getCurrentYearView()
    {
        
$d getdate(time());
        return 
$this->getYearView($d["year"]);
    }
    
    
    
/*
        Return the HTML for a specified month
    */
    
function getMonthView($month$year)
    {
        return 
$this->getMonthHTML($month$year);
    }
    

    
/*
        Return the HTML for a specified year
    */
    
function getYearView($year)
    {
        return 
$this->getYearHTML($year);
    }
    
    
    
    
/********************************************************************************
    
        The rest are private methods. No user-servicable parts inside.
        
        You shouldn't need to call any of these functions directly.
        
    *********************************************************************************/


    /*
        Calculate the number of days in a month, taking into account leap years.
    */
    
function getDaysInMonth($month$year)
    {
        if (
$month || $month 12)
        {
            return 
0;
        }
   
        
$d $this->daysInMonth[$month 1];
   
        if (
$month == 2)
        {
            
// Check for leap year
            // Forget the 4000 rule, I doubt I'll be around then...
        
            
if ($year%== 0)
            {
                if (
$year%100 == 0)
                {
                    if (
$year%400 == 0)
                    {
                        
$d 29;
                    }
                }
                else
                {
                    
$d 29;
                }
            }
        }
    
        return 
$d;
    }


    
/*
        Generate the HTML for a given month
    */
    
function getMonthHTML($m$y$showYear 1)
    {
        
$s "";
        
        
$a $this->adjustDate($m$y);
        
$month $a[0];
        
$year $a[1];        
        
        
$daysInMonth $this->getDaysInMonth($month$year);
        
$date getdate(mktime(1200$month1$year));
        
        
$first $date["wday"];
        
$monthName $this->monthNames[$month 1];
        
        
$prev $this->adjustDate($month 1$year);
        
$next $this->adjustDate($month 1$year);
        
        if (
$showYear == 1)
        {
            
$prevMonth $this->getCalendarLink($prev[0], $prev[1]);
            
$nextMonth $this->getCalendarLink($next[0], $next[1]);
        }
        else
        {
            
$prevMonth "";
            
$nextMonth "";
        }
        
        
$header $monthName . (($showYear 0) ? " " $year "");
        
        
$s .= "<table width=\"560\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"calendar\">\n";
        
$s .= "<tr>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeader\">" . (($prevMonth == "") ? "&nbsp;" "<a href=\"$prevMonth&catid=9\"><img src=\"images\cal_arrowl.gif\" width=\"10\" height=\"11\" border=\"0\"></a>")  . "</td>\n";
        
$s .= "<td height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeader\" colspan=\"5\">$header</td>\n"
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeader\">" . (($nextMonth == "") ? "&nbsp;" "<a href=\"$nextMonth&catid=9\"><img src=\"images\cal_arrowr.gif\" width=\"10\" height=\"11\" border=\"0\"></a>")  . "</td>\n";
        
$s .= "</tr>\n";
        
        
$s .= "<tr>\n";
        
$s .= "<td colspan=\"7\" background=\"images\cal_topbg.gif\">";
        
        
$s .= "<table width=\"560\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
        
        
$s .= "<tr>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay)%7] . "</td>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay+1)%7] . "</td>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay+2)%7] . "</td>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay+3)%7] . "</td>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay+4)%7] . "</td>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay+5)%7] . "</td>\n";
        
$s .= "<td width=\"80\" height=\"35\" align=\"center\" valign=\"center\" class=\"calendarHeaderpageD\">" $this->dayNames[($this->startDay+6)%7] . "</td>\n";
        
$s .= "</tr>\n";
        
        
$s .= "</table>";
        
$s .= "</td>\n";
        
$s .= "</tr>\n";
        
        
        
// We need to work out what date to start at so that the first appears in the correct column
        
$d $this->startDay $first;
        while (
$d 1)
        {
            
$d -= 7;
        }

        
// Make sure we know when today is, so that we can use a different CSS style
        
$today getdate(time());
        
        while (
$d <= $daysInMonth)
        {
            
$s .= "<tr>\n";       
            
            for (
$i 0$i 7$i++)
            {
                
//*******************
                //**today
                //*******************
                
$class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" "calendar";
                
$s .= "<td class=\"$class\" align=\"center\" valign=\"center\" height=\"35\" width=\"80\">";       
                
                
$dw $year.substr('0'.$monthstrlen('0'.$month)-2).substr('0'.$dstrlen('0'.$d)-2);
                
$dw date("D"strtotime($dw));
                if (
$dw == "Sun")
                {
                    
$dw "<font color='#FF0000'>";
                }
                else
                {
                    
$dw "";
                }
                if (
$d && $d <= $daysInMonth)
                {
                    
$link $this->getDateLink($d$month$year);
                    
$s .= (($link == "") ? $dw.$d $link);
                }
                else
                {
                        
$s .= "&nbsp;";
                }
                  
$s .= "</td>\n";       
                
$d++;
            }
            
$s .= "</tr>\n";    
        }
        
        
$s .= "</table>\n";
        
        return 
$s;      
    }
    
    
    
/*
        Generate the HTML for a given year
    */
    
function getYearHTML($year)
    {
        
$s "";
        
$prev $this->getCalendarLink(0$year 1);
        
$next $this->getCalendarLink(0$year 1);
        
        
$s .= "<table class=\"calendar\" border=\"0\">\n";
        
$s .= "<tr>";
        
$s .= "<td align=\"center\" valign=\"top\" align=\"left\">" . (($prev == "") ? "&nbsp;" "<a href=\"$prev\">&lt;&lt;</a>")  . "</td>\n";
        
$s .= "<td class=\"calendarHeader\" valign=\"top\" align=\"center\">" . (($this->startMonth 1) ? $year " - " . ($year 1) : $year) ."</td>\n";
        
$s .= "<td align=\"center\" valign=\"top\" align=\"right\">" . (($next == "") ? "&nbsp;" "<a href=\"$next\">&gt;&gt;</a>")  . "</td>\n";
        
$s .= "</tr>\n";
        
$s .= "<tr>";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "</tr>\n";
        
$s .= "<tr>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "</tr>\n";
        
$s .= "<tr>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "</tr>\n";
        
$s .= "<tr>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML($this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML(10 $this->startMonth$year0) ."</td>\n";
        
$s .= "<td class=\"calendar\" valign=\"top\">" $this->getMonthHTML(11 $this->startMonth$year0) ."</td>\n";
        
$s .= "</tr>\n";
        
$s .= "</table>\n";
        
        return 
$s;
    }

    
/*
        Adjust dates to allow months > 12 and < 0. Just adjust the years appropriately.
        e.g. Month 14 of the year 2001 is actually month 2 of year 2002.
    */
    
function adjustDate($month$year)
    {
        
$a = array();  
        
$a[0] = $month;
        
$a[1] = $year;
        
        while (
$a[0] > 12)
        {
            
$a[0] -= 12;
            
$a[1]++;
        }
        
        while (
$a[0] <= 0)
        {
            
$a[0] += 12;
            
$a[1]--;
        }
        
        return 
$a;
    }

    
/* 
        The start day of the week. This is the day that appears in the first column
        of the calendar. Sunday = 0.
    */
    
var $startDay 0;

    
/* 
        The start month of the year. This is the month that appears in the first slot
        of the calendar in the year view. January = 1.
    */
    
var $startMonth 1;

    
/*
        The labels to display for the days of the week. The first entry in this array
        represents Sunday.
    */
    
var $dayNames = array("S""M""T""W""T""F""S");
    
    
/*
        The labels to display for the months of the year. The first entry in this array
        represents January.
    */
    
var $monthNames = array("January""February""March""April""May""June",
                            
"July""August""September""October""November""December");
                            
                            
    
/*
        The number of days in each month. You're unlikely to want to change this...
        The first entry in this array represents January.
    */
    
var $daysInMonth = array(312831303130313130313031);
    
}

?></td>
                  </tr>
                  <tr>
                    <td align="right"><table width="380" border="0" cellspacing="3">
                        <tr>
                          <td height="15">&nbsp;</td>
                          <td width="88" rowspan="3" class="calendarlegend">Competition</td>
                          <td height="15">&nbsp;</td>
                          <td width="88" rowspan="3" class="calendarlegend">Practice</td>
                          <td height="15">&nbsp;</td>
                          <td width="138" rowspan="3" class="calendarlegend">Competition / Practice</td>
                        </tr>
                        <tr>
                          <td width="15" height="15" bgcolor="#962549"><img src="images/primary_icon.gif" width="15" height="15" /></td>
                          <td width="15" height="15" bgcolor="#999000"><img src="images/secondary_icon.gif" width="15" height="15" /></td>
                          <td width="15" height="15" bgcolor="#999999"><img src="images/primary&amp;secondary_icon.gif" width="15" height="15" /></td>
                        </tr>
                        <tr>
                          <td height="15">&nbsp;</td>
                          <td height="15">&nbsp;</td>
                          <td height="15">&nbsp;</td>
                        </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td align="left" valign="top"><table width="560" border="0" cellpadding="0" cellspacing="2">
                <?php
                $month 
substr("0"$month,strlen("0"$month)-2);
                
//echo $month;
                
$sql "select * from Calendar where right(LEFT(datefr,6), 2)='"$month ."' and categoryId=1 order by datefr ASC, calendarId ASC";                
                
$result mysql_query($sql);
                
//echo $sql;
                
$x=1;
                while (
$row mysql_fetch_array($result,MYSQL_ASSOC))
                {
                    if(
$row{'calType'} == '1')
                    
$color "<img src='images/primary_icon.gif' width='15' height='15'>";
                else
                    
$color "<img src='images/secondary_icon.gif' width='15' height='15'>";                    
                echo 
"<tr>";

                echo 
"<a name=".$row{'calendarId'}."></a>";                
                echo 
"<td width='30' align='right' valign='top' style='padding-right:10;padding-top:2'>".$color."</td>";
                echo 
"<td align='left' valign='top' style='padding-right:0;padding-top:2;padding-bottom:2' class='pagecontent'>";
                echo 
"<span class='calendarlegend'><b>".$row{'datefr'}."&nbsp; to &nbsp;".$row{'dateto'}."</b></span><br>";
                echo 
"<span class='desctxt'>".$row{'calTitle'}."</span><br><br><span class='desctxt'>".$row{'calDesc'}."</span>";
                echo 
"</td></tr>";
                echo 
"<tr>";
                echo 
"<td width='30' align='right' valign='top' style='padding-right:10;padding-top:2'>&nbsp;</td>";
                echo 
"<td align='left' valign='top' style='padding-right:0;padding-top:2;padding-bottom:2' class='desctxt'>";
                echo 
"<a href=\"javascript:popwin('attendaddform.php?calendarId=".$row{'calendarId'}."')\" border='0'><b>發表</b></a><br>";
                echo 
"出席 :&nbsp;&nbsp;";
                
$sql2 "select * from attend where calendarId = ".$row{'calendarId'}." order by attendname asc";
                
//echo $sql2;                
                
$result2 mysql_query($sql2);
                unset(
$attend1);
                unset(
$row2);
                while (
$row2 mysql_fetch_array($result2,MYSQL_ASSOC))
                    {                
                     if(
$row2{'attendstatus'} == '1') { 
                     
$attend1[] = $row2{'attendname'};
                     }
                     }
                 echo 
implode(','$attend1);
                echo 
"<br>";
                echo 
"缺席 :&nbsp;&nbsp;";
                
$result2 mysql_query($sql2);
                unset(
$attend2);
                unset(
$row2);
                while (
$row2 mysql_fetch_array($result2,MYSQL_ASSOC))
                    {                
                     if(
$row2{'attendstatus'} == '2') { 
                     
$attend2[] = $row2{'attendname'};
                     }
                     }
                 echo 
implode(','$attend2);            
                echo 
"</td></tr>";
                  echo 
"<tr>";
                echo 
"<td colspan='2' align='left' valign='middle' style='padding-bottom:10;padding-top:10'><img src='images/line-x.jpg' width='560' height='3'>";
                echo 
"</td></tr>";
                
$x $x +1;
                }
            
?>
                      </table>
                       
                    </td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" valign="top"><img src="images/footer.jpg" width="1000" height="148" /></td>
  </tr>
  <tr>
    <td height="48" align="left" valign="top" background="images/footertxt.jpg" class="footertxt" style="background-repeat:no-repeat"><div align="center">© 2009 Copyright SK Dragon Boat. All Rights   Reserved<br />
    Powered by <a href="http://www.onesolution.com.hk" target="_blank">One Solution Limited</a>. </div></td>
  </tr>
</table>
</body>
</html>