<?php

function mp_filter_drop_down($key, &$filter) {

	$content = '
		<select
			form="ljdp_form"
			class="filter_menu filter_menu_drop"
		>
			<option
				selected
				onclick="filter_show_only_selection(this, '.json_encode(array()).', '."'".$key."'".')"
			>
				'.$key.'
			</option>
	';
	foreach ($filter as $value) {
		$content .= '
			<option
				onclick="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".')"
			>
				'.$value->_name.'
			</option>
		';
	}
	$content .= '
		</select>
	';

	return $content;
};

function mp_filter_buttons($key, &$filter) {

	$content = '';
	foreach ($filter as $value) {
		$content .= '
			<input
				type="checkbox"
				form="ljdp_form"
				id="checkbox_'.$value->_name.'"
				class="filter_menu_checkbox"
				onclick="filter_show_only_selection(this, '.json_encode($value->indexes).', '."'".$key."'".', true)"
				style="display:none;"
			>
			<label
				for="checkbox_'.$value->_name.'"
				class="filter_menu filter_menu_checkbox"
			>
				<p>'.$value->_name.'</p>
			</label>
		';
	}

	return $content;
};

function mp_create_div(&$filters) {
	$mp_map_div  = '
		<div id="ljdp_map_wrapper">
			<form id="ljdp_form" style="display:none;"></form>
			<div id="ljdp_map_filters">
	';

	foreach ($filters as $key => $filter) {

		if ($key == "mode")
			$mp_map_div .= mp_filter_buttons($key, $filter);
		else
			$mp_map_div .= mp_filter_drop_down($key, $filter);
	};

	$mp_map_div .= '
				<input
					type="reset"
					form="ljdp_form"
					id="filter_menu_reset"
					class="filter_menu_button"
					onclick="filter_show_all()"
					style="display:none;"
				>
				<label
					for="filter_menu_reset"
					class="filter_menu filter_menu_reset"
				>
					<p>Éffacer</p>
				</label>
	';

	$mp_map_div .= '
			</div>
			<div id="ljdp_map"></div>
		</div>
	';

	return $mp_map_div;
};


	//	// version div title
	//	
	//	$content .= '
	//		<div class="filter_menu" style="display:none;">
	//			<div class="filter_menu_drop">
	//				<p class="filter_menu_drop_title" tabindex=0>'.$key.'</p>
	//				<p onclick="filter_show_all()">TOUT DESELECTIONNER</p>
	//	';
	//	foreach ($filter as $value) {
	//		$content .= '
	//				<p onclick="filter_show_only_selection('.json_encode($value->indexes).', false)">'.$value->_name.'</p>
	//		';
	//	}
	//	$content .= '
	//			</div>
	//		</div>
	//	';


	//	// version input checkbox
	//	
	//	$content .= '
	//		<div class="filter_menu">
	//			<input  id="filter_menu_title_${key}" class="filter_menu_title" type="checkbox" />
	//			<label for="filter_menu_title_${key}" class="filter_menu_title">
	//				<p>'.$key.'</p>
	//			</label>
	//			<div class="filter_menu_drop">
	//	';
	//	foreach ($filter as $value) {
	//		$content .= '
	//				<p>'.$value._name.'</p>
	//		';
	//	}
	//	$content .= '
	//			</div>
	//		</div>
	//	';


	//	// version select
	//	
	//	$content .= '
	//		<div class="filter_menu">
	//			<select id="filter_menu_drop_'.$key.'" class="filter_menu_drop" name="'.$key.'">
	//	';
	//	foreach ($filter as $value) {
	//		$content .= '
	//				<option value="'.$value._name.'"><p>'.$value._name.'</p></option>
	//		';
	//	}
	//	$content .= '
	//			</select>
	//		</div>
	//	';

?>
