#!/usr/bin/csh -f

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

echo "Creating anchor for $3..."

if ($2 != "x") then
  set candidatehtml = "candidates/$1_$2.html"
else
  set candidatehtml = "candidates/$1.html"
endif

set found = 0

if (-f "$3/$1.txt") then
  echo "<p><a name=\042$3\042><b><u>" `cat $3/question` "</u></b>:<p>" >> $candidatehtml
else if (-f "$3/$2.txt") then
  echo "<p><a name=\042$3\042><b><u>" `cat $3/question` "</u></b>:<p>" >> $candidatehtml
else if (-f "$3/$1_$2.txt") then
  echo "<p><a name=\042$3\042><b><u>" `cat $3/question` "</u></b>:<p>" >> $candidatehtml
else if (-f "$3/$2_$1.txt") then
  echo "<p><a name=\042$3\042><b><u>" `cat $3/question` "</u></b>:<p>" >> $candidatehtml
endif

if (-f "$3/$1.txt") then
  echo "&nbsp;&nbsp;&nbsp;<u>" `cat candidates/$1.txt` "</u>:<p>" >> $candidatehtml
  echo "<ul>" >> $candidatehtml
  cat "$3/$1.txt" >> $candidatehtml
  echo "</ul>" >> $candidatehtml
  set found = 1
endif
if (-f "$3/$2.txt") then
  echo "&nbsp;&nbsp;&nbsp;<u>" `cat candidates/$2.txt` "</u>:<p>" >> $candidatehtml
  echo "<ul>" >> $candidatehtml
  cat "$3/$2.txt" >> $candidatehtml
  echo "</ul>" >> $candidatehtml
  set found = 1
endif
if (-f "$3/$1_$2.txt") then
  echo "&nbsp;&nbsp;&nbsp;<u>" `cat candidates/$1.txt` " and " `cat candidates/$2.txt` "</u>:<p>" >> $candidatehtml
  echo "<ul>" >> $candidatehtml
  cat "$3/$1_$2.txt" >> $candidatehtml
  echo "</ul>" >> $candidatehtml
  set found = 1
endif
if (-f "$3/$2_$1.txt") then
  echo "&nbsp;&nbsp;&nbsp;<u>" `cat candidates/$1.txt` " and " `cat candidates/$2.txt` "</u>:<p>" >> $candidatehtml
  echo "<ul>" >> $candidatehtml
  cat "$3/$2_$1.txt" >> $candidatehtml
  echo "</ul>" >> $candidatehtml
  set found = 1
endif

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