Index: /trunk/Ohana/src/imregister/detrend/args.detsearch.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/args.detsearch.c	(revision 11)
+++ /trunk/Ohana/src/imregister/detrend/args.detsearch.c	(revision 12)
@@ -172,6 +172,6 @@
   output.Close = FALSE;
   if (N = get_argument (argc, argv, "-close")) {
-    if (!base.TimeSelect) {       
-      fprintf (stderr, "ERROR: syntax error in -close requires -time or -trange\n");
+    if (!base.TimeSelect && !ImageSelect && !MosaicSelect) {       
+      fprintf (stderr, "ERROR: syntax error in -close requires one of: -time -trange -image -mosaic\n");
       exit (1);
     }
Index: /trunk/Ohana/src/imregister/detrend/criteria.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/criteria.c	(revision 11)
+++ /trunk/Ohana/src/imregister/detrend/criteria.c	(revision 12)
@@ -23,5 +23,10 @@
     if (criteria[i].NameSelect   && (strstr (image[0].filename, criteria[i].Name) == (char *) NULL)) continue;
 
-    if (criteria[i].TimeSelect   && (image[0].tstart           > criteria[i].tstop))   continue;
+    /* looking for the best 'close' match: minimum |dt| */
+    if (criteria[i].TimeSelect   && (image[0].tstart           > criteria[i].tstop))  {
+      close = TRUE;
+      crit  = i;
+      continue;
+    } 
     if (criteria[i].TimeSelect   && (image[0].tstop            < criteria[i].tstart)) {
       close = TRUE;
@@ -163,5 +168,6 @@
       if (match[j].crit  != i) continue;
       entry = match[j].image;
-      dmin = MIN (dmin, criteria[i].tstart - image[entry].tstop);
+      dtime = (image[entry].tstop < criteria[i].tstart) ?  criteria[i].tstart - image[entry].tstop : image[entry].tstart - criteria[i].tstop;
+      dmin = MIN (dmin, dtime);
     }
 
@@ -170,5 +176,5 @@
       if (match[j].crit  != i) continue;
       entry = match[j].image;
-      dtime = criteria[i].tstart - image[entry].tstop;
+      dtime = (image[entry].tstop < criteria[i].tstart) ?  criteria[i].tstart - image[entry].tstop : image[entry].tstart - criteria[i].tstop;
       if (dtime <= dmin) {
 	new[Nnew] = match[j];
Index: /trunk/Ohana/src/imregister/detrend/unique.c
===================================================================
--- /trunk/Ohana/src/imregister/detrend/unique.c	(revision 11)
+++ /trunk/Ohana/src/imregister/detrend/unique.c	(revision 12)
@@ -93,5 +93,5 @@
   if (crit[0].CCD     != image[0].ccd    ) return (FALSE);
   if (crit[0].Type    != image[0].type   ) return (FALSE);
-  if (crit[0].Exptime != image[0].exptime) return (FALSE);
+  /* if (crit[0].Exptime != image[0].exptime) return (FALSE); */
 
   if (crit[0].tstart  > image[0].tstop) return (FALSE);
