<?php
	$sql1 = 'SELECT Kurz, Name FROM ObR WHERE Wert = "on" AND Sektion = "wohnen";';
	$result1 = $db->query($sql1);
	$i = 1;
	while ($nt1 = $result1->fetch_assoc()) {
		if (1 == $i) {
			echo "    <ul>\n";
			echo "        <li class=\"main_level\"><a ";
			if ("immobilien" == $_GET['section']) {
				echo "class=\"active\" ";
			}
			echo "href=\"index.php?section=immobilien\">Immobilienvermittlung</a></li>\n";
			echo "	</ul>\n";
			echo "	<ul>\n";
			$i++;
		}
		echo "		<li>\n";
		echo "			<a ";
		if (("immobilien" == $_GET['section']) AND ($nt1['Kurz'] == $_GET['topic'])) {
			echo "class=\"active\" ";
		}
		echo "href=\"index.php?section=immobilien&amp;topic=".$nt1['Kurz']."\">".$nt1['Name']."</a>\n";
		echo "		</li>\n";
	}
	if (1 !== $i) {
		echo "		<li>\n";
		echo "			<a ";
		if (("immobilien" == $_GET['section']) AND ( ('sonstige_objekte' == $_GET['topic']) OR ('gewerbe_kauf' == $_GET['topic']) OR ('gewerbe_miete' == $_GET['topic']) OR ('anlage' == $_GET['topic'] ) ) ) {
			echo "class=\"active\" ";
		}
		echo "href=\"index.php?section=immobilien&amp;topic=sonstige_objekte\">Gewerbe Objekte</a>\n";
		echo "		</li>\n";
		echo "	</ul>\n";
	}
	

	$sql3 = 'SELECT Kurz, Name FROM US WHERE Wert = "on" AND Sektion = "verwaltung" ORDER BY ID ASC';
	$result3 = $db->query($sql3);
	$i = 0;
	while ($nt3 = $result3->fetch_assoc()) {
		if (0 == $i) {
			echo "	<ul style=\"margin-top:10px;\">\n";
			echo "		<li class=\"main_level\"><a ";
			if (("verwaltung" == $_GET['section']) AND (!isset($_GET['topic']))) {
				echo "class=\"active\" ";
			}
			echo "href=\"index.php?section=verwaltung&amp;topic=".$nt3['Kurz']."\">Immobilienverwaltung</a></li>\n";
			echo "	</ul>\n";
			echo "	<ul>\n";
			$i++;
		}
		echo "		<li>\n";
		echo "			<a ";
		if (("verwaltung" == $_GET['section']) AND ($nt3['Kurz'] == $_GET['topic'])) {
			echo "class=\"active\" ";
		}
		echo "href=\"index.php?section=verwaltung&amp;topic=".$nt3['Kurz']."\">".$nt3['Name']."</a>\n";
		echo "		</li>\n";
	}
	echo "	</ul>\n";

	$sql4 = 'SELECT Kurz, Name FROM US WHERE Wert = "on" AND Sektion = "unter" ORDER BY ID ASC';
	$result4 = $db->query($sql4);
	$i = 0;
	while ($nt4 = $result4->fetch_assoc()) {
		if (0 == $i) {
			echo "	<ul style=\"margin-top:10px;\">\n";
			echo "		<li class=\"main_level\"><a ";
			if (("unter" == $_GET['section']) AND (!isset($_GET['topic']))) {
				echo "class=\"active\" ";
			}
			echo "href=\"index.php?section=unter&amp;topic=".$nt4['Kurz']."\">Das Unternehmen</a></li>\n";
			echo "	</ul>\n";
			echo "	<ul>\n";
			$i++;
		}
		echo "		<li>\n";
		echo "			<a ";
		if (("unter" == $_GET['section']) AND ($nt4['Kurz'] == $_GET['topic'])) {
			echo "class=\"active\" ";
		}
		echo "href=\"index.php?section=unter&amp;topic=".$nt4['Kurz']."\">".$nt4['Name']."</a>\n";
		echo "		</li>\n";
	}
	echo "	</ul>\n";

?>
