function buildCal(Month, Year, Border){
var MonthName = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
var DaysInMonth =[31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

var TodayDate = new Date();

// ***This part is to figure out the number of the first day in the month, ie if it is sun, mon, ... sun = 0
// getDay() return 0 to 6, 6 is sunday

var TempDate = new Date(TodayDate.getYear(), TodayDate.getMonth(), 1);
var FristDayInMonthNum = TempDate.getDay();


// check if February is 29 or 28 days
if (((TodayDate.getFullYear() % 100 !=0) && (TodayDate.getFullYear() % 4 == 0))||(TodayDate.getFullYear() % 400 == 0)) 
   DaysInMonth[1] = 29;
else
   DaysInMonth[1] = 28;
                            
t = '       <TABLE cellSpacing=2 cellPadding=1 width=140 ';
t += '    align=center border=0 face="Tahoma">';
t += '      <TBODY style="font-family:tahoma;font-size:75%;">';
t += '      <TR>';
t += '       <TD colSpan=7>';
t += '    <DIV align=center style="color:blue;font-size:90%;">';
t += MonthName[TodayDate.getMonth()];
t += ' - ';
t += TodayDate.getFullYear();

t += '</DIV></TD></TR>';
t += '        <TR align=center style="font-size:90%;">';
t += '        <TD width=20 align=center>S</TD>';
t += '      <TD width=20 align=center>M</TD>';
t += '         <TD width=20 align=center>T</TD>';
t += '       <TD width=20 align=center>W</TD>';
t += '     <TD width=20 align=center>T</TD>';
t += '         <TD width=20 align=center>F</TD>';
t += '        <TD width=20 align=center>S</TD></TR>';

var PrintDay = 0;
var CalcDay = 0;

for (x = 1; x <=6; x++) {
   t += '<TR bgColor=#eeeeee style="font-size:90%;">';

   for (y=0; y <= 6; y++) {
      if ((x == 1) && (y < FristDayInMonthNum)) {
         PrintDay = '  ';
        }  
       else {    
          CalcDay = CalcDay + 1;
             if (CalcDay > DaysInMonth[TodayDate.getMonth() ])
                PrintDay = '  ';
             else
                PrintDay = CalcDay;
             }

      if (CalcDay == TodayDate.getDate()) {
         t += '<TD bgcolor="#669999">';
         t += '<font color="white" ><B>';
      }
      else
         t += '<TD>';

      t += PrintDay;
      t += '</TD>';
     }
t += '</TR>';
}

t += '</TBODY></TABLE>';

return t;
}
