// gencal.js -- generates a tabled calendar
// v2.0 -- 5/17/99


function writeNum(num){
   document.write(startFmt+goURL+num+ "' onMouseOver=\""+  
" status = 'Events for " + v_mon + "/" + num + "/"+ v_year +" ';return true;\""+ 
"target='main'><font color='#FFFFFF'><b>"+num+"</b></font>"+endFmt+"</A>"+endFmt);

// onMouseOver= &quot; status = 'Select date';return true; &quot;


}

function writeTop(str) {
   document.write("<TD>" +startFmt+ "<font color='white'><b>" +str+ "</b></font>" +endFmt+ "</TD>");
}


function genCal(month,year) {

   startFmt="<font  size='1.5'>";
   goURL="<A onclick='javascript:showAlert();'?c_month="+month+"&c_year="+year+"&c_day=";
  // goURL="<A HREF='date_info.asp?c_month="+month+"&c_year="+year+"&c_day=";
  // c_month and c_year value from genCal(month,year) gotten from vbscript...
  
  // getting current Date
  now = new Date();
  month = now.getMonth()+1;
  year = now.getYear();
  
  v_mon = month;
   v_year= year;

   endFmt="</font>";

   var cal= new Date();
   var dow=0;
   var x=0;
   var y=0;
   var num=0;
   var leap=0;
   var b_month=0;			// back button
   var b_year=year;			// back button
   cal.setMonth(month-1);		// back button
   if (month==1) {b_month='12';} 	// back button
   else {b_month=month-1;}		// back button	
   if (month==1) {b_year=year-1;}	// back button
   
   var f_month=month;
   var f_year=year;
   if (month==12) {f_month='1';}
   else {f_month=month+1;}
   if (month==12) {f_year=year+1;}
   
   cal.setDate(1);
   cal.setYear(year);
   dow=cal.getDay();//from 0=sun to 6=sat
     document.write("<TABLE WIDTH='122' CELLPADDING='0' CELLSPACING='0' BORDER='0'>"+"<TR align='top'>"+"<TD align='right'>");
    document.write(" </td>"+
"<TD align='center' colspan=2  border='0'>"+"<FONT face='tahoma,verdana,arial,helvetica' size='1' color='white'>"+
"<B>");

   if (month==1) {document.write("JANUARY ");}
   else if (month==2) {document.write("FEBRUARY ");}
   else if (month==3) {document.write("MARCH ");}
   else if (month==4) {document.write("APRIL ");}
   else if (month==5) {document.write("MAY ");}
   else if (month==6) {document.write("JUNE ");}
   else if (month==7) {document.write("JULY ");}
   else if (month==8) {document.write("AUGUST ");}
   else if (month==9) {document.write("SEPTEMBER ");}
   else if (month==10) {document.write("OCTOBER ");}
   else if (month==11) {document.write("NOVEMBER ");}
   else if (month==12) {document.write("DECEMBER ");}
   document.write(year+"</b></font></td>"+"<TD align='right' border='0'>"+
" "+"</td>"+"<TD  align='center' colspan=2  border='0'>"+"</a>"+"</right>"+"</TD></TR></table>");
    document.write("<TABLE WIDTH='118' CELLPADDING='0' CELLSPACING='0' BORDER='0'>"+"<TR align='center' >");
   writeTop("Su "); writeTop("Mo "); writeTop("Tu "); writeTop("We ");
   writeTop("Th "); writeTop("Fr "); writeTop("Sa ");
   document.write("</TR>");

   for(y=0;y<=6;y++) {
      document.write("<TR>");
      for(x=0;x<=6;x++) {
         document.write("<TD ALIGN='CENTER'>");
         if ((num==0) && (x==dow)) {
            num=1;
         }

         if ((num>0) && (num<29)) {
            writeNum(num);
         } else if ((num>28) && (num<31) && (month!=2)) {
            writeNum(num);
         } else if ((num==31)) {
              if (((month<8) && (month%2==1)) || ((month>7) && (month%2==0)))
                 writeNum(31);
              else
                 document.write("<BR>");
         } else if ((month==2) && (num==29) && (year%4==0)) {
            writeNum(29);
         } else {
            document.write(""); //deleted br tag to prevent space between links..
         }
         if (num!=0) {
            num++;
         }
         document.write("</TD>");
      }
   document.write("</TR>");
   }
   document.write("</TABLE>");
}
