#!/usr/bin/csh -f

# the question directory is $1
# the persons in question are $2 and $3

echo "  Creating anchor for $2 and $3..."

set questionhtml = "questions/$1.html"

set found = 0

if (-f "$1/$2_$3.txt") then
  echo "<p><a name=\042$2_$3\042><b><u>" `cat candidates/$2.txt` " and " `cat candidates/$3.txt` "</u></b>:<p>" >> $questionhtml
  echo "<ul>" >> $questionhtml
  cat "$1/$2_$3.txt" >> $questionhtml
  echo "</ul>" >> $questionhtml
  set found = 1
endif
if (-f "$1/$3_$2.txt") then
  echo "<p><a name=\042$2_$3\042><b><u>" `cat candidates/$2.txt` " and " `cat candidates/$3.txt` "</u></b>:<p>" >> $questionhtml
  echo "<ul>" >> $questionhtml
  cat "$1/$3_$2.txt" >> $questionhtml
  echo "</ul>" >> $questionhtml
  set found = 1
endif
if (-f "$1/$2.txt") then
  echo "<p><a name=\042$2\042><b><u>" `cat candidates/$2.txt` "</u></b>:<p>" >> $questionhtml
  echo "<ul>" >> $questionhtml
  cat "$1/$2.txt" >> $questionhtml
  echo "</ul>" >> $questionhtml
  set found = 1
endif
if (-f "$1/$3.txt") then
  echo "<p><a name=\042$3\042><b><u>" `cat candidates/$3.txt` "</u></b>:<p>" >> $questionhtml
  echo "<ul>" >> $questionhtml
  cat "$1/$3.txt" >> $questionhtml
  echo "</ul>" >> $questionhtml
  set found = 1
endif

if ($found == 1) then
  echo "Back to the <a href=\042#top\042>top</a>.<p>" >> $questionhtml
  echo "<hr width=50%>" >> $questionhtml
endif
