<!DOCTYPE HTML>
<html lang="la">
<head>
	<title>Index generalis Vocis Latinae – Diplomata</title>
	<meta name="author" content="Bernd Platzdasch"><!-- 15.9.2015 -->
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="css/main.css">
	<link rel="stylesheet" type="text/css" href="css/idx.css">
	<script src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
	<script src="js/store.js" type="text/javascript"></script>
	<style type="text/css">
		table#daten td { padding-bottom: 0.6em; }
		tr { display: none; }
		span.stelle { color: gray; }
		span.pointer { cursor: pointer; }
	</style>
	<?php
		//
		require_once $_SERVER['DOCUMENT_ROOT'] . '/db_connection.php';
		//
		$sql_select = "SELECT * FROM voxlatina WHERE Textgattung = 'Diploma' ORDER BY Faszikel, Objektzaehler";
		$sql_result = $db->query($sql_select);
		$insgesamt = $sql_result->num_rows;
	?>
	<script>
		function markiere() {	
			var url = window.location.href;
			if (url.indexOf("?") != -1) {
				var url = url.substring(url.indexOf("?")+1,url.length);
				var url = ">" + decodeURIComponent((url+'').replace(/\+/g, '%20')) + "<";
				
				$("h1").text("Diplomata electa");
				$("#sursum").css("display", "none");
				var alleTabZellen = document.getElementsByClassName("output");
				var alleTabZaehler = document.getElementsByClassName("zaehler");
				var zaehler = 1;
				for(var i = 0, l = alleTabZellen.length; i < l; i++) {
					if (alleTabZellen[i].innerHTML.indexOf(url) > -1) {
						alleTabZaehler[i].innerHTML = zaehler + ".";
						zaehler++;
						alleTabZellen[i].parentElement.style.display = "block";
					}
				}
			} else {
				$("tr").css("display", "block");
			}
		}
	</script>
</head>
<body onload="store_mnu(); markiere();">
	<?php
		include("header.inc.php");
		include("php/namen.inc.php");
	?>
	<div class="border">
		<div id="main">
			<h1>Diplomata</h1>
			<?php
					$zaehler = 0;
					echo "<table id='daten'>";
					while ($row = $sql_result->fetch_object()) {
						$zaehler++;
						$bis = $autor = $briefempfaenger = $titel = $ort = $briefdatum = $url = $a_tag_ende = $aut_emp = $ort_dat = "";
						$bis = $row->Bis;
						$p = ", p. ";
						if ($bis != "") { $bis = "–" . $bis; $p = ", pp. "; }
						if ($row->Autor != "") {
							$autor = erster_name($row->Autor);
							$autor = vorname_nachname($autor);
							$autor = htmlspecialchars($autor, ENT_QUOTES);
							$autor_ganz = alle_namen($autor, $row->Autor);
							$autor_ganz = htmlspecialchars($autor_ganz, ENT_QUOTES);
							$autor = "<span class='pointer' title='" . $autor_ganz . "'>" . $autor . "</span> ";
							
						}
						if ($row->Briefempfaenger != "") {
							$empfaenger = erster_name($row->Briefempfaenger);
							$empfaenger = vorname_nachname($empfaenger);
							$empfaenger= htmlspecialchars($empfaenger, ENT_QUOTES);
							$empfaenger_ganz = alle_namen($empfaenger, $row->Briefempfaenger);
							$empfaenger_ganz= htmlspecialchars($empfaenger_ganz, ENT_QUOTES);
							$briefempfaenger = "  → <span class='pointer' title='" . $empfaenger_ganz . "'>" . $empfaenger . "</span>";
						}
						$titel = trim($row->Titel);
						if ($titel != "") {
							$titel= htmlspecialchars($titel, ENT_QUOTES);
							$titel = $titel . "<br>";
							
						}
						if ($row->Ort != "") {
							$ort = erster_name($row->Ort);
							$ort= htmlspecialchars($ort, ENT_QUOTES);
							$ort_ganz = $row->Ort;
							$ort_ganz= htmlspecialchars($ort_ganz, ENT_QUOTES);
							$ort = "<span class='pointer' title='" . $ort_ganz . "'>" . $ort . "</span>";
						}
						if ($row->Briefdatum != "") {
							$briefdatum = $row->Briefdatum;
							$briefdatum = str_replace("00.", "", $briefdatum);
						}
						if ($navigatrum == 1) {
							$fasc_000 = str_pad($row->Faszikel, 3, '0', STR_PAD_LEFT);
							$seite_000 = str_pad($row->Seite, 3, '0', STR_PAD_LEFT);
							$url = "<a href='navigatrum.html?$fasc_000$seite_000'>";
							$a_tag_ende = "</a>";
						}
						$aut_emp = $autor . $briefempfaenger;
						if ($aut_emp != "") { $aut_emp = $aut_emp . "<br>";}
						
						if (($ort != "") AND ($briefdatum !="")) { $ort = $ort . ", "; }
						$ort_dat = $ort . $briefdatum;
						if ($ort_dat != "") { $ort_dat = $ort_dat . "<br>";}
						echo "<tr>
								<td class='zaehler'>" . $zaehler . ". </td>
								<td class='output'>" . $aut_emp . $titel . $ort_dat .
									"<span class='stelle'>&#160;&#160;&#160;"
									. $url . "fasc. " . $row->Faszikel . " (tom. " . $row->Band . ", a. ". $row->Jahr . ")" .$p . $row->Seite . $bis . $a_tag_ende . "</span>" .	
								"</td>
							</tr>";
						}
						echo "</table>";
					$db->close();
				?>
			<p>&#160;</p>
			<p id='sursum'><a href='javascript:window.scrollTo(0, 0);'>sursum</a></p>
			<p>&#160;</p>
		</div>
	</div>
	<?php include("footer.inc.php");?>
</body>
</html>