--- qdig-20051203cnj.php	Sat Dec  3 22:13:15 2005
+++ qdig-20060105cnj.php	Thu Jan  5 20:12:37 2006
@@ -37,9 +37,9 @@
 | Version 2 along with this program; if not, visit GNU's Home Page
 | http://www.gnu.org/
 +----------------------------------------------------------------------+
-CVS: $Id: qdig.php,v 1.21 2005/12/04 00:22:39 matt Exp $#
+CVS: $Id: qdig.php,v 1.29 2006/01/06 01:11:36 matt Exp $#
 */#
-$qdig_version = '20051203cnj [based on 20050509]';
+$qdig_version = '20060105cnj [based on 20050509]';
 $mtime = microtime();
 $mtime = explode(' ', $mtime);
 $start_time = $mtime[1] + $mtime[0];
@@ -67,7 +67,8 @@
 * If this is set, the text will appear at the bottom of your gallery.
 * See http://www.whatiscopyright.org/ for information about copyrights.
 */
-$copyright['txt'] = 'Images copyright &copy; 2003, 2004, 2005 original creators or assignees. All rights reserved.';#
+$copyright['txt'] = 'Images copyright &copy; 2003, 2004, 2005, 2006 original creators or assignees. All rights reserved.';#
 
 /**
 * Admin Script
@@ -114,7 +115,7 @@
 $dir_nav['fname_ena'] = FALSE; // Display the filename.
 $dir_nav['cntr_ena']  = TRUE;  // Display the counter.
 $dir_nav['path_delim'] = '&gt;'; // Delimiter between path elements
-$dir_nav['align_dirs'] = 'center'; // Subdirs-only alignment (left/center/right).
+$dir_nav['align_dirs'] = 'left'; // Subdirs-only alignment (left/center/right).
 $dir_nav['dir_is_new'] = 30 * 24 * 60 * 60; // New if less than this many seconds
 $dir_nav_lang_new      = 'New';#
 $dir_nav['new_flag']   = "&nbsp;
@@ -124,7 +125,7 @@
 $dir_nav['sort_age']  = FALSE;  // Sort directories by time-since-modified
                                 // (most recent first) rather than by alpha.
 $dir_nav['sort_rev']  = FALSE;  // Reverse the sort order of directories.
-$dir_nav['icon']      = FALSE;  // Display a camera icon in directory links.
+$dir_nav['icon']      = 2;  // Display a camera icon in directory links.
 $dir_nav['updir_ena'] = TRUE;   // Display an up-one-level link.
 $dir_nav['row_width'] = '100%'; // Width of the Directory Navigation row
 $dir_nav['start_thm'] = TRUE;  // Start in a dir with thumbs-only display (if
@@ -1641,6 +1642,30 @@
 } // End dirnavPath()
 
 /**
+* Get random image from a directory
+*/
+function getDirectoryImage($root, $bThmb=false)
+{
+	global $url_base_path, $pwd, $cnvrt_files_root, $cnvrtd_dir, $cnvrt_thmb;
+	$dirs=array('');
+	while(sizeof($dirs)) {
+		shuffle($dirs);
+		foreach($dirs as $dir) {
+			$dir_imgs = getImageFilenames($root.'/'.$dir);
+			$rval = $dir_imgs[rand(0,sizeof($dir_imgs)-1)];
+			if($rval!='') {
+				if(!$bThmb) return $rval;
+				$dcnvrt_path   = cleanPath($cnvrtd_files_root.$root.'/'.$dir.'/'.$cnvrtd_dir);
+				$thmb_file = $url_base_path.'/'.$dcnvrt_path.'/'.'/'.$cnvrt_thmb['prefix'].$rval.'.jpeg';
+				return $thmb_file;
+			}
+		}
+		$root=$root.'/'.$dirs[0];
+		$dirs = array_keys(getDirNames($root));
+	}
+}
+
+/**
 * Produce navigation links to subdirectory galleries.
 */
 function subdirLinks($dir_nav)
@@ -1689,10 +1714,16 @@
 			} else {
 				$newdir = '';
 			}
+			$rimg='';
+			if ($dir_nav['icon'] == 2 && !isset($imgs)) {
+				$rand_image = getDirectoryImage("{$reqd_image['pwd']}/$dir", True);
+				$rimg = '<img src="'.$rand_image.'" alt="Gallery Image" style="vertical-align:middle" />&nbsp;';
+				if($rand_image=='') $rimg='';
+			}
 			$str .= <<<EOT
     <span style='white-space:nowrap;'>$tag1$bkt1
      <a  href="$qdig_url?{$extra_param}Qwd={$reqd_image['pwd_url']}/$dirurl{$qif}&amp;Qiv={$reqd_image['view']}&amp;Qis={$reqd_image['size']}$anchor"
-      class="qdig-subdirlink" title="{$dir_nav['go_to_txt']} $dir">$icon$dirtxt$newdir $dircapt</a>
+      class="qdig-subdirlink" title="{$dir_nav['go_to_txt']} $dir">$icon$rimg$dirtxt $dircapt $newdir</a>
     $bkt2</span>\n
 EOT;
 		}
