/**
 * Main search page. Allows the user to search the forum according to criteria.
 */
function template_searchform()
{
    global $context, $settings, $txt, $scripturl, $modSettings;
    echo '
				<form action="', $scripturl, '?action=search;sa=results" method="post" accept-charset="UTF-8" name="searchform" id="searchform" class="standard_category">
					<h2 class="category_header', !empty($settings['use_buttons']) ? ' hdicon cat_img_search' : '', '">
						', $txt['set_parameters'], '
					</h2>';
    // Any search errors to inform the user about
    if (!empty($context['search_errors'])) {
        echo '
					<p class="errorbox">', implode('<br />', $context['search_errors']['messages']), '</p>';
    }
    // Start off showing our basic search form
    echo '
					<fieldset id="simple_search" class="content">
						<div id="search_term_input">
							<label for="search">
								<strong>', $txt['search_for'], '</strong>
							</label>:
							<input type="search" id="search" class="input_text" name="search" value="', $context['search_params']['search'], '" maxlength="', $context['search_string_limit'], '" size="40" placeholder="' . $txt['search'] . '" required="required" autofocus="autofocus" />', '
							<input id="submit" type="submit" name="s_search" value="' . $txt['search'] . '" class="button_submit"/>
						</div>';
    if (empty($modSettings['search_simple_fulltext'])) {
        echo '
						<p class="smalltext">', $txt['search_example'], '</p>';
    }
    // Does the search require a visual verification screen to annoy them?
    if ($context['require_verification']) {
        template_verification_controls($context['visual_verification_id'], '
						<div class="verification">
							<strong>' . $txt['search_visual_verification_label'] . ':</strong>
							<br />', '
						</div>');
    }
    // All of the advanced options, this div is collapsed by the JS when available
    echo '
						<div id="advanced_search" class="content">
							<dl id="search_options">
								<dt class="righttext"><label for="searchtype">
									', $txt['search_match'], ':</label>
								</dt>
								<dd>
									<select name="searchtype" id="searchtype">
										<option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['all_words'], '</option>
										<option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['any_words'], '</option>
									</select>
								</dd>
								<dt class="righttext">
									<label for="userspec">', $txt['by_user'], ':</label>
								</dt>
								<dd>
									<input id="userspec" type="text" name="userspec" value="', $context['search_params']['userspec'], '" size="40" class="input_text" />
								</dd>
								<dt class="righttext">
									<label for="sort">', $txt['search_order'], ':</label>
								</dt>
								<dd>
									<select id="sort" name="sort">
										<option value="relevance|desc">', $txt['search_orderby_relevant_first'], '</option>
										<option value="num_replies|desc">', $txt['search_orderby_large_first'], '</option>
										<option value="num_replies|asc">', $txt['search_orderby_small_first'], '</option>
										<option value="id_msg|desc">', $txt['search_orderby_recent_first'], '</option>
										<option value="id_msg|asc">', $txt['search_orderby_old_first'], '</option>
									</select>
								</dd>
								<dt class="righttext options">
									', $txt['search_options'], ':
								</dt>
								<dd class="options">
									<label for="show_complete">', $txt['search_show_complete_messages'], '
										<input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked="checked"' : '', ' class="input_check" />
									</label><br />
									<label for="subject_only">', $txt['search_subject_only'], '
										<input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked="checked"' : '', ' class="input_check" />
									</label>
								</dd>
								<dt class="righttext between">
									', $txt['search_post_age'], ':
								</dt>
								<dd><label for="minage">
									', $txt['search_between'], '</label><input type="text" name="minage" id="minage" value="', $context['search_params']['minage'], '" size="5" maxlength="4" class="input_text" />&nbsp;<label for="maxage">', $txt['search_and'], '&nbsp;</label><input type="text" name="maxage" id="maxage" value="', $context['search_params']['maxage'], '" size="5" maxlength="4" class="input_text" /> ', $txt['days_word'], '
								</dd>
							</dl>
						</div>
						<a id="upshrink_link" href="', $scripturl, '?action=search;advanced" class="linkbutton" style="display:none">', $txt['search_simple'], '</a>';
    // Set the initial search style for the form
    echo '
						<input id="advanced" type="hidden" name="advanced" value="1" />';
    // If $context['search_params']['topic'] is set, that means we're searching just one topic.
    if (!empty($context['search_params']['topic'])) {
        echo '
						<p>', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.</p>
						<input type="hidden" name="topic" value="', $context['search_topic']['id'], '" />';
    }
    echo '
					</fieldset>';
    // This starts our selection area to allow searching by specific boards
    if (empty($context['search_params']['topic'])) {
        echo '
					<fieldset id="pick_boards" class="content">';
        template_pick_boards('searchform');
        echo '
					</fieldset>';
    }
    echo '
				</form>';
    // And now all the JS to make this work
    addInlineJavascript('
		createEventListener(window);
		window.addEventListener("load", initSearch, false);

		var oAddMemberSuggest = new smc_AutoSuggest({
			sSelf: \'oAddMemberSuggest\',
			sSessionId: elk_session_id,
			sSessionVar: elk_session_var,
			sControlId: \'userspec\',
			sSearchType: \'member\',
			bItemList: false
		});

		// Set the search style
		document.getElementById(\'advanced\').value = "' . (empty($context['minmax_preferences']['asearch']) ? '1' : '0') . '";

		// And allow for the collapsing of the advanced search options
		var oSearchToggle = new elk_Toggle({
			bToggleEnabled: true,
			bCurrentlyCollapsed: ' . (empty($context['minmax_preferences']['asearch']) ? 'false' : 'true') . ',
			funcOnBeforeCollapse: function () {
				document.getElementById(\'advanced\').value = \'0\';
			},
			funcOnBeforeExpand: function () {
				document.getElementById(\'advanced\').value = \'1\';
			},
			aSwappableContainers: [
				\'advanced_search\'
			],
			aSwapLinks: [
				{
					sId: \'upshrink_link\',
					msgExpanded: ' . JavaScriptEscape($txt['search_simple']) . ',
					msgCollapsed: ' . JavaScriptEscape($txt['search_advanced']) . '
				}
			],
			oThemeOptions: {
				bUseThemeSettings: ' . ($context['user']['is_guest'] ? 'false' : 'true') . ',
				sOptionName: \'minmax_preferences\',
				sSessionId: elk_session_id,
				sSessionVar: elk_session_var,
				sAdditionalVars: \';minmax_key=asearch\'
			},
		});', true);
}
/**
 * Display a list of boards so a user can choose to ignore some
 */
function template_ignoreboards()
{
    global $txt, $scripturl;
    // The main containing header.
    echo '
	<form action="', $scripturl, '?action=profile;area=ignoreboards;save" method="post" accept-charset="UTF-8" name="creator" id="creator">
		<h2 class="category_header hdicon cat_img_profile">
			', $txt['profile'], '
		</h2>
		<p class="description">', $txt['ignoreboards_info'], '</p>
		<div class="windowbg2">
			<div class="content flow_hidden">';
    template_pick_boards('creator', 'ignore_brd', false);
    // Show the standard "Save Settings" profile button.
    template_profile_save();
    echo '
			</div>
		</div>
	</form>
	<br />';
}