<!DOCTYPE html>
<html lang="la">
<head>
	<title>Index generalis Civis Romani et Scriptoris Latini – Versiones eligere</title>
	<meta name="author" content="Bernd Platzdasch"><!-- 27.1.2015 // 22.7.2015 // 4.11.2018 // 31.12.2020 // 8.4.2021 -->
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="css/main.css">
	<link rel="stylesheet" type="text/css" href="css/sev.css">
	<script type="text/javascript" src="js/jquery-1.11.2.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/jquery-ui-1.11.4.custom/jquery-ui.min.js"></script>
	<link rel="stylesheet" type="text/css" href="js/jquery-ui-1.11.4.custom/jquery-ui.css">
	<script src="js/store.js" type="text/javascript"></script>
	<style type="text/css">
		td.labelausg { width: 10em; }
		span.gray { color: gray; }
		li.ui-menu-item { font-size: small !important; }
		#dig1, #dig2, #linO, #linV, #ord { width: 12em; }
	</style>
	<?php
// Debugging:
// error_reporting(E_ALL);
// ini_set('display_errors', true);	
		include("php/sql_select.inc.php");
		//
		$PHP_SELF = $_SERVER ["PHP_SELF"];
		// "0" = Skript wird erstmals aufgerufen:
		if (!isset($_POST ["sent"])) { $sent = 0; } else { $sent = 1; }
		// Automatische Suche über Klick gestatten:
// 		$sent = 1;
		$auto = 0;
		if (isset($_POST ["aucO"])) { $aucO = $_POST ["aucO"];} else { if (isset($_GET ["aucO"])) { $aucO = $_GET ["aucO"]; $auto = 1;} else {$aucO="";} }
		$titO = (isset($_POST ["titO"])) ? $_POST ["titO"] : "";
		$linO = (isset($_POST ["linO"])) ? $_POST ["linO"] : "";
		if (isset($_POST ["aucV"])) { $aucV = $_POST ["aucV"];} else { if (isset($_GET ["aucV"])) { $aucV = $_GET ["aucV"]; $auto = 1;} else {$aucV="";} }
//		$titV = (isset($_POST ["titV"])) ? $_POST ["titV"] : "";
		if (isset($_POST ["titV"])) { $titV = $_POST ["titV"];} else { if (isset($_GET ["titV"])) { $titV = $_GET ["titV"]; $auto = 1;} else {$titV="";} }
		$linV = (isset($_POST ["linV"])) ? $_POST ["linV"] : "";
		$dig1 = (isset($_POST ["dig1"])) ? $_POST ["dig1"] : "";
		$dig2 = (isset($_POST ["dig2"])) ? $_POST ["dig2"] : "";
		$ord = (isset($_POST ["ord"])) ? $_POST ["ord"] : "ASC";
		//
		$sel = (isset($_POST ["sel"])) ? $_POST ["sel"] : 1;
		$bl = (isset($_POST ["bl"])) ? $_POST ["bl"] : "";
		$anf = (isset($_POST ["anf"])) ? $_POST ["anf"] : "";
		$zur = (isset($_POST ["zur"])) ? $_POST ["zur"] : "";
		$vor = (isset($_POST ["vor"])) ? $_POST ["vor"] : "";
		$end = (isset($_POST ["end"])) ? $_POST ["end"] : "";
		//
		if (($bl == "l◄") AND ($anf != "")) { $sel = 1; }
		if (($bl == "►") AND ($vor != "")) { $sel = $vor; }
		if (($bl == "◄") AND ($zur != "")) { $sel = $zur; }
		if (($bl == "►l") AND ($end != "")) { $sel = $end; }
		//
		$aucO = addslashes($aucO);
		$titO = addslashes($titO);
		$aucV = addslashes($aucV);
		$titV = addslashes($titV);
		$anz_angezeigte = 0;
		//
		 if ($sent == 1) {
			//
			$colOriginalautor = "style='background: #fff; color: #000;'";
			$colOriginaltitel = "style='background: #fff; color: #000;'";
			$colAutor = "style='background: #fff; color: #000;'";
			$colTitel = "style='background: #fff; color: #000;'";
			$colFaszikel = "style='background: #fff; color: #000;'";
			$bgcolor = "style='background: #f4f4f4; color: green;'";
			switch ($dig1) {
				case "Originalautor": $colOriginalautor = $bgcolor; break;
				case "Originaltitel": $colOriginaltitel = $bgcolor; break;
				case "Autor": $colAutor = $bgcolor; break;
				case "Titel": $colTitel = $bgcolor; break;
				case "Faszikel,Objektzaehler": $colFaszikel = $bgcolor; break;
			}
			//
			$digest1 = $dig1;
			$digest2 = $dig2;
			if ($digest1 == "Faszikel,Objektzaehler") { $digest1 = "Faszikel " . $ord . ", Objektzaehler"; }
			if ($digest2 == "Faszikel,Objektzaehler") { $digest2 = "Faszikel " . $ord . ", Objektzaehler"; }
			$sql_order_by = "ORDER BY " . $digest1 . " " . $ord;
			if ($digest2 != "") { $sql_order_by = $sql_order_by . ", " . $digest2 . " " . $ord; }
			// Vorteil über LEFT JOIN: auch nach den Originalnamen kann gesucht werden.
			$sql_select = "SELECT * FROM cr_sl AS v
			LEFT JOIN cr_sl_namen AS vno ON v.OriginalautorID = vno.NameID
			LEFT JOIN cr_sl_namen AS vna ON v.AutorID = vna.NameID
			WHERE
			Uebersetzung = '1' ";
			if ($linO != "") {
				$sql_select = $sql_select . " AND Ausgangssprache = '$linO'";
// 				$sql_select = $sql_select . " AND Ausgangssprache = '$linO' AND Textgattung = 'Poema' " ;
			}
			if ($linV != "") {
				$sql_select = $sql_select . " AND Zielsprache = '$linV'";
			}
			$sql_select = sql_select($titV, "Titel", $sql_select, "T");
			$sql_select = sql_select($titO, "Originaltitel", $sql_select, "T");
			$sql_select = sql_select($aucO, "vno", $sql_select, "A");
			$sql_select = sql_select($aucV, "vna", $sql_select, "A");
			$sql_select = $sql_select . $sql_order_by;
			//
			require_once $_SERVER['DOCUMENT_ROOT'] . '/db_connection.php';
			//
			$sql_result = $db->query($sql_select);
			//
			$treffer = "";
			$insgesamt = $sql_result->num_rows;
			switch ($insgesamt) {
				case 0: $treffer = "Ne una quidem versio!";
				break;
				case 1: $treffer = "1 versio!";
				break;
				default: $treffer = $insgesamt . " versiones!";
				}
		 } else {
			$insgesamt = "0";
			$range = "0";
		}
		//
		function Ausgangssprache() {
			$arrLinguae = array(
			"Anglicus",
			"Checius",
			"Francogallicus",
			"Graecus",
			"Hungaricus",
			"Latinus",
			"Nederlandicus",
			"Slovacicus",
			"Suecicus",
			"Theodiscus"
			);
			for ($x = 0, $c = count($arrLinguae); $x < $c; $x++) {
				echo "<option value=\"$arrLinguae[$x]\">$arrLinguae[$x]</option>";
			}
		}
	?>
	<script type="text/javascript">
		function formularNeu() {
			window.location.href = "versiones.php";
			sessionStorage.clear();
		}
		function formenInit() {
			store_mnu();
			if((sessionStorage.getItem("ID") == "versiones") && (sessionStorage.length >= "1")) {
				var aucO = sessionStorage.getItem("aucO");
				var titO = sessionStorage.getItem("titO");
				var aucV = sessionStorage.getItem("aucV");
				var titV = sessionStorage.getItem("titV");
				var linO = sessionStorage.getItem("linO");
				var linV = sessionStorage.getItem("linV");
				var dig1 = sessionStorage.getItem("dig1");
				var dig2 = sessionStorage.getItem("dig2");
				var ord = sessionStorage.getItem("ord");
			} else {
				var aucO =  "<?php echo $aucO ?>";
				var titO =  "<?php echo $titO ?>";
				var aucV = "<?php echo $aucV ?>";
				var titV = "<?php echo $titV ?>";
				var linO = "<?php echo $linO ?>";
				var linV = "<?php echo $linV ?>";
				var dig1 = "<?php echo $dig1 ?>";
				var dig2 =  "<?php echo $dig2 ?>";
				var ord =  "<?php echo $ord ?>";
			}
			sessionStorage.clear();
			document.form1.aucO.value = aucO;
			document.form1.titO.value = titO;
			document.form1.aucV.value = aucV;
			document.form1.titV.value = titV;
			// Zielsprache:
			sor_arr = new Array("", "Graecus", "Latinus", "Theodiscus");
			temp = linV;
			for (i = 0; i < sor_arr.length; i++) {
				if(sor_arr[i] == temp) {
					document.form1.linV[i].selected = "true";
				}
			}
			// Ausgangssprache:
			sor_arr = new Array(
				"",
				"Anglicus",
				"Checius",
				"Francogallicus",
				"Graecus",
				"Hungaricus",
				"Latinus",
				"Nederlandicus",
				"Slovacicus",
				"Suecicus",
				"Theodiscus"
			);
			temp = linO;
			for (i = 0; i < sor_arr.length; i++) {
				if(sor_arr[i] == temp) {
					document.form1.linO[i].selected = "true";
				}
			}
			// Sortierreihenfolge1:
			sor_arr = new Array("Originalautor", "Originaltitel", "Autor", "Titel", "Faszikel,Objektzaehler");
			temp = dig1;
			for (i = 0; i < sor_arr.length; i++) {
				if(sor_arr[i] == temp) {
					document.form1.dig1[i].selected = "true";
					}
			}
			// Sortierreihenfolge2:
			sor_arr = new Array("","Originalautor", "Originaltitel", "Autor", "Titel", "Faszikel,Objektzaehler");
			temp = dig2;
			for (i = 0; i < sor_arr.length; i++) {
				if(sor_arr[i] == temp) {
					document.form1.dig2[i].selected = "true";
					}
			}
			// Sortierrichtung:
			sor_arr = new Array( "ASC", "DESC");
			temp = ord;
			for (i = 0; i < sor_arr.length; i++) {
				if(sor_arr[i] == temp) {
					document.form1.ord[i].selected = "true";
					}
			}
			document.getElementById("defaultActionButton").focus();
		}
		var optionen = new Array(); // G L O B A L !!!!!
		function createDatenseiten() {
			if("<?php echo $sent ?>" == "1") {
				if ( "<?php echo $insgesamt ?>" > 0) {
					var insgesamt = "<?php echo $insgesamt ?>";
					var range=30;
					var rest = insgesamt % range;
					var divi = insgesamt / range;
					if (rest == 0) {
						var ganz = insgesamt / range;
					} else {
						var ganz = vorkomma(divi);
						ganz = ganz - 0; // wieder in Zahl umwandeln
					}
					for (var i=1; i <= ganz; i++) {
						var wert1 = ((i * range) - range) + 1;
						optionen.push(wert1);
						var wert2 = (i * range);
						optionen.push(wert2);
					}
					if (rest != 0) {
						wert1 = (ganz * range) + 1;
						optionen.push(wert1);
						wert2 = (ganz * range) + rest;
						optionen.push(wert2);
					}
					var laenge = optionen.length;
					for (var i=0; i < laenge; i++) {
						var newOpt = document.createElement("option");
						var f1 = optionen[i];
						var f2 = optionen[i+1];
						f1 != f2 ? txt = f1 + "–" + f2 : txt = f1;
						var newTxt = document.createTextNode(txt);
						newOpt.setAttribute("value", optionen[i]);
						document.form2.sel.appendChild(newOpt);
						newOpt.appendChild(newTxt);
						i++;
					}
					for (var i=0; i < laenge; i++) {
						var newOpt = document.createElement("option");
						var f1 = optionen[i];
						var f2 = optionen[i+1];
						f1 != f2 ? txt = f1 + "–" + f2 : txt = f1;
						var newTxt = document.createTextNode(txt);
						newOpt.setAttribute("value", optionen[i]);
						document.form3.sel.appendChild(newOpt);
						newOpt.appendChild(newTxt);
						i++;
					}
					for (i = 0; i < optionen.length; i++) {
						if(optionen[i] == "<?php echo $sel ?>") {
							break;
						}
					}
					if("<?php echo $insgesamt ?>" > 30) {
						document.form2.sel[i/2].selected = "true";
						document.form3.sel[i/2].selected = "true";
					}
					if("<?php echo $insgesamt ?>" >= 5) {
						document.getElementById("sursum").style.display = "block";
					}
				}
			}
		}
		function vorkomma(z) {
			var s = z.toString();
			var p = s.indexOf(".");
			return s.substr(0, p);
		}
		 function autosuche() {
			if ("<?php echo $auto ?>" == 1) {
				document.form1.submit();
			}
		}
		function storeSS(id) {
			sessionStorage.clear();
			sessionStorage.setItem("ID", "versiones");
			var arr_keys = new Array ( "aucO", "titO", "aucV", "titV", "linO", "linV", "dig1", "dig2", "ord");
			for(var i=0; i < arr_keys.length; i++) {
				if(arr_keys[i] == id){
					arr_keys.splice(i, 1);
				}
			}
			for (var i=0; i < arr_keys.length; i++) {
				var value = document.getElementById(arr_keys[i]).value;
				var key = arr_keys[i];
				sessionStorage.setItem(key, value);
			}
			if (id == "aucO") {
				document.location.href = "idx_ver_arc_auc.php";
			}
			if (id == "titO") {
				document.location.href = "idx_ver_arc_tit.php";
			}
			if (id == "aucV") {
				document.location.href = "idx_ver_int.php";
			}
			if (id == "titV") {
				document.location.href = "idx_ver_tit.php";
			}
 		}
	</script>
</head>
<body onLoad="formenInit(); autosuche();">
	<?php
		include("header.inc.php");
		include("php/ini.inc.php");
		include("php/namen.inc.php");
		include("php/ds_mnu.inc.php");
	?>
	<div class="border">
		<div id="main">
			<h1>Versiones eligere</h1>
			<div class="quaestio">
				<form name="form1" action="<?php echo $PHP_SELF ?>" method="POST">
					<table style="margin-left: 4.8em;">
						<tr>
							<td class="label">
								ARCHETYPUM <span class="gray">&bull; </span>Auctor:
							</td>
							<td>
								<input class="strg" type="search" name="aucO" id="aucO">
							</td>
							<td>
								<input class="indexbutton" type="button" onClick="storeSS('aucO');" value="Index&thinsp;&hellip;">
							</td>
						</tr>
						<tr>
							<td class="label">
								Titulus:
							</td>
							<td>
								<input class="strg" type="search" name="titO" id="titO">
							</td>
							<td>
								<input class="indexbutton"  type="button" onClick="storeSS('titO');" value="Index&thinsp;&hellip;">
							</td>
						</tr>
						<tr>
							<td class="label">
								Sermo:
							</td>
							<td>
								<select name="linO" id="linO">
									<option value="">&nbsp;</option>
									<?php Ausgangssprache(); ?>
								</select>
							</td>
							<td>&#160;</td>
						</tr>
						<tr>
							<td class="label">
								VERSIO <span class="gray">&bull;</span> Interpres:
							</td>
							<td>
								<input class="strg" type="search" name="aucV" id="aucV">
							</td>
							<td>
								<input class="indexbutton"  type="button" onClick="storeSS('aucV');" value="Index&thinsp;&hellip;">
							</td>
						</tr>
						<tr>
							<td class="label">
								Titulus:
							</td>
							<td>
								<input class="strg" type="search" name="titV" id="titV">
							</td>
							<td>
								<input class="indexbutton" type="button" onClick="storeSS('titV');" value="Index&thinsp;&hellip;">
							</td>
						</tr>
						<tr>
							<td style="padding-bottom: 0.8em;" class="label">
								Sermo:
							</td>
							<td style="padding-bottom: 0.5em;">
								<select name="linV" id="linV" style="display: inline;">
									<option selected value="">&nbsp;</option>
									<option value="Graecus">Graecus</option>
									<option value="Latinus">Latinus</option>
									<option value="Theodiscus">Theodiscus</option>
								</select>
							</td>
							<td>&#160;</td>
						</tr>
						<tr>
							<td style="padding-top: 0.5em;" class="label">
								Ordo:
							</td>
							<td style="padding-top:0.5em;">
								<select name="dig1" id="dig1">
									<option value="Originalautor" >Auctor</option>
									<option value="Originaltitel">Titulus archetypi</option>
									<option value="Autor">Interpres</option>
									<option value="Titel">Titulus versionis</option>
									<option value="Faszikel,Objektzaehler" selected>Fasciculus</option>
								</select> —
								<select name="dig2" id="dig2">
									<option value="">&nbsp;</option>
									<option value="Originalautor">Auctor</option>
									<option value="Originaltitel">Titulus archetypi</option>
									<option value="Autor">Interpres</option>
									<option value="Titel">Titulus versionis</option>
									<option value="Faszikel,Objektzaehler">Fasciculus</option>
								</select>
							</td>
							<td>&#160;</td>
						</tr>
						<tr>
							<td class="label">
								&#160;
							</td>
							<td>
								<select name="ord" id="ord">
									<option value="ASC" selected>A — Z</option>
									<option value="DESC">Z — A</option>
								</select>
							</td>
							<td>&#160;</td>
						</tr>
						<tr>
							<td>&#160;</td>
							<td>
								<input type="hidden" name="bl" value="l◄">
								<input type="hidden" name="bl" value="◄">
								<input type="hidden" name="bl" value="►">
								<input type="hidden" name="bl" value="►l">
								<input type='hidden' name='anf' value="">
								<input type='hidden' name='zur' value="">
								<input type='hidden' name='vor' value="">
								<input type='hidden' name='end' value="">
								<input type="hidden" name="sent" value="<?php echo $sent ?>">
								<input id="denuo" type="button" class="button" value="Delere" onClick="formularNeu();">
								<input id="defaultActionButton" type="submit" class="button" value="Eligere">
							</td>
							<td>&#160;</td>
						</tr>
					</table>
				</form>
				<p id="treffer">&#160;<!-- &#160; wichtig! -->
					<?php if ($sent == 1) { echo $treffer; } ?>
				</p>
			</div>
				<?php
					// Bei Treffer = 0 wenigstens die Einträge von form1 weitergeben:
					if ($insgesamt == 0) {
						echo "<form id='form2' name='form2' action='$PHP_SELF' method='POST'>
							<input type='hidden' name='aucO' value='$aucO'>
							<input type='hidden' name='titO' value='$titO'>
							<input type='hidden' name='linO' value='$linO'>
							<input type='hidden' name='aucV' value='$aucV'>
							<input type='hidden' name='titV' value='$titV'>
							<input type='hidden' name='linV' value='$linV'>
							<input type='hidden' name='dig1' value='$dig1'>
							<input type='hidden' name='dig2' value='$dig2'>
							<input type='hidden' name='ord' value='$ord'>
							<input type='hidden' name='sent' value='$sent'>
						</form>";
					}
					// A U S G A B E :
					if ($insgesamt > 0) {
						// B u t t o n n a v i g a t i o n 1 :
						echo "<form id='form2' name='form2' style='visibility: hidden;' action='$PHP_SELF' method='POST'>
							<input class='inp_nav' type='submit' name='bl' value='l◄'>
							<input class='inp_nav' type='submit' name='bl' value='◄'>
							<input class='inp_nav' type='submit' name='bl' value='►'>
							<input class='inp_nav' type='submit' name='bl' value='►l'>
							<input type='hidden' name='anf'>
							<input type='hidden' name='zur'>
							<input type='hidden' name='vor'>
							<input type='hidden' name='end'>
							<input type='hidden' name='aucO' value='$aucO'>
							<input type='hidden' name='titO' value='$titO'>
							<input type='hidden' name='linO' value='$linO'>
							<input type='hidden' name='aucV' value='$aucV'>
							<input type='hidden' name='titV' value='$titV'>
							<input type='hidden' name='linV' value='$linV'>
							<input type='hidden' name='dig1' value='$dig1'>
							<input type='hidden' name='dig2' value='$dig2'>
							<input type='hidden' name='ord' value='$ord'>
							<input type='hidden' name='sent' value='$sent'>
							<select name='sel' style='width: 7.5em; margin-left: 1em; ' onChange='document.form2.submit();'></select>
						</form>";
						// A u s g a b e t a b e l l e :
						echo "<p style='clear: both; height: 6px;'>&#160;</p>";
						echo "<table id='ausgabe'>";
						// sql-limit:
						$zaehler = $sel;
						$range=30;
							$firstrun = 1;
						if ($insgesamt < 30) { $range = 0; }
						$sel--;
						if ($insgesamt >= 30) { $sql_limit = "LIMIT $sel, $range"; } else { $sql_limit =""; }
						$sql_select = "$sql_select $sql_limit";
						//
						$sql_result = $db->query($sql_select);
						$anz_angezeigte = $sql_result->num_rows;
						//
						while ($row = $sql_result->fetch_object()) {
							$ON=$OL=$TG="";
							if ($firstrun == 1) { $firstrun = 0; } else { echo "<tr><td colspan='3'><p class='sep'></p> </td></tr>"; }
							$IID = $row->IID;
							$bis = $row->Bis;
							$p = $row->Seite != "" ? ", p. " : "";
							if ($bis != "") { $bis = "–" . $bis; $p = ", pp. "; }
							$Oid = $row->OriginalautorID;
							//
							$sql_select_2 = "SELECT * FROM cr_sl_namen WHERE NameID = '$Oid'";
							$sql_result_2 = $db->query($sql_select_2);
							while ($row_2 = $sql_result_2->fetch_object()) {
								$ON = $row_2->Originalname; $OL= htmlspecialchars($row_2->extLink);
							}
							$Aid = $row->AutorID;
							//
							$sql_select_3 = "SELECT * FROM cr_sl_namen WHERE NameID = '$Aid'";
							$sql_result_3 = $db->query($sql_select_3);
							while ($row_3 = $sql_result_3->fetch_object()) {
								$AN = $row_3->Originalname; $AL= htmlspecialchars($row_3->extLink);
							}
							//
							$nil = "<span style='color: gray;'> –&thinsp;·&thinsp;–&thinsp;·&thinsp;– </span>";
							$OA = namen_ausgeben($row->Originalautor, $ON, $OL, $nil);
							$AU = namen_ausgeben($row->Autor, $AN, $AL, $nil);
							$TG = $row->Textgattung;
							if ($TG == "") {$TG = $nil;}
							if (trim($row->Originaltitel) != "") $OT = $row->Originaltitel; else $OT = $nil;
							if (trim($row->Titel) != "") $TI = $row->Titel; else $TI = $nil;
								echo "<tr><td class='zaehler'>$zaehler. </td><td class='labelausg'>ARCHETYPUM&#160;&bull;&#160;Auctor:</td><td $colOriginalautor>$OA</td></tr>";
								echo "<tr><td></td><td class='labelausg'>Titulus:</td><td $colOriginaltitel>$OT</td></tr>";
								echo "<tr><td></td><td class='labelausg'>VERSIO&#160;&bull;&#160;Interpres:</td><td $colAutor>$AU</td></tr>";
								echo "<tr><td></td><td class='labelausg'>Titulus:</td><td $colTitel>$TI</td></tr>";
							echo "<tr><td></td><td class='labelausg'>Genus litterarium:</td><td style='color:gray;'>$TG</td></tr>";
							echo "<tr><td></td><td class='labelausg'>Sermo:</td><td style='color:gray;'>$row->Ausgangssprache → $row->Zielsprache</td></tr>";
							
							$heft = "Civis Romanus";
							$fasc = $row->Faszikel;
							if ($fasc >= 801) { $heft = "Scriptor Latinus"; }
							$bandteil = $row->Bandteil;
							$band = $row->Band;
							$jahr = $row->Jahr;
							$monat = $row->Monat;
							$seite = $row->Seite;
							if($fasc == 602) {$heft = "Civ. Rom."; $bandteil = "2/3"; $monat = "Febr. Mart.";}
							if ($fasc == "704") {$heft = "Civ. Rom."; $monat = "Oct. Nov. Dec.";}
							if ($fasc == "807") {$monat = "Nov. Dec.";}
							if ($fasc == "808") {$monat = "Ian. Febr.";}
							$out = $heft . ", a. " . $band . ", ". $monat . " " .  $jahr . ", n. " . $bandteil .  $p . $seite . $bis;
							echo "<tr><td>&#160;</td><td class='labelausg'>Fasciculus:</td><td $colFaszikel>$out</td></tr>";
							echo "<tr><td >&#160;</td><td class='labelausg'>&#160;</td>";
							ds_mnu($IID, $band, $jahr, $bandteil, $seite, $bis, $navigatrum);
							$zaehler++;
						} // Ende der Ausgabeschleife
						echo "</table>";

						// B u t t o n n a v i g a t i o n 2 :
						echo "<form id='form3' name='form3' style='visibility: hidden;' action='$PHP_SELF' method='POST'>
								<input class='inp_nav' type='submit' name='bl' value='l◄'>
								<input class='inp_nav' type='submit' name='bl' value='◄'>
								<input class='inp_nav' type='submit' name='bl' value='►'>
								<input class='inp_nav' type='submit' name='bl' value='►l'>
								<input type='hidden' name='anf'>
								<input type='hidden' name='zur'>
								<input type='hidden' name='vor'>
								<input type='hidden' name='end'>
								<input type='hidden' name='aucO' value='$aucO'>
								<input type='hidden' name='titO' value='$titO'>
								<input type='hidden' name='linO' value='$linO'>
								<input type='hidden' name='aucV' value='$aucV'>
								<input type='hidden' name='titV' value='$titV'>
								<input type='hidden' name='linV' value='$linV'>
								<input type='hidden' name='dig1' value='$dig1'>
								<input type='hidden' name='dig2' value='$dig2'>
								<input type='hidden' name='ord' value='$ord'>
								<input type='hidden' name='sent' value='$sent'>
								<select name='sel' style='width: 7.5em; margin-left: 1em;' onChange='document.form3.submit();'></select>
							</form>";
						$db->close();
					}
				?>
			<p id="sursum"><a href="javascript: window.scrollTo(0,0);"><b>sursum</b></a></p>
			<p>&#160;</p>
		</div>
	</div>
	<?php include("footer.inc.php"); ?>
	<script>
		// Eingabetaste ruft defaultActionButton auf
		$(document).ready(function() {
			$("input").bind("keydown", function(event) {
				var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
				if (keycode == 13) {
					document.getElementById('defaultActionButton').click();
					return false;
				} else {
					return true;
				}
			});
			$("#aucO").autocomplete({
				source: 'auto_ver.php?db_feld=Originalautor',
				minLength: 3,
				delay: 500
			});
			$("#titO").autocomplete({
				source: 'auto_ver.php?db_feld=Originaltitel',
				minLength: 3,
				delay: 500
			});
			$("#aucV").autocomplete({
				source: 'auto_ver.php?db_feld=Autor',
				minLength: 3,
				delay: 500
			});
			$("#titV").autocomplete({
				source: 'auto_ver.php?db_feld=Titel',
				minLength: 3,
				delay: 500
			});
			// Seitenaufbau
			createDatenseiten();
			if(("<?php echo $sent ?>" == 1) && ("<?php echo $insgesamt ?>" > 0)) {
				document.form2.anf.value = 0;
				document.form3.anf.value = 0;
				var end = <?php echo $sel ?> + <?php echo $range ?> + 1;
				if (end > optionen[optionen.length-2]) { end = 1; }
				document.form2.vor.value = end ;
				document.form3.vor.value = end ;
				var zur = <?php echo $sel ?> - <?php echo $range ?> + 1;
				if (zur < 0) { zur = 1; }
				document.form2.zur.value = zur;
				document.form3.zur.value = zur;
				document.form2.end.value = optionen[optionen.length-2];
				document.form3.end.value = optionen[optionen.length-2];
			}
			if("<?php echo $insgesamt ?>" <= 30) {
				$("#ausgabe").css("margin-top", "0");
			}
			if("<?php echo $insgesamt ?>" > 30) {
				$("form[name=form2]").css("visibility", "visible");
			}
			if(("<?php echo $insgesamt ?>" > 30) && ("<?php echo $anz_angezeigte ?>" > 5)) { $("form[name=form3]").css("visibility", "visible"); }
			if("<?php echo $anz_angezeigte ?>" < 5) { $("#sursum").css("display", "none"); }
		});
	</script>
</body>
</html>
