function mc_change_instances($id, $repeats, $begin = false)
{
    global $wpdb;
    $mcdb = $wpdb;
    $events = $mcdb->get_results("SELECT * FROM " . my_calendar_event_table() . " WHERE occur_event_id = {$id} ORDER BY occur_begin DESC");
    $count = count($events);
    $last = $count - 1;
    if ($begin == false) {
        if ($count > $repeats) {
            // if higher than previous: delete
            $diff = $count - $repeats;
            for ($i = 0; $i < $diff; $i++) {
                $oid = $events[$i]->occur_id;
                $sql = "DELETE FROM " . my_calendar_event_table() . " WHERE occur_id = {$oid}";
                $result = $mcdb->query($sql);
            }
        } else {
            if ($count < $repeats) {
                // if lower: add more by incrementing from the last date available.
                $dates = array('event_begin' => date('Y-m-d', strtotime($events[0]->occur_begin)), 'event_time' => date('H:i:s', strtotime($events[0]->occur_begin)), 'event_end' => date('Y-m-d', strtotime($events[0]->occur_end)), 'event_endtime' => date('H:i:s', strtotime($events[0]->occur_end)));
                mc_increment_event($id, $dates);
            } else {
                return false;
            }
        }
    } else {
        $sql = "DELETE FROM " . my_calendar_event_table() . " WHERE occur_event_id = {$id}";
        $delete = $mcdb->query($sql);
        $dates = array('event_begin' => date('Y-m-d', strtotime($events[$last]->occur_begin)), 'event_time' => date('H:i:s', strtotime($events[$last]->occur_begin)), 'event_end' => date('Y-m-d', strtotime($events[$last]->occur_end)), 'event_endtime' => date('H:i:s', strtotime($events[$last]->occur_end)));
        mc_increment_event($id, $dates);
    }
    return true;
}
function mc_migrate_db()
{
    global $wpdb;
    // this function migrates the DB from version 1.10.x to version 2.0.
    $tables = $wpdb->get_results("show tables;");
    foreach ($tables as $table) {
        foreach ($table as $value) {
            if ($value == my_calendar_event_table()) {
                $count = $wpdb->get_var('SELECT count(1) from ' . my_calendar_event_table());
                $count2 = $wpdb->get_var('SELECT count(1) from ' . my_calendar_table());
                if ($count2 > 0 && $count > 0) {
                    return;
                }
                if ($count2 == 0 && $count == 0) {
                    return;
                    // no events, migration unnecessary
                }
                break 2;
            }
        }
    }
    // 2) create new occurrences database, if necessary
    //dbDelta($initial_occur_db);
    // 3) migrate events
    $sql = "SELECT event_id, event_begin, event_time, event_end, event_endtime FROM " . my_calendar_table();
    $events = $wpdb->get_results($sql);
    foreach ($events as $event) {
        // assign endtimes to all events
        if ($event->event_endtime == '00:00:00' && $event->event_time != '00:00:00') {
            $event->event_endtime = date('H:i:s', strtotime("{$event->event_time} +1 hour"));
            mc_flag_event($event->event_id, $event->event_endtime);
        }
        $dates = array('event_begin' => $event->event_begin, 'event_end' => $event->event_end, 'event_time' => $event->event_time, 'event_endtime' => $event->event_endtime);
        mc_increment_event($event->event_id, $dates);
    }
}
/**
 * Test whether an event has an invalid overlap.
 * 
 * @object $data Event object
 *
 * @return string Warning text about problem with event.
 */
function mc_test_occurrence_overlap($data, $return = false)
{
    $warning = '';
    // if this event is single, skip query
    $single_recur = $data->event_recur == 'S' || $data->event_recur == 'S1' ? true : false;
    // if event starts and ends on same day, skip query
    $start_end = $data->event_begin == $data->event_end ? true : false;
    // only run test when an event is set up to recur & starts/ends on different days.
    if (!$single_recur && !$start_end) {
        $check = mc_increment_event($data->event_id, array(), 'test');
        if (my_calendar_date_xcomp($check['occur_begin'], $data->event_end . '' . $data->event_endtime)) {
            $warning = "<div class='error'><span class='problem-icon dashicons dashicons-performance'></span> <p><strong>" . __('Event hidden from public view.', 'my-calendar') . "</strong> " . __('This event ends after the next occurrence begins. Events must end <strong>before</strong> the next occurrence begins.', 'my-calendar') . "</p><p>" . sprintf(__('Event end date: <strong>%s %s</strong>. Next occurrence starts: <strong>%s</strong>', 'my-calendar'), $data->event_end, $data->event_endtime, $check['occur_begin']) . "</p></div>";
            update_post_meta($data->event_post, '_occurrence_overlap', 'false');
        } else {
            delete_post_meta($data->event_post, '_occurrence_overlap');
        }
    }
    if ($return) {
        return $warning;
    } else {
        echo $warning;
    }
}
function my_calendar_import()
{
    if (get_option('ko_calendar_imported') != 'true') {
        global $wpdb;
        $mcdb = $wpdb;
        define('KO_CALENDAR_TABLE', $mcdb->prefix . 'calendar');
        define('KO_CALENDAR_CATS', $mcdb->prefix . 'calendar_categories');
        $events = $mcdb->get_results("SELECT * FROM " . KO_CALENDAR_TABLE, 'ARRAY_A');
        $event_ids = array();
        foreach ($events as $key) {
            $endtime = $key['event_time'] == '00:00:00' ? '00:00:00' : date('H:i:s', strtotime("{$key['event_time']} +1 hour"));
            $data = array('event_title' => $key['event_title'], 'event_desc' => $key['event_desc'], 'event_begin' => $key['event_begin'], 'event_end' => $key['event_end'], 'event_time' => $key['event_time'], 'event_endtime' => $endtime, 'event_recur' => $key['event_recur'], 'event_repeats' => $key['event_repeats'], 'event_author' => $key['event_author'], 'event_category' => $key['event_category'], 'event_hide_end' => 1, 'event_link' => isset($key['event_link']) ? $key['event_link'] : '');
            $format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%s');
            $update = $mcdb->insert(my_calendar_table(), $data, $format);
            $events_results = $update ? true : false;
            $event_ids[] = $mcdb->insert_id;
        }
        foreach ($event_ids as $value) {
            // propagate event instances.
            $sql = "SELECT event_begin, event_time, event_end, event_endtime FROM " . my_calendar_table() . " WHERE event_id = {$value}";
            $event = $wpdb->get_results($sql);
            $event = $event[0];
            $dates = array('event_begin' => $event->event_begin, 'event_end' => $event->event_end, 'event_time' => $event->event_time, 'event_endtime' => $event->event_endtime);
            $event = mc_increment_event($value, $dates);
        }
        $cats = $mcdb->get_results("SELECT * FROM " . KO_CALENDAR_CATS, 'ARRAY_A');
        $catsql = "";
        foreach ($cats as $key) {
            $name = esc_sql($key['category_name']);
            $color = esc_sql($key['category_colour']);
            $id = (int) $key['category_id'];
            $catsql = "INSERT INTO " . my_calendar_categories_table() . " SET \n\t\t\t\tcategory_id='" . $id . "',\n\t\t\t\tcategory_name='" . $name . "', \n\t\t\t\tcategory_color='" . $color . "' \n\t\t\t\tON DUPLICATE KEY UPDATE \n\t\t\t\tcategory_name='" . $name . "', \n\t\t\t\tcategory_color='" . $color . "';\n\t\t\t\t";
            $cats_results = $mcdb->query($catsql);
        }
        $message = $cats_results !== false ? __('Categories imported successfully.', 'my-calendar') : __('Categories not imported.', 'my-calendar');
        $e_message = $events_results !== false ? __('Events imported successfully.', 'my-calendar') : __('Events not imported.', 'my-calendar');
        $return = "<div id='message' class='updated fade'><ul><li>{$message}</li><li>{$e_message}</li></ul></div>";
        echo $return;
        if ($cats_results !== false && $events_results !== false) {
            update_option('ko_calendar_imported', 'true');
        }
    }
}
function mc_form_fields($data, $mode, $event_id)
{
    global $wpdb, $user_ID;
    $mcdb = $wpdb;
    $has_data = empty($data) ? false : true;
    $warning = '';
    if ($data) {
        if (!($data->event_recur == 'S' || $data->event_recur == 'S1')) {
            $check = mc_increment_event($data->event_id, array(), 'test');
            if (my_calendar_date_xcomp($check['occur_begin'], $data->event_end . '' . $data->event_endtime)) {
                $warning = "<div class='updated'><p>" . __('This event ends after the next occurrence begins. Events must end <strong>before</strong> the next occurrence begins.', 'my-calendar') . "</p><p>" . sprintf(__('Event end date: <strong>%s %s</strong>. Next occurrence starts: <strong>%s</strong>', 'my-calendar'), $data->event_end, $data->event_endtime, $check['occur_begin']) . "</p></div>";
                echo $warning;
            }
        }
    }
    $instance = isset($_GET['date']) ? (int) $_GET['date'] : false;
    if ($instance) {
        $ins = mc_get_instance_data($instance);
        $event_id = $ins->occur_event_id;
        $data = mc_get_event_core($event_id);
    }
    ?>

<div class="postbox-container jcd-wide">
<div class="metabox-holder">
<?php 
    if ($mode == 'add' || $mode == 'copy') {
        $edit_args = '';
    } else {
        $edit_args = "&amp;mode={$mode}&amp;event_id={$event_id}";
        if ($instance) {
            $edit_args .= "&amp;date={$instance}";
        }
    }
    ?>
<form id="my-calendar" method="post" action="<?php 
    echo admin_url('admin.php?page=my-calendar') . $edit_args;
    ?>
">
<div>
	<input type="hidden" name="_wpnonce" value="<?php 
    echo wp_create_nonce('my-calendar-nonce');
    ?>
" />
	<?php 
    if (isset($_GET['ref'])) {
        ?>
		<input type="hidden" name="ref" value="<?php 
        echo esc_url($_GET['ref']);
        ?>
" />
	<?php 
    }
    ?>
	<input type="hidden" name="event_group_id" value="<?php 
    if (!empty($data->event_group_id) && $mode != 'copy') {
        echo $data->event_group_id;
    } else {
        echo mc_group_id();
    }
    ?>
" />
	<input type="hidden" name="event_action" value="<?php 
    echo $mode;
    ?>
" />
	<?php 
    if (!empty($_GET['date'])) {
        ?>
 
		<input type="hidden" name="event_instance" value="<?php 
        echo (int) $_GET['date'];
        ?>
" />
	<?php 
    }
    ?>
	
	<input type="hidden" name="event_id" value="<?php 
    echo (int) $event_id;
    ?>
" />
	<?php 
    if ($mode == 'edit') {
        ?>
		<input type='hidden' name='event_post' value="<?php 
        echo $data->event_post;
        ?>
" />
	<?php 
    }
    ?>
	<input type="hidden" name="event_author" value="<?php 
    if ($mode != 'edit') {
        echo $user_ID;
    } else {
        echo $data->event_author;
    }
    ?>
" />
	<input type="hidden" name="event_nonce_name" value="<?php 
    echo wp_create_nonce('event_nonce');
    ?>
" />
</div>

<div class="ui-sortable meta-box-sortables">
<div class="postbox">
	<?php 
    if (isset($_GET['mode']) && $_GET['mode'] == 'edit') {
        $text = __('Edit Event', 'my-calendar');
        $delete = " &middot; <a href='" . admin_url("admin.php?page=my-calendar-manage&amp;mode=delete&amp;event_id={$data->event_id}") . "' class='delete'>" . __('Delete', 'my-calendar') . "</a>";
    } else {
        $text = __('Add Event', 'my-calendar');
        $delete = '';
    }
    $post_id = $has_data ? $data->event_post : false;
    if ($has_data && !$data->event_post) {
        $array_data = (array) $data;
        $post_id = mc_event_post('add', $array_data, $data->event_id);
    }
    if (apply_filters('mc_use_permalinks', get_option('mc_use_permalinks')) == 'true') {
        $post_link = $post_id ? get_edit_post_link($post_id) : false;
        $text_link = $post_link ? sprintf(" &middot; <a href='%s'>" . __('Edit Event Post', 'my-calendar') . "</a>", $post_link) : '';
    } else {
        $text_link = '';
    }
    ?>
	<h3><?php 
    echo $text;
    ?>
 <span class="alignright"><a href="<?php 
    echo admin_url('admin.php?page=my-calendar-manage');
    ?>
"><?php 
    _e('Manage events', 'my-calendar');
    ?>
</a><?php 
    echo $delete;
    echo $text_link;
    ?>
</span>
</h3>
	<div class="inside">
	<?php 
    if (!empty($_GET['date']) && $data->event_recur != 'S') {
        $event = mc_get_event($instance);
        $date = date_i18n(get_option('mc_date_format'), strtotime($event->occur_begin));
        $message = __("You are editing the <strong>{$date}</strong> instance of this event. Other instances of this event will not be changed.", 'my-calendar');
        //echo "<div><input type='hidden' name='event_instance' value='$instance' /></div>";
        echo "<div class='message updated'><p>{$message}</p></div>";
    } else {
        if (isset($_GET['date']) && empty($_GET['date'])) {
            echo "<div class='message updated'><p>" . __('There was an error acquiring information about this event instance. The ID for this event instance was not provided. <strong>You are editing this entire recurrence set.</strong>', 'my-calendar') . "</p></div>";
        }
    }
    ?>
        <fieldset>
		<legend><?php 
    _e('Event Details', 'my-calendar');
    ?>
</legend>
		<p>
		<label for="e_title"><?php 
    _e('Event Title', 'my-calendar');
    ?>
 <span class='required'><?php 
    _e('(required)', 'my-calendar');
    ?>
</span></label><br /><input type="text" id="e_title" name="event_title" size="50" maxlength="255" value="<?php 
    if ($has_data) {
        echo apply_filters('mc_manage_event_title', stripslashes(esc_attr($data->event_title)), $data);
    }
    ?>
" /><?php 
    if ($mode == 'edit') {
        ?>
			<input type='hidden' name='prev_event_status' value='<?php 
        echo $data->event_approved;
        ?>
' /><?php 
        if (get_option('mc_event_approve') == 'true') {
            if (current_user_can('mc_approve_events')) {
                // Added by Roland P.
                if ($has_data && $data->event_approved == '1') {
                    $checked = " checked=\"checked\"";
                } else {
                    if ($has_data && $data->event_approved == '0') {
                        $checked = "";
                    } else {
                        if (get_option('mc_event_approve') == 'true') {
                            $checked = "checked=\"checked\"";
                        }
                    }
                }
                ?>
					<input type="checkbox" value="1" id="e_approved" name="event_approved" <?php 
                echo $checked;
                ?>
 /> <label for="e_approved"><?php 
                _e('Approve', 'my-calendar');
                ?>
</label><?php 
            } else {
                // case: editing, approval enabled, user cannot approve
                ?>
					<input type="hidden" value="0" name="event_approved" /><?php 
                _e('An administrator must approve your new event.', 'my-calendar');
            }
        } else {
            // Case: editing, approval system is disabled - auto approve
            ?>
	
				<input type="hidden" value="1" name="event_approved" /><?php 
        }
    } else {
        // case: adding new event (if use can, then 1, else 0)
        if (get_option('mc_event_approve') != 'true') {
            $dvalue = 1;
        } else {
            if (current_user_can('mc_approve_events')) {
                $dvalue = 1;
            } else {
                $dvalue = 0;
            }
        }
        ?>
				<input type="hidden" value="<?php 
        echo $dvalue;
        ?>
" name="event_approved" /><?php 
    }
    ?>
		</p>
		<?php 
    if (is_object($data) && $data->event_flagged == 1) {
        ?>
		<div class="error">
		<p>
		<input type="checkbox" value="0" id="e_flagged" name="event_flagged"<?php 
        if ($has_data && $data->event_flagged == '0') {
            echo " checked=\"checked\"";
        } else {
            if ($has_data && $data->event_flagged == '1') {
                echo "";
            }
        }
        ?>
 /> <label for="e_flagged"><?php 
        _e('This event is not spam', 'my-calendar');
        ?>
</label>
		</p>
		</div>
		<?php 
    }
    if (function_exists('jd_doTwitterAPIPost') && current_user_can('wpt_can_tweet')) {
        if (!($mode == 'edit' && $data->event_approved == 1)) {
            ?>
			<p>
			<label for='mc_twitter'><?php 
            _e('Post to Twitter (via WP to Twitter)', 'my-calendar');
            ?>
</label><br />
			<textarea cols='70' rows='2' id='mc_twitter' name='mc_twitter'><?php 
            do_action('mc_twitter_text', $data);
            ?>
</textarea>
			</p><?php 
        }
    }
    mc_show_block('event_desc', $has_data, $data);
    mc_show_block('event_short', $has_data, $data);
    mc_show_block('event_image', $has_data, $data);
    ?>
		<p>
		<label for="e_host"><?php 
    _e('Host', 'my-calendar');
    ?>
</label>
		<select id="e_host" name="event_host">
			<?php 
    // Grab all the categories and list them
    $users = my_calendar_getUsers();
    foreach ($users as $u) {
        $display_name = $u->display_name == '' ? $u->user_nicename : $u->display_name;
        if (is_object($data) && $data->event_host == $u->ID) {
            $selected = ' selected="selected"';
        } else {
            if (is_object($u) && $u->ID == $user_ID && empty($data->event_host)) {
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
        }
        echo "<option value='{$u->ID}'{$selected}>{$display_name}</option>\n";
    }
    ?>
		</select>
		</p>			
		<?php 
    mc_show_block('event_category', $has_data, $data);
    mc_show_block('event_link', $has_data, $data);
    echo apply_filters('mc_event_details', '', $has_data, $data, 'admin');
    ?>
							
	</fieldset>
</div>
</div>
</div>

<div class="ui-sortable meta-box-sortables">
<div class="postbox">
<h3><?php 
    _e('Date and Time', 'my-calendar');
    ?>
</h3>
<div class="inside">
			<?php 
    if (is_object($data)) {
        // information for rewriting recurring data
        ?>
			<input type="hidden" name="prev_event_begin" value="<?php 
        echo $data->event_begin;
        ?>
" />
			<input type="hidden" name="prev_event_time" value="<?php 
        echo $data->event_time;
        ?>
" />
			<input type="hidden" name="prev_event_end" value="<?php 
        echo $data->event_end;
        ?>
" />
			<input type="hidden" name="prev_event_endtime" value="<?php 
        echo $data->event_endtime;
        ?>
" />			
			<?php 
    }
    ?>
			<fieldset><legend><?php 
    _e('Event Date and Time', 'my-calendar');
    ?>
</legend>
			<div id="e_schedule">
			<div id="event1" class="clonedInput" aria-live="polite">
			<?php 
    echo apply_filters('mc_datetime_inputs', '', $has_data, $data, 'admin');
    ?>
			</div>
			<?php 
    if ($mode != 'edit') {
        ?>
			
			<p id="event_span">
				<input type="checkbox" value="1" id="e_span" name="event_span"<?php 
        if ($has_data && $data->event_span == '1') {
            echo " checked=\"checked\"";
        } else {
            if ($has_data && $data->event_span == '0') {
                echo "";
            } else {
                if (get_option('mc_event_span') == 'true') {
                    echo " checked=\"checked\"";
                }
            }
        }
        ?>
 /> <label for="e_span"><?php 
        _e('This is a multi-day event.', 'my-calendar');
        ?>
</label>
			</p>
			<p class="note"><em><?php 
        _e('Enter start and end dates/times for each occurrence of the event.', 'my-calendar');
        ?>
</em></p>
			<div>
				<input type="button" id="add_field" value="<?php 
        _e('Add another occurrence', 'my-calendar');
        ?>
" class="button" />
				<input type="button" id="del_field" value="<?php 
        _e('Remove last occurrence', 'my-calendar');
        ?>
" class="button" />
			</div>
			<?php 
    } else {
        ?>
			<div id='mc-accordion'>
			<?php 
        if ($data->event_recur != 'S') {
            ?>
			<h4><?php 
            _e('Scheduled dates for this event', 'my-calendar');
            ?>
</h4>
			<div>
				<?php 
            _e('Editing a single date of an event changes only that date. Editing the root event changes all events in the series.', 'my-calendar');
            ?>
			
				<ul class="columns">
					<?php 
            if (isset($_GET['date'])) {
                $date = (int) $_GET['date'];
            } else {
                $date = false;
            }
            ?>
					<?php 
            echo mc_instance_list($data->event_id, $date);
            ?>
				</ul>
			</div>
			<?php 
        }
        ?>
			<?php 
        if ($data->event_group_id != 0) {
            ?>
				<?php 
            $edit_group_url = admin_url('admin.php?page=my-calendar-groups&mode=edit&event_id=' . $data->event_id . '&group_id=' . $data->event_group_id);
            ?>
			
				<h4><?php 
            _e('Related Events:', 'my-calendar');
            ?>
 (<a href='<?php 
            echo $edit_group_url;
            ?>
'><?php 
            _e('Edit group', 'my-calendar');
            ?>
</a>)</h4>
				<div>
					<ul class="columns">
						<?php 
            mc_related_events($data->event_group_id);
            ?>
					</ul>
				</div>
				<?php 
        }
        ?>
			</div>				
			<?php 
    }
    ?>
			</div>
			</fieldset>			
		</div>
		</div>
		</div>
		<?php 
    mc_show_block('event_recur', $has_data, $data);
    mc_show_block('event_access', $has_data, $data);
    mc_show_block('event_open', $has_data, $data);
    if (mc_show_edit_block('event_location') || mc_show_edit_block('event_location_dropdown')) {
        ?>

			<div class="ui-sortable meta-box-sortables">
			<div class="postbox">
			<h3><?php 
        _e('Event Location', 'my-calendar');
        ?>
</h3>
			<div class="inside location_form">
				<fieldset>
				<legend><?php 
        _e('Event Location', 'my-calendar');
        ?>
</legend><?php 
    }
    if (mc_show_edit_block('event_location_dropdown')) {
        $locs = $mcdb->get_results("SELECT location_id,location_label FROM " . my_calendar_locations_table() . " ORDER BY location_label ASC");
        if (!empty($locs)) {
            ?>
				
				<p>
					<label for="l_preset"><?php 
            _e('Choose a preset location:', 'my-calendar');
            ?>
</label> <select name="location_preset" id="l_preset">
					<option value="none"> -- </option><?php 
            foreach ($locs as $loc) {
                echo "<option value=\"" . $loc->location_id . "\">" . stripslashes($loc->location_label) . "</option>";
            }
            ?>
				</select>
				</p><?php 
        } else {
            ?>
				<input type="hidden" name="location_preset" value="none" />
				<p><a href="<?php 
            echo admin_url('admin.php?page=my-calendar-locations');
            ?>
"><?php 
            _e('Add recurring locations for later use.', 'my-calendar');
            ?>
</a></p><?php 
        }
    } else {
        ?>
			<input type="hidden" name="location_preset" value="none" /><?php 
    }
    mc_show_block('event_location', $has_data, $data);
    if (mc_show_edit_block('event_location') || mc_show_edit_block('event_location_dropdown')) {
        ?>
					</fieldset>
				</div>
			</div>
			</div><?php 
    }
    if (mc_show_edit_block('event_specials')) {
        ?>
			
			<div class="ui-sortable meta-box-sortables">
				<div class="postbox">
				<h3><?php 
        _e('Special scheduling options', 'my-calendar');
        ?>
</h3>
					<div class="inside">		
						<fieldset>
						<legend><?php 
        _e('Special Options', 'my-calendar');
        ?>
</legend>
						<p>
						<label for="e_holiday"><?php 
        _e('Cancel this event if it occurs on a date with an event in the Holidays category', 'my-calendar');
        ?>
</label> <input type="checkbox" value="true" id="e_holiday" name="event_holiday"<?php 
        if ($has_data && $data->event_holiday == '1') {
            echo " checked=\"checked\"";
        } else {
            if ($has_data && $data->event_holiday == '0') {
                echo "";
            } else {
                if (get_option('mc_skip_holidays') == 'true') {
                    echo " checked=\"checked\"";
                }
            }
        }
        ?>
 />
						</p>
						<p>
						<label for="e_fifth_week"><?php 
        _e('If this event recurs, and falls on the 5th week of the month in a month with only four weeks, move it back one week.', 'my-calendar');
        ?>
</label> <input type="checkbox" value="true" id="e_fifth_week" name="event_fifth_week"<?php 
        if ($has_data && $data->event_fifth_week == '1') {
            echo " checked=\"checked\"";
        } else {
            if ($has_data && $data->event_fifth_week == '0') {
                echo "";
            } else {
                if (get_option('mc_no_fifth_week') == 'true') {
                    echo " checked=\"checked\"";
                }
            }
        }
        ?>
 />
						</p>
						</fieldset>
					</div>
				</div>
			</div><?php 
    } else {
        ?>
				<div>
				<input type="hidden" name="event_holiday" value="true"<?php 
        if (get_option('mc_skip_holidays') == 'true') {
            echo " checked=\"checked\"";
        }
        ?>
 />
				<input type="hidden" name="event_fifth_week" value="true"<?php 
        if (get_option('mc_no_fifth_week') == 'true') {
            echo " checked=\"checked\"";
        }
        ?>
/>
				</div><?php 
    }
    ?>
		<p>
			<input type="submit" name="save" class="button-primary" value="<?php 
    _e('Save Event', 'my-calendar');
    ?>
" />
		</p>
	</form>	
	</div>
	</div><?php 
}