calendarlist.put(new Integer(i), new CalendarListElement(start, end));
      // pre-populate the row to contain zero items.
      TDColumn.put(new Integer(i), new Integer(0));
    }
  
    GregorianCalendar listRenderCalendar = new GregorianCalendar(tz);
    listRenderCalendar.setTime(starttimeuser.getTime());
  
    int counthour = 0;
    for (int i = 0; i < totalnumberofrows; i++) {
      // The Calendar fields will be used to track the current place in
      // the displayed calendar, we will increment through the blocks
      // and compare the activites returned from the list.
      int calendarDate = listRenderCalendar.get(Calendar.DATE);
      int calendarMonth = listRenderCalendar.get(Calendar.MONTH);
      int calendarYear = listRenderCalendar.get(Calendar.YEAR);
      Iterator activityIterator = calactivityVector.iterator();
      int uniqueId = 0;
      while (activityIterator.hasNext()) {
        uniqueId++;
        CalendarActivityObject activityobject = (CalendarActivityObject)activityIterator.next();
        GregorianCalendar starttime = activityobject.getStartTime();
        GregorianCalendar endtime = activityobject.getEndTime();
  
        // If somehow we squeezed an illegally formed activity in we should skip
        // it.
        if ((starttime.getTimeInMillis() > endTimeuser.getTimeInMillis())) {
          continue;
        }
        // calendarStartingBlock is the starting block for an activity on the
        // displayed table.
        int calendarStartingBlock = 0;
        // The critical info on the currently selected activity.
        int activityDate = starttime.get(Calendar.DATE);
        int activityMonth = starttime.get(Calendar.MONTH);
        int activityYear = starttime.get(Calendar.YEAR);
        int activityHour = starttime.get(Calendar.HOUR);
        int activityMinute = starttime.get(Calendar.MINUTE);
        int activityAMPM = starttime.get(Calendar.AM_PM);
        if (activityAMPM == 1) {
          activityHour = activityHour + 12;
        }
        boolean flag = false;
  
        // If the selected activity has the same month, date, and year
        // and we are looking at the Daily View.
        if (activityDate == calendarDate && activityMonth == calendarMonth
            && activityYear == calendarYear
            && (totalnumberofrows == 24 || totalnumberofrows == 48 || totalnumberofrows == 96)) {
          // if it is daily hourly blocks then the starting block is the
          // starting hour
          calendarStartingBlock = (activityHour);
          // otherwise we need calculate the starting block because the number
          // of blocks may
          // have doubled or quadrupled (30 or 15 minute intervals)
          // It needs to be the floor function of the division also.
          if (totalnumberofrows == 48) {
            int diffMinute = (int)Math.floor(activityMinute / 30.0);
            calendarStartingBlock = (calendarStartingBlock * 2) + diffMinute;
          } else if (totalnumberofrows == 96) {
            int diffMinute = (int)Math.floor(activityMinute / 15.0);
            calendarStartingBlock = (calendarStartingBlock * 4) + diffMinute;
          }
          flag = true;
        } else if (activityDate == calendarDate && activityMonth == calendarMonth
            && activityYear == calendarYear) {
          // it is still the same, but we are not one of the daily views.
          flag = true; // no setup required for numberof rows = 28 through 31
                        // ??
  
          calendarStartingBlock = (activityDate - 1);
          if (totalnumberofrows == 168) // if weekly columnar
          {
            calendarStartingBlock = starttime.get(Calendar.DAY_OF_WEEK);
            if (calendarStartingBlock == Calendar.SUNDAY) // if SUNDAY
            {
              calendarStartingBlock = 6; // then move to the end.
            } else {
              // else normalize monday to be zero (coupled to UI)                                                           // normalize
              calendarStartingBlock = calendarStartingBlock - Calendar.MONDAY; 
            }
            calendarStartingBlock = (calendarStartingBlock * 24) + (activityHour);
  
            // Display as an allday activity on top
            if (activityobject.getAllDayEvent()) {
              activityobject.setAllDayTime();
              flag = false;
              allDayMap.put(activityobject.getActivityID(), activityobject);
            }
          }
  
          if (totalnumberofrows == 7) {
            // if weekly non-columnar
            calendarStartingBlock = starttime.get(GregorianCalendar.DAY_OF_WEEK);
            if (calendarStartingBlock == Calendar.SUNDAY) // if SUNDAY
            {
              calendarStartingBlock = 6; // then move to the end.
            } else {
              // else normalize monday to be zero (coupled to UI)                                                           // normalize
              calendarStartingBlock = calendarStartingBlock - Calendar.MONDAY;
            }
          }
        }
  
        if (flag) // It matches one of our calendar blocks, we need to display
                  // it
        {
          // Get the blank element we stuck in there before as a placeholder
          CalendarListElement element = (CalendarListElement)calendarlist.get(new Integer(
              calendarStartingBlock));
          // monthly will only use the element at 0 on calendarlist (I guess the
          // rest is designed for that)
          if (element != null) // if the element is null then our
                                // calendarStartingBlock is totally out of
                                // whack.
          {
            int numberOfRows = 1; // assume it only takes one row
            // We probably should take account if the activity spans to a
            // different day.
            // right now this doesn't seem to accomodate that.
            int activityEndHour = endtime.get(Calendar.HOUR);
            int activityEndAMPM = endtime.get(Calendar.AM_PM);
            if (activityEndAMPM == 1) {
              activityEndHour = activityEndHour + 12;
            }
  
            // calculate the number of rows the activity spans, if it is one of
            // the daily views
            // use ceiling function, so that any activity that impinges on the
            // above activity
            // will fill that row also.
            if (totalnumberofrows == 24 || totalnumberofrows == 48 || totalnumberofrows == 96) {
              // We must have to do the ZoneOffSet and DayLight Saving to
              // Offset.
              // off zone time values we must have to add to TimeInMillis
              long startTimeValue = starttime.getTimeInMillis()
                  + starttime.get(Calendar.ZONE_OFFSET) + starttime.get(Calendar.DST_OFFSET);
              long endTimeValue = endtime.getTimeInMillis() + endtime.get(Calendar.ZONE_OFFSET)
                  + endtime.get(Calendar.DST_OFFSET);
  
              double activityDuration = endTimeValue - startTimeValue;
              numberOfRows = (int)Math.ceil(activityDuration / (timespan * 60000));
  
              // When we have Scheduling and activity for two whole day event