<?php
if (isset($_GET['section'])) {
    $path = "img/" . $_GET['section'] . "/";
    $link = "index.php?section=" . $_GET['section'] . "&";
} else {
    $path = "img/will/";
    $link = "index.php?section=will&";
}

if (isset($_GET['t'])) {
    $path .= $_GET['t'] . "/";
    $link .= "t=" . $_GET['t'] . "&";
}

if (isset($_GET['f'])) {
    $pic = $path . $_GET['f'] . ".jpg";
    echo "    <img class=\"gross\" src=$pic />\n";
    echo "</div>\n";
    echo "<br class=\"clear\" />\n";
    echo "<div id=\"thumb\">\n";
} else {
    for ($i = 0; $i < 10; $i++) {
        $pic = $path . $i . ".jpg";
        if (file_exists($pic)) {
            echo "    <img class=\"gross\" src=$pic />\n";
            echo "</div>\n";
            echo "<br class=\"clear\" />\n";
            echo "<div id=\"thumb\">\n";
            break;
        }
    }
}

for ($i = 9; $i >= 0; $i--) {
    $thumb = $path . $i . ".jpg";
    if (file_exists($thumb)) {
        $ref = $link . "f=$i";
        echo "    <a href=$ref><img src=$thumb /></a>\n";
    }
}
echo "</div>\n";

