$x = 1;
         while ($cal->get_calendar_by_name($new_cal_name)) {
             $new_cal_name = $cal_name . ' (' . $x . ')';
             $x++;
         }
         $calendar_id = $cal->add_calendar($GO_SECURITY->user_id, addslashes($new_cal_name), 7, 20);
         $dropbox->add_value($calendar_id, $new_cal_name);
     } else {
         $calendar_id = $first_writable_cal;
     }
 }
 if (count($event['calendars']) == 0) {
     $event['calendars'][] = $calendar_id;
 }
 for ($i = 0; $i < count($event['calendars']); $i++) {
     if (!$dropbox->is_in_dropbox($event['calendars'][$i])) {
         echo '<input type="hidden" name="calendars[]" value="' . $event['calendars'][$i] . '" />';
     }
 }
 echo '<tr><td valign="top">' . $sc_put_in . ':</td>';
 echo '<td><table border="0">';
 $dropbox->print_dropbox('calendars[]', $event['calendars'], '', true, '5', '200');
 echo '</table></td></tr>';
 echo '<tr><td colspan="2">';
 $button = new button($cmdOk, "javascript:save_event('true');");
 echo '&nbsp;&nbsp;';
 $button = new button($cmdApply, "javascript:save_event('false');");
 echo '&nbsp;&nbsp;';
 $button = new button($cmdSave, "javascript:document.event_form.emptyform.value='true';save_event('false');");
 echo '&nbsp;&nbsp;';
 if ($event_id > 0) {