;+
; NAME        : EIT_SUB_UTIL_MOVE
;
; PURPOSE     :	Redraw EIT subfield pattern at the input offset location.
;
; CATEGORY    :
;
; EXPLANATION : 
;
; SYNTAX      : 
;
; EXAMPLES    : none
;
; CALLED BY   :
;
; CALLS TO    : none
;
; ARGURMENTS  :	none
;
; KEYWORDS    : none
;	SUB_IDS		BYRARR(1024) with indices of currently highlighted
;			blocks set to 1b, and all the rest set to 0b.
;       OFFSET		A new offset value, may be shifted to fit.
;
; OUTPUTS     : none
;
; COMMON      : none
;
; RESTRICTIONS: none
;
; SIDE EFFECTS: none
;
; PROJECT     : SOHO - EIT
;
; HISTORY     : V1,  Elaine Einfalt (HSTX)
; 	1999-march  Einfalt - - passing group to more routines for V5 modal
;
; CONTACT     : eit@xanado.nascom.nasa.gov
;-

pro EIT_SUB_UTIL_MOVE, $
			offset		= offset,	$ 
			sub_ids		= sub_ids,	$
			substruc	= substruc


 ; Get the index numbers of all currently highlighted subfields
 ; When there is no pattern to be moved to the new offset, 
 ;      bring subfield tool to the foreground.

 blocks = where(sub_ids eq 1b, n_blks) 

 if n_blks eq 0 then begin	
    if xregistered('EIT_SUBFIELD') then widget_control, hourglass=0
    return 			
 endif

 ;
 ; Get and save the current (old) offset value, based on the SUB_IDS pattern.
 ;

 save_offset = EIT_SUB_GETOFF(sub_ids)

 ;
 ; Test and modify (if necessary) the requested passed in offset, using 
 ; current SUB_IDS pattern.  The result may be the offset for the subfield
 ; pattern adjusted to fit within the window.
 ;

 ok = EIT_SUB_FIXOFF(sub_ids=sub_ids, offset=offset, group=substruc.sub_base_id)

 ;
 ; Erase all currently highlighted blocks
 ;

 EIT_SUB_UTIL_HIGH, color	= bytarr(n_blks), $
		    blocks	= blocks, 	  $
		    sub_ids	= sub_ids, 	  $
		    pix_per	= substruc.pix_per

 ;
 ; Move adjusted block values to the new offset location
 ;
 blocks = blocks + (offset - save_offset)

 ;
 ; Set the SUB_IDS indices, of the moved blocks
 ; SUB_IDS came back from EIT_SUB_UTIL_HIGH as all zeroes.
 ;

 sub_ids(blocks) = 1b	

 ;  
 ; Highlight all the blocks in the pattern, now at new (input) OFFSET
 ;  

 EIT_SUB_UTIL_HIGH, color	= bytarr(n_blks)+1, 	$
		    blocks	= blocks, 		$
		    sub_ids	= sub_ids, 		$
		    pix_per	= substruc.pix_per

return
end
