function MakeBodyCalendar(nDay, nMonth, nYear, aWeek, aMonth, sFont, sFontSize, aColors, cField, iType)
{
   var sHTML = "", nDays, nDayWeek, nLastDay, nToday, sPosDay = "", oDate = new Date();
   if ( iType == 2 )
      sPosDay = cField.value == "" ? "0000000000000000000000000000000" : cField.value;
   nDay   = nDay   == null ? oDate.getDate()     : nDay; 
   nMonth = nMonth == null ? oDate.getMonth()+1  : nMonth; 
   nYear  = nYear  == null ? oDate.getFullYear() : nYear; 
   
   sFont     = sFont     == null ? "Arial" : sFont; 
   sFontSize = sFontSize == null ? "1"     : sFontSize; 

   sBgColor          = aColors == null ? "#CCCCCC" : aColors[0]; 
   sHeaderFontColor  = aColors == null ? "#FFFFFF" : aColors[1]; 
   sHeaderBgColor    = aColors == null ? "#808080" : aColors[2]; 
   sCelFontColor     = aColors == null ? "#000000" : aColors[3]; 
   sCelBgColor       = aColors == null ? "#FFFFFF" : aColors[4]; 
   sSundayFontColor  = aColors == null ? "#FF0000" : aColors[5]; 
   sSundayBgColor    = aColors == null ? "#FFECEC" : aColors[6]; 
   sTodayBgColor     = aColors == null ? "#BAEBED" : aColors[7]; 
   sMouseOverColor   = aColors == null ? "#CCCCCC" : aColors[8]; 
   
   oDate.setDate(1);
   oDate.setMonth(nMonth-1);
   oDate.setFullYear(nYear);
   
   nDayWeek = oDate.getDay();
   nLastDay = new Date( nYear, nMonth, 1).getDate();
   nLastDay = nLastDay==1 ? new Date(nYear, nMonth, 0).getDate() : nLastDay;

   sHTML += "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 BGCOLOR='"+sBgColor+"'><TR>\n";
   for(i=0;i<7;++i)
   { 
      sHTML += "<TD align='center" + 
               "' bgcolor=" + sHeaderBgColor + "'>" +
               "<font face='" + sFont + 
               "' size=" + sFontSize + 
               "' color=" + sHeaderFontColor + 
               "><B>" + aWeek[i] + 
               "</B></FONT></TD>\n"; 
   }   
   sHTML += "</TR>\n";
   nDays = 0
   for(i=0;i<6;++i)
   { 
      sHTML += "<TR>\n";
      for(j=0;j<7;++j)
      { 
         nDays = (j == nDayWeek && i == 0 ) ? 1 : nDays;
         bValidDay = nDays >= 1 && nDays <= nLastDay;
         sBgColor = (( nDays == nDay && bValidDay && iType == 1 ) ||
                     ( iType == 2 && bValidDay && sPosDay.substr(nDays-1,1) == '1') ? 
                       sTodayBgColor : ( j==0 && iType == 1 ? sSundayBgColor : sCelBgColor ))    
         sHTML += "<TD align='center'" + 
                  " bgcolor='" + sBgColor + "'" + 
                  ( !bValidDay ? "&nbsp;" : 
                  " id='"+cField.name + strzero(nDays+'',2) + "'" + 
                  " style='cursor: hand'" +
                  " onClick='DayClick(\""+
                  cField.name+"\","+iType+","+nDays+","+nMonth+","+nYear+",this, \""+
                  sTodayBgColor+"\", \""+sBgColor+"\")'" +
                  " onMouseOver='this.style.background=\"" + sMouseOverColor + "\"'" +
                  " onMouseOut='this.style.background=\"" + 
                    (( nDays == nDay && iType == 1 ) || 
                     ( cField.value.substr(nDays-1,1) == '1' && iType == 2 ) ? sTodayBgColor : 
                     ( j==0 && iType == 1 ) ? 
                      sSundayBgColor : sCelBgColor ) + "\"'" ) +
                  ">" +               
                  "<font face='" + sFont + 
                  "' size='" + sFontSize + 
                  "' color='" + ( j==0 && iType == 1 ? sSundayFontColor : sCelFontColor ) + 
                  "'><B>" + (bValidDay ? nDays++ : "&nbsp;" ) + 
                  "</B></FONT></TD>\n"; 
      }
      sHTML += "</TR>\n";   
   }   
   sHTML += "</TABLE>\n";
   return sHTML; 
}
function DayClick(cField, iType, nDay, nMonth, nYear, oCell, sTodayBgColor, sBgColor)
{
   if(iType==1)
   {
     oField = document.getElementById(cField);
     oField.value = (nDay < 10 ? "0" : "" ) + nDay + "/" +
                    (nMonth < 10 ? "0" : "" ) + nMonth + "/" +
                    nYear + oField.value.substr(10)
     DATEDIV.style.visibility='hidden';
     oField.focus();
     //SetCursor(oField,11);
   }
   else
   {
     oField = eval("document.all."+cField+"AGENDA");
     oField.value = oField.value.substr(0, nDay-1)+
                   (oField.value.substr(nDay-1,1)=="1" ? "0" : "1")+
                    oField.value.substr(nDay);
     oCell.style.background = oField.value.substr(nDay-1,1) == '1' ? 
                              sTodayBgColor : sBgColor ;
     sParam = "mouseOut('" + oField.name + "','" + oCell.id + "')";
     oCell.onmouseout = new Function(sParam);
   }
}
function mouseOut(sField,sCell)
{
   var nDay = sCell.substr(sCell.length-2,2);
   oField = eval("document.all."+sField+"AGENDA");
   document.getElementById(sCell).style.background = ( oField.value.substr(nDay-1,1) == '1' ? 
                                  sTodayBgColor : sCelBgColor );
}