function amr_whats_in_use()
{
    global $amr_options;
    amr_set_defaults();
    // $amr_options will be set, don't fetch other options yet
    $defaults = $amr_options;
    $desc = amr_set_helpful_descriptions();
    $amr_options = amr_getset_options(false);
    $inuse = get_option('amr-event-fields-in-use');
    // overlay any existing
    // get all fields that have a column
    if (empty($inuse)) {
        $inuse = array();
    }
    foreach ($amr_options['listtypes'] as $i => $l) {
        // foreach list
        if (isset($l['compprop'])) {
            foreach ($l['compprop'] as $f => $opt) {
                if (empty($opt['Column'])) {
                    if (empty($allfieldsinuse[$f])) {
                        $allfieldsinuse[$f] = 0;
                    }
                } else {
                    if (empty($allfieldsinuse[$f])) {
                        $allfieldsinuse[$f] = 1;
                    } else {
                        $allfieldsinuse[$f]++;
                    }
                }
            }
        }
    }
    // any new defaults ?
    foreach ($defaults['listtypes'] as $i => $l) {
        if (isset($l['compprop'])) {
            foreach ($l['compprop'] as $f => $opt) {
                if (!isset($allfieldsinuse[$f])) {
                    $allfieldsinuse[$f] = 0;
                }
            }
        }
    }
    // check descriptions just in case ? - no also has componemts
    /*	foreach  ($desc as $i=> $l) {
    		if (empty($allfieldsinuse[$i]))
    			$allfieldsinuse[$i] = 0;
    	}	
    */
    if (!empty($inuse)) {
        // we already got somethingstored
        foreach ($inuse as $i => $l) {
            if (!isset($allfieldsinuse[$i])) {
                // its no longer possible, delete it
                unset($inuse[$i]);
            }
        }
    } else {
        $inuse = array();
    }
    // no option yet
    foreach ($allfieldsinuse as $i => $l) {
        // for all the fields we know about
        if (!isset($inuse[$i])) {
            // is maybe new? - not empty because thats just what we set before
            $inuse[$i] = $allfieldsinuse[$i];
        }
    }
    //	var_dump($inuse);
    array_multisort(array_values($inuse), SORT_DESC, array_keys($inuse), SORT_ASC, $inuse);
    return $inuse;
}
function amr_ical_general_form()
{
    global $amr_csize, $amr_calprop, $amr_formats, $amr_limits, $amr_compprop, $amr_groupings, $amr_components, $amr_options, $amr_globaltz;
    $amr_options = amr_getset_options(false);
    $amr_ical_image_settings = get_option('amr-ical-images-to-use');
    if (empty($amr_ical_image_settings['images_size'])) {
        $imagesize = '16';
    } else {
        $imagesize = (int) $amr_ical_image_settings['images_size'];
    }
    $gentext = __('General Options', 'amr-ical-events-list');
    $styletext = __('Styling and Images', 'amr-ical-events-list');
    $advtext = __('Advanced', 'amr-ical-events-list');
    $managetext = __('Manage Event List Types', 'amr-ical-events-list');
    echo '<div>
		<a title="' . $gentext . '" href="#amrglobal">' . $gentext . '</a> | ' . '<a title="' . $styletext . '" href="#amrstyle">' . $styletext . '</a> | ' . '<a title="' . $advtext . '" href="#amradvanced">' . $advtext . '</a> | ' . '<a title="' . $managetext . '" href="' . admin_url('admin.php?page=manage_event_listing') . '">' . $managetext . '</a>
		
		<fieldset id="amrglobal"><h3>' . $gentext . '</h3>';
    echo '<div class="postbox" style="padding:1em 2em; width: 600px;">

			<label for="noeventsmessage">';
    _e('Message if no events found: ', 'amr-ical-events-list');
    ?>
</label><br />
			<input class="wide regular-text" type="text" id="noeventsmessage" name="noeventsmessage"
			<?php 
    if (isset($amr_options['noeventsmessage']) and $amr_options['noeventsmessage']) {
        echo 'value="' . $amr_options['noeventsmessage'] . '"';
    }
    ?>
/>
			<br />
			<label for="lookmoresmessage">
			<?php 
    _e('Look for more events message: ', 'amr-ical-events-list');
    ?>
</label><br />
			<input class="wide regular-text" type="text" id="lookmoremessage" name="lookmoremessage"
			<?php 
    if (isset($amr_options['lookmoremessage']) and $amr_options['lookmoremessage']) {
        echo 'value="' . $amr_options['lookmoremessage'] . '"';
    }
    ?>
/>
			<br />
			<label for="lookprevmessage">
			<?php 
    _e('Look for previous events message: ', 'amr-ical-events-list');
    ?>
</label><br />
			<input class="wide regular-text" type="text" id="lookprevmessage" name="lookprevmessage"
			<?php 
    if (isset($amr_options['lookprevmessage']) and $amr_options['lookprevmessage']) {
        echo 'value="' . $amr_options['lookprevmessage'] . '"';
    }
    ?>
/>
			<br />
			<label for="resetmessage">
			<?php 
    _e('Reset events message: ', 'amr-ical-events-list');
    ?>
</label><br />
			<input class="wide regular-text" type="text" id="resetmessage" name="resetmessage"
			<?php 
    if (isset($amr_options['resetmessage']) and $amr_options['resetmessage']) {
        echo 'value="' . $amr_options['resetmessage'] . '"';
    }
    ?>
/>
			<br />
			<label for="freebusymessage">
			<?php 
    _e('Free busy text: ', 'amr-ical-events-list');
    _e(' - replaces the summary text (Busy)in a VFREEBUSY component.', 'amr-ical-events-list');
    ?>
</label><br />
			<input class="wide regular-text" type="text" id="freebusymessage" name="freebusymessage"
			<?php 
    if (isset($amr_options['freebusymessage']) and $amr_options['freebusymessage']) {
        echo 'value="' . $amr_options['freebusymessage'] . '"';
    }
    ?>
/>
			<br />

			<label for="usehumantime">
			<input type="checkbox" id="usehumantime" name="usehumantime" value="usehumantime"
			<?php 
    if (isset($amr_options['usehumantime']) and $amr_options['usehumantime']) {
        echo 'checked="checked"';
    }
    ?>
/> <?php 
    _e('Use human time like midday, midnight', 'amr-ical-events-list');
    ?>
</label>			
			
			<label for="ngiyabonga">
			<input type="checkbox" id="ngiyabonga" name="ngiyabonga" value="ngiyabonga"
			<?php 
    if (isset($amr_options['ngiyabonga']) and $amr_options['ngiyabonga']) {
        echo 'checked="checked"';
    }
    ?>
/> <?php 
    _e('Do not give credit to the author', 'amr-ical-events-list');
    ?>
</label>

			</div>
			</fieldset>
			<fieldset id="amrstyle"><h3><?php 
    echo $styletext;
    ?>
</h3>
			<div class="postbox" style="padding:1em 2em; width: 600px;">
				<label for="do_groupingjs">
				<input type="checkbox" id="do_grouping_js" name="do_grouping_js" value="do_grouping_js"
				<?php 
    if (!empty($amr_options['do_grouping_js']) and $amr_options['do_grouping_js']) {
        echo 'checked="checked"';
    }
    ?>
/> <?php 
    _e('Use javascript to collapse event groupings', 'amr-ical-events-list');
    ?>
</label>
				<br />

				<label for="own_css">
				<input type="checkbox" id="own_css" name="own_css" value="own_css"
				<?php 
    if (isset($amr_options['own_css']) and $amr_options['own_css']) {
        echo 'checked="checked"';
    }
    ?>
/> <?php 
    _e('Use my theme css, not plugin css', 'amr-ical-events-list');
    $files = amr_get_css_url_choices();
    ?>
</label>
				<br />
				<label for="no_images">
				<input type="checkbox" id="no_images" name="no_images" value="true"
				<?php 
    if (isset($amr_options['no_images']) and $amr_options['no_images']) {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    _e(' No images (tick for text only)', 'amr-ical-events-list');
    ?>
</label>
				<br />
				<br />

				<label for="images_size16">
				<?php 
    _e('Image icon size:', 'amr-ical-events-list');
    ?>
				<input type="radio" id="images_size16" name="images_size" value="16"
				<?php 
    if ($imagesize == '16') {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    _e('16', 'amr-ical-events-list');
    ?>
</label>
				<label for="images_size32">
				<input type="radio" id="images_size32" name="images_size" value="32"
				<?php 
    if ($imagesize == '32') {
        echo 'checked="checked"';
    }
    ?>
/><?php 
    _e('32', 'amr-ical-events-list');
    ?>
</label>
			<p><em><?php 
    _e('The css provided works with the default twenty-ten theme and similar themes.  Your theme may be different.', 'amr-ical-events-list');
    echo ' ';
    _e('To edit the file, download the custom one added to your uploads folder: uploads/css.', 'amr-ical-events-list');
    echo ' ';
    _e('Edit it and then re-upload to that same folder. Then select it in the box below.', 'amr-ical-events-list');
    echo ' ';
    _e('This file will not be overwritten when the plugin is upgraded or when your theme is upgraded. ', 'amr-ical-events-list');
    ?>
</em>
			<a href="http://icalevents.com/?s=css"><?php 
    _e('More info', 'amr-ical-events-list');
    ?>
</a></p>
			<p>
			<a href="<?php 
    echo ICALLISTPLUGINURL . 'css/icallist.css';
    ?>
"><?php 
    _e('Download the latest provided css file for editing', 'amr-ical-events-list');
    ?>
</a><?php 
    echo ' ';
    _e('(optional)', 'amr-ical-events-list');
    ?>
</p>
			<label for="cssfile"><?php 
    _e('Choose plugin default css or choose a custom css and edit it.', 'amr-ical-events-list');
    ?>
</label>
			<select id="cssfile" name="cssfile" ><?php 
    if (empty($files)) {
        echo AMR_NL . ' <option value="">' . __('No css files found in css directory ', 'amr-ical-events-list') . $dir . ' ' . $files . '</option>';
    } else {
        foreach ($files as $ifile => $file) {
            echo AMR_NL . ' <option value="' . $file . '"';
            if (isset($amr_options['cssfile']) and $amr_options['cssfile'] == $file) {
                echo ' selected="selected" ';
            }
            echo '>' . $file . '</option>';
        }
    }
    ?>
</select>

</div></fieldset>
<fieldset id="amradvanced">
<h3><?php 
    _e('Advanced:', 'amr-ical-events-list');
    ?>
</h3><div class="postbox" style="padding:1em 2em; width: 600px;">
<?php 
    printf(__('Your php version is: %s', 'amr-ical-events-list'), phpversion());
    ?>
<br /><?php 
    if (version_compare('5.3', PHP_VERSION, '>')) {
        echo '<b>' . __('Minimum Php version 5.3 required for events cacheing. ', 'amr-ical-events-list') . '</b>';
        _e('Cacheing of generated events for re-use on same page (eg: widget plus list) will not be attempted. ', 'amr-ical-events-list');
        _e('Apparently objects do not serialise correctly in php < 5.3.', 'amr-ical-events-list');
        echo '<br /><br />';
    }
    amr_check_timezonesettings();
    $now = date_create('now', $amr_globaltz);
    ?>
<br /><br /><?php 
    _e('Choose date localisation method:', 'amr-ical-events-list');
    ?>
<a href="http://icalevents.com/2044-date-and-time-localisation-in-wordpress/"><b>?</b></a><br />
			<br /><label for="no_localise"><input type="radio" id="no_localise" name="date_localise" value="none" <?php 
    if ($amr_options['date_localise'] === "none") {
        echo ' checked="checked" ';
    }
    ?>
 />
			<?php 
    _e('none', 'amr-ical-events-list');
    echo ' - ' . amr_format_date('r', $now);
    ?>
</label>
			<br /><label for="am_localise"><input type="radio" id="am_localise" name="date_localise" value="amr" <?php 
    if ($amr_options['date_localise'] === "amr") {
        echo ' checked="checked" ';
    }
    ?>
 />
			<?php 
    _e('amr', 'amr-ical-events-list');
    echo ' - ' . amr_date_i18n('r', $now);
    ?>
</label>
			<br /><label for="wp_localise"><input type="radio" id="wp_localise" name="date_localise" value="wp" <?php 
    if ($amr_options['date_localise'] === "wp") {
        echo ' checked="checked" ';
    }
    ?>
 />
			<?php 
    _e('wp', 'amr-ical-events-list');
    echo ' - ' . amr_wp_format_date('r', $now, false);
    ?>
</label>
			<br /><label for="wpg_localise"><input type="radio" id="wpg_localise" name="date_localise" value="wpgmt" <?php 
    if ($amr_options['date_localise'] === "wpgmt") {
        echo ' checked="checked" ';
    }
    ?>
 />
			<?php 
    _e('wpgmt', 'amr-ical-events-list');
    echo ' - ' . amr_wp_format_date('r', $now, true);
    ?>
</label>
		<br /><br /><br />	
		<?php 
    //
    _e('Http timeout for external ics files:', 'amr-ical-events-list');
    $options = array('5', '8', '10', '20', '30', '1');
    if (!isset($amr_options['timeout'])) {
        $amr_options['timeout'] = 5;
    }
    ?>
<br /><br />	
		<label for="timeout"><?php 
    _e('Choose seconds before timeout for each ics file fetch', 'amr-ical-events-list');
    ?>
</label>
			<select id="timeout" name="timeout" ><?php 
    foreach ($options as $i => $sec) {
        echo '<option value="' . $sec . '"';
        if (isset($amr_options['timeout']) and $amr_options['timeout'] == $sec) {
            echo ' selected="selected" ';
        }
        echo '>' . $sec . '</option>';
    }
    ?>
</select><br />
		<em><?php 
    _e('Warning - 30 seconds is a long time! Let it use cache rather if things are slow', 'amr-ical-events-list');
    ?>
</em>	
		</div>
		</fieldset>
	</div>
<?php 
}