<?php	

// Penguin Gallery http://www.penguintutor.com/penguingallery 
// Copyright 2009 Stewart Watkiss
/*  
	This file is a part of Penguin Gallery

	Penguin Gallery is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Penguin Gallery is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Penguin Gallery.  If not, see <http://www.gnu.org/licenses/>.
*/

// galleryimg.php
// Displays large image on page and navigation buttons.
// Also creates file arrays which are subsequently used by gallery.php / gallerythumb.php to create the thumbnails



// Is this running standalone or as an include - if standalone
// - does $galleryconfigfile exist - if not then we are standalone (eg. AJAX) - if is we are embedded  
// standalone variable used later to determine if we need to close the <p> we create
if (!isset($galleryconfigfile)) 
{
	$standalone = 1;
	// If standalone get configfile from url
	$galleryconfigfile = trim($_GET[gallery]);
	// Call the setup code (this is included in gallery.php for embedded)
	// Note security checking i
	include ($galleryphpdir."gallerysetup.php");
}
else
{
	$standalone = 0;
	echo "<div id=\"gallerylargeimgdiv\">\n\n";
}




// Get image number from the url
$imgnum = trim($_GET[img]);
// If not in the url then we show the first image 
// Put it so that image starts with 1 rather than 0 - as this makes more sense to the user
// Array is still held as 0 - so we need to subtract one from the user value to get the array position.
if (empty($imgnum) || !is_numeric($imgnum) || $imgnum < 1) {$imgnum = 1;}

// Already checked for imgnum being too small - now check it's not too large - if so make it the last image
if ($imgnum > sizeof($filenames)) {$imgnum = sizeof($filenames);}

// Display large image
echo "<img id=\"gallerylargeimg\" src=\"".$viewfull.$filenames[($imgnum-1)].".jpg\" alt=\"".$filenames[($imgnum-1)]."\" />\n\n";
// Filename
echo "<p id=\"imgname\">".$filenames[($imgnum-1)]."</p>";
// Img number
//echo "<p>Image $imgnum of ".sizeof($filenames)."</p>\n";

// Close <p> - end of image division
if ($standalone == 0) 
{
	echo "</div>\n\n";
}

?>




