;;; border.mhtml: -*- Meta-HTML -*-  DESCRIPTIVE TEXT.

;;;  Copyright (c) 1996 Brian J. Fox
;;;  Author: Brian J. Fox (bfox@ai.mit.edu) Mon May 20 15:06:32 1996.

;;; Netscape doesn't let you display anything but background in the
;;; xxx pixels of the left or right hand side of the page.  So,
;;; our border values have to be corrected in order to make the image
;;; and the text layout evenly.  Here it is:
<defvar layout::border-fudge-factor 0>
<defvar layout::cellpadding 0>
<defvar layout::cellspacing 0>
<defvar layout::debug-border 0>

<defvar layout::layout plain>
<defvar layout::left-border-width 120>
<defvar layout::right-border-width 120>

<when <string-eq <get-var layout::layout> plain>>
  <defmacro layout::left-border>%body</defmacro>
  <defmacro layout::page>%body</defmacro>
  <defmacro layout::right-border>%body</defmacro>
  <defun layout::default-header>
    <layout::page>
      <DEBUGGING-OUTPUT>
    </layout::page>
  </defun>
</when>

<when <string-eq <get-var layout::layout> bordered-left caseless=true>>
  <defmacro layout::left-border whitespace=delete>
    <set-var layout::left-border-contents[layout::left-border-index] =
      <prog %body>>
    <increment layout::left-border-index>
  </defmacro>

  <defmacro layout::page whitespace=delete>
    <set-var layout::page-contents[layout::page-index] = <prog %body>>
    <increment layout::page-index>
  </defmacro>

  <defmacro layout::right-border>%body</defmacro>

  <defun layout::default-header>
    <layout::page>
      <DEBUGGING-OUTPUT>
    </layout::page>
    <table border=<get-var layout::debug-border> width=100%
	   cellpadding=<get-var layout::cellpadding>
	   cellspacing=<get-var layout::cellspacing>>
      <tr valign=top>
	<td width=<add layout::left-border-width layout::border-fudge-factor>
	    <if <get-var layout::left-border-color>
		<prog bgcolor=<get-var layout::left-border-color>>>>
	  <img src="/images/trans.gif" height=2 align=left
	       width=<get-var layout::left-border-width>>
	  <br clear>
	  %LEFT-BORDER-CONTENTS%
	</td>
	<td> %PAGE-CONTENTS% </td>
      </tr>
    </table>
  </defun>

</when>

<when <string-eq <get-var layout::layout> bordered-right caseless=true>>
  <defmacro layout::left-border>%body</defmacro>

  <defmacro layout::page whitespace=delete>
    <set-var layout::page-contents[layout::page-index] = <prog %body>>
    <increment layout::page-index>
  </defmacro>

  <defmacro layout::right-border whitespace=delete>
    <set-var layout::right-border-contents[layout::right-border-index] =
      <prog %body>>
    <increment layout::right-border-index>
  </defmacro>

  <defun layout::default-header>
    <layout::page>
      <DEBUGGING-OUTPUT>
    </layout::page>
    <table border=<get-var layout::debug-border>
	   cellpadding=<get-var layout::cellpadding>
	   cellspacing=<get-var layout::cellspacing>>
      <tr valign=top>
	<td> %PAGE-CONTENTS% </td>
	<td width=<add layout::right-border-width layout::border-fudge-factor>
	    align=right
	    <if <get-var layout::right-border-color>
		<prog bgcolor=<get-var layout::right-border-color>>>>
	  <img src="/images/trans.gif" height=2 align=left
	       width=<get-var layout::right-border-width>>
	  %RIGHT-BORDER-CONTENTS%
	</td>
      </tr>
    </table>
  </defun>

</when>

<when <string-eq <get-var layout::layout> bordered-right-and-left
		 caseless=true>>
  <defmacro layout::left-border whitespace=delete>
    <set-var layout::left-border-contents[layout::left-border-index] =
      <prog %body>>
    <increment layout::left-border-index>
  </defmacro>

  <defmacro layout::page whitespace=delete>
    <set-var layout::page-contents[layout::page-index] = <prog %body>>
    <increment layout::page-index>
  </defmacro>

  <defmacro layout::right-border whitespace=delete>
    <set-var layout::right-border-contents[layout::right-border-index] =
      <prog %body>>
    <increment layout::right-border-index>
  </defmacro>

  <defun layout::default-header>
    <layout::page>
      <DEBUGGING-OUTPUT>
    </layout::page>
    <table border=<get-var layout::debug-border>
	   cellspacing=<get-var layout::cellspacing>
	   cellpadding=<get-var layout::cellpadding>>
      <tr valign=top>
	<td width=<add layout::left-border-width layout::border-fudge-factor>
	    <if <get-var layout::left-border-color>
		<prog bgcolor=<get-var layout::left-border-color>>>>
	  <img src="/images/trans.gif" height=2 align=left
	       width=<get-var layout::left-border-width>>
	  <br clear>
	  %LEFT-BORDER-CONTENTS%
	</td>
	<td>
	  %PAGE-CONTENTS%
	</td>
	<td width=<add layout::right-border-width layout::border-fudge-factor>
	    align=right
	    <if <get-var layout::right-border-color>
		<prog bgcolor=<get-var layout::right-border-color>>>>
	  <img src="/images/trans.gif" height=2 align=left
	       width=<get-var layout::right-border-width>>
	  <br clear>
	  %RIGHT-BORDER-CONTENTS%
	</td>
      </tr>
    </table>
  </defun>
</when>

<defsubst layout::resolve-contents>
  <subst-in-page
   "%LEFT-BORDER-CONTENTS%"   "<get-var-once layout::left-border-contents[]>"
   "%PAGE-CONTENTS%"	      "<get-var-once layout::page-contents[]>"
   "%RIGHT-BORDER-CONTENTS%"  "<get-var-once layout::right-border-contents[]>">
</defsubst>
