<?php
  include __DIR__ . "/../layout/header_drop.php";
  include __DIR__ . "/../inc/foto_nav.php";
  include __DIR__ . "/../css/navi.css";
  include __DIR__ . "/../css/gallery.css";

  $unter_thema = $anz_themen = array();  // Themenunterschrift - Anzahl Bilder vom gleichen Thema
  $path_images = __DIR__ . "/../images/".$thema."/";
  $base_ordner = "/home/foto/views/images/";
  $unterordner = scandir($path_images); // $unterordner lesen
  $i = 1;                     // 1. Bild
  foreach($unterordner AS $bild_thema){
    if ($bild_thema != "." && $bild_thema != ".." && $bild_thema != "klein" && $bild_thema != "_notes" &&
      $bild_thema != ".DS_Store" && $bild_thema != "Thumbs.db") {
      $unter_thema[] = $bild_thema;         // gültiges Unterthema in array eintragen
      $ordner = $base_ordner.$thema."/".$bild_thema;

      $allebilder = scandir($path_images.$bild_thema);

      foreach ($allebilder as $bild) {      //Ordner "images" auslesen
        if ( substr( $bild, -4) == ".jpg"){ // Dateiname gültig?>
          <style><?php
            echo ("#p".$i.",#p".$i." + span{background-image:url(".$ordner."/".$bild.")}");?>
          </style><?php
          $i++;
        }
      }
      $anz_themen[] = $i-1;   //anzahl bilder an letzter stelle hizufügen
    }
  }
  $anz_images = $i;           // Anzahl Bilder
  ?>

  <div id="myBtnContainer" style="padding-left:20px; top:0px; text-transform:capitalize;"><?php
      echo "&nbsp;<b>Thema &nbsp;".$thema.":</b>&nbsp;&nbsp;";?>

    <button class="btn active" onclick="filterSelection('all')"> Show all</button><?php
    foreach($unter_thema AS $bild_thema) { ?>
        <button class="btn" onclick="filterSelection('<?php echo $bild_thema;?>')"><?php echo $bild_thema."</button>";
    } ?>

    <!--   <button class="btn btn-primary"><a href='portfolio'><b>Übersicht Portfolio</b></a></button> -->
    <input class="btn-default" type="button"
             value="Click auf ein Bild vergrößert es - erneuter click verkleinert es">

    <form action="<?php echo $thema?>" >
      <input type="radio" name="carussel" id="carussel" value="00" onchange="submit()" <?php
        if ($_SESSION['carussel'] == "00") { echo "checked=checked"; } ?> />
        <label><small>Einzelbilder</small></label>
      <input type="radio" name="carussel" id="carussel" value="01" onchange="submit()" <?php
        if ($_SESSION['carussel'] == "01") { echo "checked=checked"; } ?> />
          <label><small>Bilderkarussel&nbsp;</small></label>
    </form>
  </div><?php
  $i = 1;   //1. Bild
  $m = 0;   //1. Matrix-Eintrag ?>
  <div class="row"><?php   // style="top:0px; "
    for ($i = 1; $i < $anz_images; $i++) { ?>
      <div class="column <?php echo $unter_thema[$m];?>">
        <div class="content">
          <div class = "gallery">
            <p><a id="p<?php echo $i;?>" href="#" tabindex="0"></a><span>&nbsp;</span></p>
          </div>
          <p><?php echo $unter_thema[$m].": ".($titel[$i]). "</p>";?>
        </div>
      </div><?php
      if ($i == ($anz_themen[$m])) {    // Themenzähler
        $m = $m+1;
      }
    }  ?>
  </div>

  <?php
    include __DIR__ . "/../js/filter_1.inc.js";

    include __DIR__ . "/../layout/footer.php";
  ?>