close,1
mywin=0
filenm=' '
syn=0
syn=intarr(360,181)
fpos=0
fpos=lonarr(200)   &  ftmp=long(0)   &   ii=0
                  
; Open a window
device,window_state=winst
if(winst(mywin) eq 0)then window,mywin,xsize=360,ysize=181

; Load color table
_a=intarr(256)  &  _b=intarr(256)  &  _c=intarr(256)
openr,11,'syn_col.rgb' & readu,11,_a  &  readu,11,_b  &  readu,11,_c  &  close,11
tvlct,_a,_b,_c
                  
mn=0 & mx=1500
if( n_elements(listfile) eq 0) then begin ;{
    listfile=' '
    print,$
      'Enter in a filename that contains a list of the maps you wish to view.'
    print,'The list should include the entire path to the images.'
    read,listfile
endif $
else begin ;}{
    print,' '
    print,'Your present listfile is: ',listfile
    print,'If you want to change it, enter the idl command: listfile=''newone'''
    print,'Where ''newone'' is an example new list file.'
    print,' '
endelse;}

print,' '
print,'The images listed in file: ',listfile,' will now be displayed.'
print,' '
print,'You can use the mouse to move backwards and forwards in your image list.'
print,'     To move forwards, use the left most mouse button.'
print,'     To move backwards, use the middle   mouse button.'
print,' '
print,' '


close,13 & openr,13,listfile
                  
while ( not eof(13) ) do begin ;{
    point_lun,-13,ftmp  & fpos(ii)=ftmp
    readf,13,filenm
    close,1 & openr,1,filenm & readu,1,syn & close,1
    
    wset,mywin  & tv,bytscl(syn,min=mn,max=mx),order=1
    xyouts,.0,.85,filenm,size=2,/NORMAL
    print,'Image presently displayed is: ',filenm
    
    
    ; Logic to move forwards or backwards in the list of images.
    cursor,x,y,/NORMAL
    if ( !ERR eq 2 ) then begin ;{
	ii=ii-1  & if (ii le 0) then ii=0
	point_lun,13,fpos(ii)
    endif else begin ;}{
	ii=ii+1
    endelse ;}
    wait, 0.3

endwhile ;}
                  
close,13
end
