<table border=0 cellpadding=2 cellspacing=0>
<tr>
<td align="center">

<table style="display: inline; height: 150px;" border=0 cellpadding=0 cellspacing=0><tr><td align="center" valign="top">
% if ($have_dfile) {
<img width="125" height"125" src="/model/<% $dbname %>/stamp.jpg?file=<% $dfile %>">
<br><small>Diff | <a href="/model/<% $dbname %>/stamp.fits?file=<% $dfile %>">FITS</a></small>
% } else {
<div style="width: 125px; height: 125px; border: 1px solid grey;"><b>No<br>diff<br>stamp</b></div>
% }
</td></tr></table>

<table style="display: inline; height: 150px;" border=0 cellpadding=0 cellspacing=0><tr><td align="center" valign="top">
% if ($have_cfile) {
<img width="125" height"125" src="/model/<% $dbname %>/stamp.jpg?file=<% $cfile %>">
<br><small>Chip | <a href="/model/<% $dbname %>/stamp.fits?file=<% $cfile %>">FITS</a></small>
% } else {
<div style="width: 125px; height: 125px; border: 1px solid grey;"><b>No<br>chip<br>stamp</b></div>
% }
</td></tr></table>

</td>
</tr></table>


<%args>
$det_id => undef
$det => undef
</%args>

<%init>
use Digest::MD5;
my $inst = $m->notes('INST');

if ($det) {
    $det_id = $det->detId;
}

my $dbname = $inst->dbname;
my $id = sprintf "%010d", $det_id;
my $dreldir = join('/', 'MD', split '', substr(uc(Digest::MD5::md5_hex($id)), 0, 5));
my $creldir = join('/', 'MC', split '', substr(uc(Digest::MD5::md5_hex($id)), 0, 5));

my $dfile = $inst->getEnvironment('VARDIR') . "/stamps/$dreldir/MD-$id.fits";
if (!-f $dfile) {
    my $nn = int($det->epoch) - 1;  # TJD to MOPS nn
    my ($dir) = $det_id =~ /(\d)$/;
    $dfile = "/data/mops13.0/stamp-store/stamps/special-stamps/$dbname-auto/$nn/$dir/D$det_id.fits";
    if (!-f $dfile) {
        $dfile = "/data/mops13.0/stamp-store/stamps/special-stamps/$dbname-auto/$nn/D$det_id.fits";
    }
}
my $have_dfile = -f $dfile;

my $cfile = $inst->getEnvironment('VARDIR') . "/stamps/$creldir/MC-$id.fits";
if (!-f $cfile) {
    my $nn = int($det->epoch) - 1;  # TJD to MOPS nn
    my ($dir) = $det_id =~ /(\d)$/;
    $cfile = "/data/mops13.0/stamp-store/stamps/special-stamps/$dbname-auto/$nn/$dir/C$det_id.fits";
    if (!-f $cfile) {
        $cfile = "/data/mops13.0/stamp-store/stamps/special-stamps/$dbname-auto/$nn/C$det_id.fits";
    }
}
my $have_cfile = -f $cfile;

my $stuff;
</%init>
