function calendar(date)
         {
         //If no parameter is passed use the current date.
         if(date == null)
            date = new Date();
         
         day = date.getDate();
         month = date.getMonth();
         year = date.getFullYear();
         
         months = new Array('January',
                            'February',
                            'March',
                            'April',
                            'May',
                            'June',
                            'July',
                            'August',
                            'September',
                            'October',
                            'November',
                            'December');
         
         this_month = new Date(year, month, 1);
         next_month = new Date(year, month + 1, 1);
         
         //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 = '<ul id="calendar">';
 		 calendar_html += '<li class="click">';
 		 calendar_html += '<table><thead>';
		 var currdate = new Date(year, month - 1, 1, 12);
		 var unixtime_ms = currdate.getTime(); // Returns milliseconds since the epoch
		 var unixtime = parseInt(unixtime_ms / 1000);
 		 calendar_html += '<tr><td onClick="showContent(\'Events for the day of '+ months[month - 1] +'\, '+ 1 +' '+ year+'\', \'./php/calendarquery.php?day='+ unixtime +'\'); showCalendar(prevmonth)"><img src="./img/cal/grid/prev.png" class="domroll ./img/cal/grid/prevhov.png"/></td>';
 		 calendar_html += '<td colspan="5"><center>' + months[month] + ' ' + year + '</center></td>';
		 var currdate = new Date(year, month + 1, 1, 12);
		 var unixtime_ms = currdate.getTime(); // Returns milliseconds since the epoch
		 var unixtime = parseInt(unixtime_ms / 1000);
		 calendar_html += '<td onClick="showContent(\'Events for the day of '+ months[month + 1] +'\, '+ 1 +' '+ year+'\', \'./php/calendarquery.php?day='+ unixtime +'\'); showCalendar(nextmonth)"><img src="./img/cal/grid/next.png" class="domroll ./img/cal/grid/nexthov.png"/></td></tr>';
 		 calendar_html += '</thead><tbody>';
		 
         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><img src="./img/cal/grid/0.png"/></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><img src="./img/cal/grid/'+ day_counter +'hov.png"/></td>';
			}
			
            else
				{
				var currdate = new Date(year, month, day_counter, 12);
				var unixtime_ms = currdate.getTime(); // Returns milliseconds since the epoch
				var unixtime = parseInt(unixtime_ms / 1000);
				calendar_html += '<td onClick="showContent(\'Events for the day of '+ months[month] +'\, '+ day_counter +' '+ year+'\', \'./php/calendarquery.php?day='+ unixtime +'\'); showCalendar(new Date('+ year +', '+ month +','+ day_counter +'));"><img src="./img/cal/grid/'+ day_counter +'.png" class="domroll ./img/cal/grid/'+ day_counter +'hov.png"/></td>';
				}
            week_day++;
            }
            
         calendar_html += '</tr></tbody>';
         calendar_html += '</table></li></ul>';
		 
         prevmonth = new Date(year, month - 1, 1);
		 nextmonth = new Date(year, month + 1, 1);
		 
		 $('calAreaPic').innerHTML = '<img src="./img/cal/'+ months[month] +'.png" style="width:100%"/>';
		 
         //Display the calendar.    
         return calendar_html;                  
         }

