Index: lib/TWiki/Plugins/PhotoarchivePlugin.pm
===================================================================
--- lib/TWiki/Plugins/PhotoarchivePlugin.pm	(Revision 461)
+++ lib/TWiki/Plugins/PhotoarchivePlugin.pm	(Arbeitskopie)
@@ -36,6 +36,7 @@
 #use TWiki::Plugins::PhotoarchivePlugin::;
 #use TWiki::Func;
 #use CGI;
+use POSIX;
 
 # =========================
 use vars qw(
@@ -286,7 +287,7 @@
 		TWiki::Func::getPluginPreferencesValue("THUMBSROW") || "4";
 	my $images_per_page = TWiki::Func::getPreferencesValue($pluginName."_DESCRIPTEDIMAGES") ||
 		TWiki::Func::getPluginPreferencesValue("DESCRIPTEDIMAGES") || "5";
-	my $virt_page = int( $page * $images_per_page / ($images_per_col * $images_per_row) ) + 1;
+	my $images_per_tpage = $images_per_row * $images_per_col;
 	my $image_width = TWiki::Func::getPreferencesValue($pluginName."_DESCRIPTEDWIDTH") ||
 		TWiki::Func::getPluginPreferencesValue("DESCRIPTEDWIDTH") || "250";
 	my $image_height = TWiki::Func::getPreferencesValue($pluginName."_DESCRIPTEDHEIGHT") ||
@@ -363,6 +364,7 @@
 
 	for ( my $i=0; $i <= $#image_file; $i++ )
 	{
+		my $virt_page = ceil( ($page * $images_per_page - $images_per_page + $i + 1) / $images_per_tpage );
 		$descripted = $sourceimage = $pfile->[$i];
 		$descripted =~ s/\.[^\.]*$//;
 		$sourcedescripted = "$attachment_dir"."_"."$pluginName"."_"."$descripted"."_descripted.jpg";
@@ -422,8 +424,10 @@
 	}
 	$content .= qq(</div>);
 
-	$content = qq(<br />\n<div align="center"><a href="?PhotoarchivePlugin_page=$virt_page&PhotoarchivePlugin_view=thumbs" class="twikiLink">thumbnails</a> &nbsp;&nbsp;&nbsp; descriptions &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$virt_page&PhotoarchivePlugin_view=detailed" class="twikiLink">details</a></div>\n<br />\n).$content;
+	my $virt_page = ceil( ($page * $images_per_page - $images_per_page + 1) / $images_per_tpage );
 
+	$content = qq(<br />\n<div align="center"><a href="?PhotoarchivePlugin_page=$virt_page&PhotoarchivePlugin_view=thumbs" class="twikiLink">thumbnails</a> &nbsp;&nbsp;&nbsp; descriptions &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_file=$pfile->[0]&PhotoarchivePlugin_page=$virt_page&PhotoarchivePlugin_view=detailed" class="twikiLink">details</a></div>\n<br />\n).$content;
+
 	return $content;
 
 }
@@ -443,6 +447,8 @@
 	my $images_per_row = TWiki::Func::getPreferencesValue($pluginName."_THUMBSROW") ||
 		TWiki::Func::getPluginPreferencesValue("THUMBSROW") || "4";
 	my $images_per_page = ( $images_per_col * $images_per_row );
+	my $images_per_dpage = TWiki::Func::getPreferencesValue($pluginName."_DESCRIPTEDIMAGES") ||
+		TWiki::Func::getPluginPreferencesValue("DESCRIPTEDIMAGES") || "5";
 	my $image_width = TWiki::Func::getPreferencesValue($pluginName."_DETAILEDWIDTH") ||
 		TWiki::Func::getPluginPreferencesValue("DETAILEDWIDTH") || "600";
 	my $image_height = TWiki::Func::getPreferencesValue($pluginName."_DETAILEDHEIGHT") ||
@@ -601,8 +607,10 @@
 		
 	$content .= qq(</div>);
 
-	$content = qq(<br />\n<div align="center"><a href="?PhotoarchivePlugin_page=$page&PhotoarchivePlugin_view=thumbs" class="twikiLink">thumbnails</a> &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$page&PhotoarchivePlugin_view=descripted" class="twikiLink">descriptions</a> &nbsp;&nbsp;&nbsp; details</div>\n<br />\n).$content;
+	my $virt_page = ceil( ($page * $images_per_page - ($images_per_page - $array_counter - 1)) / $images_per_dpage );
 
+	$content = qq(<br />\n<div align="center"><a href="?PhotoarchivePlugin_page=$page&PhotoarchivePlugin_view=thumbs" class="twikiLink">thumbnails</a> &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$virt_page&PhotoarchivePlugin_view=descripted" class="twikiLink">descriptions</a> &nbsp;&nbsp;&nbsp; details</div>\n<br />\n).$content;
+
 	return $content;
 
 }
@@ -622,6 +630,8 @@
 	my $images_per_row = TWiki::Func::getPreferencesValue($pluginName."_THUMBSROW") ||
 		TWiki::Func::getPluginPreferencesValue("THUMBSROW") || "4";
 	my $images_per_page = ( $images_per_col * $images_per_row );
+	my $images_per_dpage = TWiki::Func::getPreferencesValue($pluginName."_DESCRIPTEDIMAGES") ||
+		TWiki::Func::getPluginPreferencesValue("DESCRIPTEDIMAGES") || "5";
 	my $image_width = TWiki::Func::getPreferencesValue($pluginName."_THUMBSWIDTH") ||
 		TWiki::Func::getPluginPreferencesValue("THUMBSWIDTH") || "";
 	my $image_height = TWiki::Func::getPreferencesValue($pluginName."_THUMBSHEIGHT") ||
@@ -758,8 +768,10 @@
 	}
 	$content .= qq(</div>);
 
-	$content = qq(<br />\n<div align="center">thumbnails &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$page&PhotoarchivePlugin_view=descripted" class="twikiLink">descriptions</a> &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$page&PhotoarchivePlugin_view=detailed" class="twikiLink">details</a></div>\n<br />\n).$content;
+	my $virt_page = ceil( (($page - 1) * $images_per_page + 1) / $images_per_dpage );
 
+	$content = qq(<br />\n<div align="center">thumbnails &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$virt_page&PhotoarchivePlugin_view=descripted" class="twikiLink">descriptions</a> &nbsp;&nbsp;&nbsp; <a href="?PhotoarchivePlugin_page=$page&PhotoarchivePlugin_view=detailed" class="twikiLink">details</a></div>\n<br />\n).$content;
+
 	return $content;
 
 }
Index: data/TWiki/PhotoarchivePlugin.txt
===================================================================
--- data/TWiki/PhotoarchivePlugin.txt	(Revision 461)
+++ data/TWiki/PhotoarchivePlugin.txt	(Arbeitskopie)
@@ -146,9 +146,11 @@
 ---++ Plugin Info
 
 |  Plugin Author: | TWiki:Main/MarkusKolb |
-|  Plugin Version: | 31 Oct 2006 (V1.004) |
+|  Plugin Version: | 04 May 2007 (V1.006) |
 |  Plugin Id: | $Id$ |
 |  Change History: | <!-- versions below in reverse order -->&nbsp; |
+|  04 May 2007: | V1.006 bugfix - last part of page selection |
+|  04 May 2007: | V1.005 bugfix - descripted and detailed page selection |
 |  31 Oct 2006: | V1.004 updated this plugin info for new version |
 |  31 Oct 2006: | V1.003 fix quote image filename bug (Thanks to Michael Okincha for bug report) |
 |  30 Sep 2004: | V1.002 overwriting of plugin preferences in topic now possible |
@@ -164,5 +166,5 @@
 
 __Related Topics:__ %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins
 
--- Main.MarkusKolb - 31 Oct 2006
+-- Main.MarkusKolb - 04 May 2007
 
