<? include $DOCUMENT_ROOT."/zzzfilelist.inc"; ?>
<? include Inc("functions_general.inc.php"); ?>
<? include Inc("functions_images.inc.php"); ?>
<? include Inc("functions_javascript.inc.php"); ?>

<script language="JavaScript">
function choose(imageName) {
	window.opener.document.<? echo $formopener; ?>.gamephoto.value=imageName;
	window.opener.document.photo_img_<? echo $formopener; ?>.src=imageName;
	window.close();
}
</script>
<?
	$basedir = $DOCUMENT_ROOT;
	MakeListImage(DirL('displaymap.php').'gfx/pics');
?>
<?
	$j=0;
	for ($i=1; $i<=$filenb; $i++) {
		if ((!strpos($filename[$i],"_no")) && (strpos($filename[$i],"choice"))) {
			$j++;
			$filename2[$j]=$filename[$i];
		}
	}
	
	$num=$j;
	$larg=5;
	$haut=5;

	if ($photo=="") { $photo=1; }
	$photonext=$photo+$larg*$haut;
	$photoprev=$photo-$larg*$haut;
	if ($photonext>$num) { $photonext=1; }
	if ($photoprev<0) { $photoprev=floor($num/($larg*$haut))*$larg*$haut+1; }
?>
<center><b>Pick a pic</b><br>
<a href="?photo=<? echo $photoprev; ?>">< < < previous < < <</a> --- <a href="?photo=<? echo $photonext; ?>">> > > next > > ></a></center>
<form name="f" method="post">
<input type="hidden" name="imagechosen" value="">
<?
	$k=0;
	echo "<table>";
	for ($j=1; $j<=$larg; $j++) {
		echo "<tr align=center valign=middle>";
		for ($i=1; $i<=$haut; $i++) {
			echo "<td>";
			if ($photo+$k<=$num) {
				echo "<a href='' onclick=\"javascript:choose('".IncL($filename2[$photo+$k])."')\" style='cursor:pointer'><img src='".IncL($filename2[$photo+$k])."' border=0></a>";
			}
			echo "<td>";
			$k++;
		}
		echo "<tr>";
	}
	echo "</table>";
?>
</form>