function sxt_satscreen,index,data,fr=fr,timer=timer

;+
; PROGRAM NAME
;	sxt_satscreen
;
; PURPOSE
;	To identify images for which the only saturation is dark spike
;	saturation, i.e., no solar x-ray saturation.  This allows these
;	images to be processed into movie images without compositing.
;
; PROCEDURE
;	The program takes advantage of the fact that dark spike saturation
;	is only a single column wide in the x-direction.  Images with no
;	x-ray saturation features above row 5 (to eliminate "bottom row"
;	problems) are accepted as x-ray saturation free.  The rare cases
;	of genuine single-column saturated solar features will not be caught
;	by this code -- but this is not much of a problem as they
;	will still be in the movie.
;	*** TAKES ABOUT 20 SEC FOR (512,512,36) DATA CUBE ***
;	*** WASTED A LOT OF TIME TRYING TO MAKE IT FASTER  :-(  ***
;
;	Test is implemented on gt_res or keyword RES because saturation level
;	for FR images is 235 DN.  Use either index structure or set
;	/fr keyword flat.  Default is saturation=255 DN.
;
; CALLING SEQUENCE
;	outlist = sxt_satscreen(index,data)
;	outlist = sxt_satscreen(xx,data,/fr,/timer
;	
; INPUT
;	index = sxt index structure OR any non-structure input to ignore.
;	****OK to use on mixed-resolution data cube if index is passed in.***
;	data = raw, sxt_compressed image or data cube.
;
; OPTIONAL INPUT KEYWORD
;	/fr specifies that all input data are full resolution
;	/timer will print out 'SXT_SATSCREEN took:   ....." message.
; OUTPUT
;	outlist = logic vector, unsaturated images are 1's.
;
; HISTORY
;	16-Oct-96 [LWA], written.
; 	19-Oct-96 [LWA], added timer keyword.
;	23-Oct-96 [LWA], changed handle FR case, too.
;-


if keyword_set(timer) then begin
   start_time = systime(1)
   run_time = 0.
endif

siz=size(data)

if(siz(0) eq 2) then begin
	; CASE FOR SINGLE IMAGE.
if (datatype(index(0),2)) eq 8 then res=gt_res(index) else res=1
if res eq 0 or keyword_set(fr) then sat=235 else sat=255
   array=temporary(data(*,5:siz(2)-1)) ge sat
   n3=total(total(((2.*(array)-shift(array,1,0)) eq 1),1),1)
endif else begin
		; CASE FOR DATA CUBE.
   if (datatype(index(0),2)) eq 8 then res=gt_res(index)
   if n_elements(res) gt 0 then jj=where(res eq 0,nj) else nj=0 & jj=indgen(siz(3))
   sat=intarr(siz(3))+255
   if nj ne 0 then sat(jj)=235
   if keyword_set(fr) then sat(*)=235
      array=intarr(siz(1),siz(2)-5,siz(3))
      for i=0,siz(3)-1 do begin
         array(0,0,i)=data(*,5:siz(2)-1,i) ge sat(i)
      endfor
   n3=total(total(((2.*(array)-shift(array,1,0,0)) eq 1),1),1)
endelse

out = n3 eq 0

if keyword_set(timer) then begin
   end_time = systime(1)
   run_time = (end_time-start_time)
   print, 'SXT_SATSCREEN took: ', run_time, ' seconds to process your request'
endif

return,out


end
