;+
; NAME        : EIT_SUB_UTIL_SIDE
;
; PURPOSE     : Draw 4 sides around highlighted EIT subfields.
;
; CATEGORY    :
;
; EXPLANATION : 
;
; SYNTAX      : 
;
; EXAMPLES    : none
;
; CALLED BY   :
;
; CALLS TO    : none
;
; ARGURMENTS  :	none
;
; KEYWORDS    : none
;
; OUTPUTS     : none
;
; COMMON      : none
;
; RESTRICTIONS: none
;
; SIDE EFFECTS: none
;
; PROJECT     : SOHO - EIT
;
; HISTORY     : V1,  Elaine Einfalt (HSTX)
;
; CONTACT     : eit@xanado.nascom.nasa.gov
;-

pro EIT_SUB_UTIL_SIDE, x0, y0, color, block, $
		       sub_ids=sub_ids, pix_per=pix_per

common highlight_box, $
		last_resize,    $	; window size last time through here.
					;
		h_line,		$	; dotted horz. long grid
		solid_h_line,	$	; solid horz. line for side
		solid_v_line, 	$	; solid vert. line for top/bottom side
		h_nub, 		$	; solid "nubby" for mid-point sides
		v_line,		$	; dotted vert. long grid
		v_nub, 		$	; solid "nubby" for mid-point sides
		dot_h_line,	$	; dotted horz line for unhighlighting
		dot_v_line		; dotted vert line for unhighlighting

    ; Do the square's sides
    ; Draw the 4 sides of the subfield square.
    ; If un-highlighting and the adjacent subfield is selected then ignore

 ;---

 if block-32 ge 0 then begin		; One above is not off top of screen

      if sub_ids(block-32) ne 1b then begin  	; Box above is not highlighted
 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /top, pix_per=pix_per	;  add top side nub
		tv, solid_h_line,  x0, y0 + pix_per 		;  solid top side line
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /top, pix_per=pix_per	;  kill top side nub
		tv, dot_h_line,  x0, y0 + pix_per		;  dotted top line
        endelse

      endif else begin				; Box above is highlighted 

	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0 + pix_per, color eq 0, /bottom, pix_per=pix_per  ; kill above one's bottom nub
		tv, dot_h_line, x0, y0 + pix_per  		;  dotted top side
	endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0 + pix_per, color eq 0, /bottom, pix_per=pix_per  ; above one gets a bottom nub
		tv, solid_h_line, x0, y0 + pix_per 		;  solid top side 
	endelse

      endelse

 endif else begin				; Can't have one above

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /top, pix_per=pix_per	;  this one gets a top nub
		tv, solid_h_line,  x0, y0 + pix_per 		;  solid line
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /top, pix_per=pix_per	;  kill top side nub
		tv, dot_h_line,  x0, y0 + pix_per		;  dotted top line
        endelse

 endelse
 
 ;---
 
 if block+32 lt 1023 then begin	      ; One below is not off bottom of screen

      if sub_ids(block+32) ne 1b then begin	; Box below not highlighted

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /bottom, pix_per=pix_per	;  add bottom side nub
		tv, solid_h_line,  x0, y0  		;  solid bottom side
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /bottom, pix_per=pix_per	;  kill bottom side nub
		tv, dot_h_line,  x0, y0 		;  dotted top line
        endelse

      endif else begin				; Box below is highlighted 

	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0-pix_per, color eq 0, /top, pix_per=pix_per  ; kill below one's top nub
		tv, dot_h_line, x0, y0   		;  dotted bottom side
	endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0-pix_per, color eq 0, /top, pix_per=pix_per ; one below gets a nub
		tv, solid_h_line, x0, y0 		;  solid bottom side 
 	endelse

      endelse

 endif else begin				; Can't have one below it

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /bottom, pix_per=pix_per	; this one gets a nub on bottom
		tv, solid_h_line, x0, y0       
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /bottom, pix_per=pix_per	;  kill top side nub
		tv, dot_h_line,  x0, y0 + pix_per		;  dotted top line
        endelse
 endelse

 ;---

 if (block mod 32) ne 0 then begin	; One to the left is not off screen

      if sub_ids(block-1) ne 1b then begin	; Box to left is not highlighted

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /left, pix_per=pix_per 	;  add left side nub
		tv, solid_v_line,  x0, y0  		;  solid left side
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /left, pix_per=pix_per 	;  kill left side nub
		tv, dot_v_line,  x0, y0 		;  dotted top line
        endelse

      endif else begin				; Box to left is highlighted 

	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0-pix_per, y0, color eq 0, /right, pix_per=pix_per  ; kill left one's right nub
		tv, dot_v_line, x0, y0   		;  dotted left side
	endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0-pix_per, y0, color eq 0, /right, pix_per=pix_per  ; one to left gets a right nub
		tv, solid_v_line, x0, y0 		;  solid left side 
 	endelse

      endelse

 endif else begin				; Can't have one to the left

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /left, pix_per=pix_per	;  this one gets a left nub
		tv, solid_v_line,  x0, y0  		;  solid left side
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /left, pix_per=pix_per 	;  kill left side nub
		tv, dot_v_line,  x0, y0			;  dotted left side
        endelse
 endelse

 ;---

 if (block mod 32) ne 31 then begin	; One to right is not off screen

      if sub_ids(block+1) ne 1b then begin	; Box to right is not highlighted

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /right, pix_per=pix_per 	;  add right side nub
		tv, solid_v_line,  x0+pix_per, y0  		;  solid right side
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /right, pix_per=pix_per 	;  kill right side nub
		tv, dot_v_line,  x0+pix_per, y0 		;  dotted right side
        endelse

      endif else begin				; Box to right is highlighted 

	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0+pix_per, y0, color eq 0, /left, pix_per=pix_per  ; kill right one's left nub
		tv, dot_v_line, x0+pix_per, y0   		;  dotted right side
	endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0+pix_per, y0, color eq 0, /left, pix_per=pix_per  ; one to right gets a left nub
		tv, solid_v_line, x0+pix_per, y0 		;  solid right side 
 	endelse

      endelse

 endif else begin				; Can't have one to the right

 	if color eq 1 then begin			; Highlighting
		EIT_SUB_UTIL_NUB, x0, y0, color, /right, pix_per=pix_per	;  this one gets a right nub
		tv, solid_v_line,  x0+pix_per, y0  		;  solid right side
        endif else begin				; Unhighlighting
		EIT_SUB_UTIL_NUB, x0+pix_per, y0, color, /right, pix_per=pix_per 	;  kill right side nub
		tv, dot_v_line,  x0+pix_per, y0		;  dotted right side
        endelse

 endelse

return
end

