<!DOCTYPE html>
<html lang="la">
<head>
	<title>Index generalis Hermae Americani – Symbolas eligere</title>
	<meta name="author" content="Bernd Platzdasch"><!-- 4.11.2018 / 2.5.2020-->
	<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"></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">
		li.ui-menu-item { font-size: small !important; }
		#dig1, #dig2, #fasc1, #fasc2, #ord { width: 12em; }
	</style>
	<?php
// Debugging:
// error_reporting(E_ALL);
// ini_set('display_errors', true); 
		include("php/sql_select.inc.php");
		include("php/namen.inc.php");
		include("php/ds_mnu.inc.php");
		include("php/tomus_annus.inc.php");
		include("php/tomus_annus_s.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:
		$auto = 0;
		if (isset($_POST ["auctor"])) { $auctor = $_POST ["auctor"]; } else { if (isset($_GET ["auctor"])) { $auctor = $_GET ["auctor"]; $auto=1; } else { $auctor="";} }
		if (isset($_POST ["titulus"])) { $titulus = $_POST ["titulus"]; } else { if (isset($_GET ["titulus"])) { $titulus = $_GET ["titulus"]; $auto=1; } else { $titulus="";} }
		if (isset($_POST ["genlit"])) { $genlit = $_POST ["genlit"]; } else { if (isset($_GET ["genlit"])) { $genlit = $_GET ["genlit"]; $auto=1; } else { $genlit="";} }
		$res = (isset($_POST ["res"])) ? $_POST ["res"] : "";
		$fasc1 = (isset($_POST ["fasc1"])) ? $_POST ["fasc1"] : "";
		$fasc2 = (isset($_POST ["fasc2"])) ? $_POST ["fasc2"] : "";
		$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; }
		//
		$auctor = addslashes($auctor);
		$titulus = addslashes($titulus);
		$anz_angezeigte = 0;
		//
		require_once $_SERVER['DOCUMENT_ROOT'] . '/db_connection.php';
		//
		$sql_select_x = "SELECT DISTINCT Faszikel FROM hermes ORDER BY Faszikel";
		$sql_result_x = $db->query($sql_select_x);
		$i = 0;

		$sql_select_x = "SELECT DISTINCT Textgattung FROM hermes ORDER BY Textgattung";
		$sql_result_x = $db->query($sql_select_x);
		$i = 0;
		$arr_textgattung = array();
		while ($row_x = $sql_result_x->fetch_object()) {
				$arr_textgattung[$i] = $row_x->Textgattung;
				$i++;
		}
		$sql_select_x = "SELECT DISTINCT Sachgebiet FROM hermes ORDER BY Sachgebiet";
		$sql_result_x = $db->query($sql_select_x);
		$i = 0;
		$arr_sachgebiet = array();
		while ($row_x = $sql_result_x->fetch_object()) {
			$arr_sachgebiet[$i] = $row_x->Sachgebiet;
			$i++;
		}
		 if ($sent == 1) {
			//
			$colAutor = "style='background-color: #fff; color: #000;'";
			$colTitel = "style='background-color: #fff; color: #000;'";
			$colGenLit = "style='background-color: #fff; color: #000;'";
			$colRes = "style='background-color: #fff; color: #000;'";
			$colFaszikel = "style='background-color: #fff; color: #000;'";
			$bgcolor = "style='background-color: #f4f4f4; color: green;'";
			switch ($dig1) {
				case "Autor": $colAutor = $bgcolor; break;
				case "Titel": $colTitel = $bgcolor; break;
				case "Faszikel,Objektzaehler": $colFaszikel = $bgcolor; break;
			}
			//
			if(($fasc1 == "") AND ($fasc2 == "")) {
				$sql_select_vgl = "";
			} else {
				if($fasc1 <= $fasc2) {
					$sql_select_vgl = "AND (Faszikel >= '$fasc1') AND (Faszikel <= '$fasc2') ";
				}
				if ($fasc1 >= $fasc2) {
					$sql_select_vgl = "AND (Faszikel >= '$fasc2') AND (Faszikel <= '$fasc1') ";
				}
				if (($fasc1 != "") AND ($fasc2 == "")) {
					$sql_select_vgl = "AND (Faszikel = '$fasc1')";
				}
				if (($fasc1 == "") AND ($fasc2 != "")) {
					$sql_select_vgl = "AND (Faszikel = '$fasc2')";
				}
			}
			//
			$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 hermes AS v
			LEFT JOIN hermes_namen AS vna ON v.AutorID = vna.NameID
			WHERE
				Textgattung <> 'Epistu'";
			if($genlit != "") {
				$sql_select = $sql_select . " AND Textgattung = '$genlit'";
			}
			if($res != "") {
				$sql_select = $sql_select . " AND Sachgebiet = '$res'";
			}
			$sql_select = sql_select($titulus, "Titel", $sql_select, "T");
			$sql_select = sql_select($auctor, "vna", $sql_select, "A");
			//
			$sql_select = $sql_select . $sql_select_vgl . $sql_order_by;
			$sql_result = $db->query($sql_select);
			//
			$treffer = "";
			$insgesamt = $sql_result->num_rows;
			switch ($insgesamt) {
				case 0: $treffer = "Ne una quidem symbola!";
				break;
				case 1: $treffer = "1 symbola!";
				break;
				default: $treffer = $insgesamt . " symbolae!";
			}
		 } else {
			$insgesamt = "0";
			$range = "0";
		}
	?>
	<script type="text/javascript">
		function formularNeu() {
			window.location.href = "symbolae.php";
			sessionStorage.clear();
		}
		function formenInit() {
			store_mnu();
			if((sessionStorage.getItem("ID") == "symbolae") && (sessionStorage.length >= "1")) {
				var auctor = sessionStorage.getItem("auctor");
				var titulus = sessionStorage.getItem("titulus");
				var genlit = sessionStorage.getItem("genlit");
				var res = sessionStorage.getItem("res");
				var fasc1 = sessionStorage.getItem("fasc1");
				var fasc2 = sessionStorage.getItem("fasc2");
				var dig1 = sessionStorage.getItem("dig1");
				var dig2 = sessionStorage.getItem("dig2");
				var ord = sessionStorage.getItem("ord");
			} else {
				var auctor =  "<?php echo $auctor ?>";
				var titulus =  "<?php echo $titulus ?>";
				var genlit = "<?php echo $genlit ?>";
				var res = "<?php echo $res ?>";
				var fasc1 = "<?php echo $fasc1 ?>";
				var fasc2 = "<?php echo $fasc2 ?>";
				var dig1 = "<?php echo $dig1 ?>";
				var dig2 =  "<?php echo $dig2 ?>";
				var ord =  "<?php echo $ord ?>";
			}
			sessionStorage.clear();
			document.form1.auctor.value = auctor;
			document.form1.titulus.value = titulus;
			temp = genlit;
			for (i = 0; i < document.getElementById("genlit").length; ++i) {
				if (document.getElementById("genlit").options[i].value == temp) {
					document.form1.genlit[i].selected = "true";
				}
			}
			temp = res;
			for (i = 0; i < document.getElementById("res").length; ++i) {
				if (document.getElementById("res").options[i].value == temp) {
					document.form1.res[i].selected = "true";
				}
			}
			temp = fasc1;
			for (i = 0; i < document.getElementById("fasc1").length; ++i) {
				if (document.getElementById("fasc1").options[i].value == temp) {
					document.form1.fasc1[i].selected = "true";
				}
			}
			temp = fasc2;
			for (i = 0; i < document.getElementById("fasc2").length; ++i) {
				if (document.getElementById("fasc2").options[i].value == temp) {
					document.form1.fasc2[i].selected = "true";
				}
			}
			// Sortierreihenfolge1:
			sor_arr = new Array("Autor", "Titel", "Textgattung", "Sachgebiet", "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("","Autor", "Titel", "Textgattung", "Sachgebiet", "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() {
			var sent = "<?php echo $sent ?>";
			var insgesamt = <?php echo $insgesamt ?>;
			var sel = "<?php echo $sel ?>";
			if(sent == "1") {
				if ( insgesamt > 0) {
					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] == sel) {
							break;
						}
					}
					if (insgesamt > 30) {
						document.form2.sel[i/2].selected = "true";
						document.form3.sel[i/2].selected = "true";
					}
					if (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", "symbolae");
			var arr_keys = new Array ( "auctor", "titulus", "genlit", "res", "fasc1", "fasc2", "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 == "auctor") {
				document.location.href = "idx_sym_auc.php";
			}
			if (id == "titulus") {
				document.location.href = "idx_sym_tit.php";
			}
 		}
	</script>
</head>
<body onLoad="formenInit(); autosuche();">
<?php
	include("header.inc.php");
?>
<div class="border">
	<div id="main">
		<h1>Symbolas eligere</h1>
		<div class="quaestio">
			<form name="form1" action="<?php echo $PHP_SELF ?>" method="POST">
				<table style="margin-left: 5.3em;">
					<tr>
						<td class="label">
							Auctor:
						</td>
						<td>
							<input class="strg" type="search" name="auctor" id="auctor">
						<td>
							<input class="indexbutton" type="button" onClick="storeSS('auctor');" value="Index&thinsp;&hellip;">
						</td>
					</tr>
					<tr>
						<td class="label">
							Titulus:
						</td>
						<td >
							<input class="strg" type="search" name="titulus" id="titulus">
						</td>
						<td>
							<input class="indexbutton" type="button" onClick="storeSS('titulus');" value="Index&thinsp;&hellip;">
						</td>
					</tr>
					<tr>
						<td class="label">
							Genus litterarium:
						</td>
						<td>
							<select id="genlit" name="genlit" style="width:100%;">
								<option value="" selected>&nbsp;</option>
								<?php
									for ($x = 1, $l = count($arr_textgattung); $x < $l; $x++) {
										echo "<option value=\"$arr_textgattung[$x]\">$arr_textgattung[$x]</option>";
									}
								?>
							</select>
						</td>
						<td>&#160;</td>
					</tr>
					<tr>
						<td class="label">
							Genus rei:
						</td>
						<td>
							<select id="res" name="res" style="width: 100%;">
								<option value="" selected>&nbsp;</option>
								<?php
									for ($x = 1, $l = count($arr_sachgebiet); $x < $l; $x++) {
										echo "<option value=\"$arr_sachgebiet[$x]\">$arr_sachgebiet[$x]</option>";
									}
								?>
							</select>
						</td>
						<td>&#160;</td>
					</tr>
					<tr>
						<td class="label">
							Fasciculus:
						</td>
						<td>
							<select id="fasc1" name="fasc1">
								<option value="">&nbsp;</option>
								<?php
									for ($x = 1, $l = 14; $x <= $l; $x++) {
										echo "<option value=\"$x\">$arr_vla_s[$x]</option>";
									}
								?>
							</select> —
							<select id="fasc2" name="fasc2">
								<option value="">&nbsp;</option>
								<?php
									for ($x = 1, $l = 14; $x <= $l; $x++) {
										echo "<option value=\"$x\">$arr_vla_s[$x]</option>";
									}
								?>
							</select>
						</td>
						<td>&#160;</td>
					</tr>
					<tr>
						<td style="padding-top: 1em;" class="label">
							Ordo:
						</td>
						<td style="padding-top: 1em;">
							<select id="dig1" name="dig1">
								<option value="Autor">Auctor</option>
								<option value="Titel">Titulus</option>
								<option value="Textgattung">Genus litterarium</option>
								<option value="Sachgebiet">Genus rei</option>
								<option value="Faszikel,Objektzaehler" selected>Fasciculus</option>
							</select> —
							<select id="dig2" name="dig2">
								<option value="" selected>&nbsp;</option>
								<option value="Autor">Auctor</option>
								<option value="Titel">Titulus</option>
								<option value="Textgattung">Genus litterarium</option>
								<option value="Sachgebiet">Genus rei</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" class="button" type="submit" 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 keinem Trefffer 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='auctor' value='$auctor'>
						<input type='hidden' name='titulus' value='$titulus'>
						<input type='hidden' name='genlit' value='$genlit'>
						<input type='hidden' name='res' value='$res'>
						<input type='hidden' name='fasc1' value='$fasc1'>
						<input type='hidden' name='fasc2' value='$fasc2'>
						<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) {
				// 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;
				// 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='auctor' value='$auctor'>
						<input type='hidden' name='titulus' value='$titulus'>
						<input type='hidden' name='genlit' value='$genlit'>
						<input type='hidden' name='res' value='$res'>
						<input type='hidden' name='fasc1' value='$fasc1'>
						<input type='hidden' name='fasc2' value='$fasc2'>
						<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: 8.8em; 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'>";
				while ($row = $sql_result->fetch_object()) {
					$AN = $AL = "";
					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. "; }
					$Aid = $row->AutorID;
					$sql_select_3 = "SELECT * FROM hermes_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>";
					$AU = namen_ausgeben($row->Autor, $AN, $AL, $nil);
					if (trim($row->Titel) != "") $TL = $row->Titel; else $TL = $nil;
					if (trim($row->Textgattung) != "") $GL = $row->Textgattung; else $GL = $nil;
					if (trim($row->Sachgebiet) != "") $RS = $row->Sachgebiet; else $RS = $nil;
					echo "<tr><td class='zaehler'>$zaehler. </td><td class='labelausg'>Auctor:</td><td $colAutor>$AU</td></tr>";
					echo "<tr><td>&#160;</td><td class='labelausg'>Titulus:</td><td $colTitel>$TL</td></tr>";
					echo "<tr><td>&#160;</td><td class='labelausg'>Genus&#160;litterarium:</td><td $colGenLit>$GL</td></tr>";
					echo "<tr><td>&#160;</td><td class='labelausg'>Genus rei:</td><td $colRes>$RS</td></tr>";
					$lab_fasc = $arr_vla[$row->Faszikel];
					echo "<tr><td>&#160;</td><td class='labelausg'>Fasciculus:</td><td $colFaszikel>$lab_fasc";
					echo "$p" . $row->Seite . $bis . "</td></tr>";
					echo "<tr><td >&#160;</td><td class='labelausg'>&#160;</td>";
					ds_mnu($IID, $row->Faszikel, $row->Seite, $navigatrum);
					$zaehler++;
				}
				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='auctor' value='$auctor'>
						<input type='hidden' name='titulus' value='$titulus'>
						<input type='hidden' name='genlit' value='$genlit'>
						<input type='hidden' name='res' value='$res'>
						<input type='hidden' name='fasc1' value='$fasc1'>
						<input type='hidden' name='fasc2' value='$fasc2'>
						<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: 8.8em; 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;
			}
		});
		$("#auctor").autocomplete({
			source: 'auto_sym.php?db_feld=Autor',
			minLength: 3,
			delay: 500
		});
		$("#titulus").autocomplete({
			source: 'auto_sym.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>
