function calendare(date)
         {
         //If no parameter is passed use the current date.
         if(date == null)
            date = new Date();
         
         day = 0;
         month = date.getMonth();
         year = date.getFullYear();
         year = year;
         month = month + 1;
         months = new Array('Януари',
                            'Февруари',
                            'Март',
                            'Април',
                            'Май',
                            'Юни',
                            'Юли',
                            'Август',
                            'Септември',
                            'Октомври',
                            'Ноември',
                            'Декември');
         
         this_month = new Date(year, month, 0);
         next_month = new Date(year, month + 1, 0);

         
         //Find out when this month starts and ends.         
         first_week_day = this_month.getDay();
         days_in_this_month = Math.round((next_month.getTime() - this_month.getTime()) / (1000 * 60 * 60 * 24));
         
         calendar_html = '<table align="center" style="background-color:green; color:ffffff;font-size: 10;  font-family: verdana;">';
         
         calendar_html += '<tr><td colspan="7" align="center" style="background-color:#D2F8CB; color:000000;font-size: 10;  font-family: verdana;">' + 
                          months[month] + ' ' + year + '</td></tr>';
         
         calendar_html += '<tr>';
          
         //Fill the first week of the month with the appropriate number of blanks.       
         for(week_day = 0; week_day < first_week_day; week_day++)
            {
            calendar_html += '<td style="background-color:D2F8CB; color:000000;"> </td>';   
            }
            
         week_day = first_week_day;
         for(day_counter = 1; day_counter <= days_in_this_month; day_counter++)
            {
            week_day %= 7;
            
            if(week_day == 0)
               calendar_html += '</tr><tr>';
            
            //Do something different for the current day.
            if(day == day_counter)   
               calendar_html += '<td align="center"><b>' + 
                                day_counter + 
                           ' </b></td>';
            else
               calendar_html += '<td align="center" style="background-color:D2F8CB; color:000000;">' + 
                                day_counter + 
                           '</td>';
            
            week_day++;
            }
            
         calendar_html += '</tr>';
         calendar_html += '</table><br><font face="verdana" size=2>Събития за месец ' +
 months[month] + '<br> <iframe width="300" src="viewmonth.php?m=' +
 months[month] + '&y='+ year +'" frameborder="1"></iframe>';
         
         //Display the calendar.     
         document.write(calendar_html);                  
         }

