#!/bin/csh -f

set npages = $1
set thispage = $2
set colourmode = $3
@ numpairs = $#argv - 3

switch ($colourmode)
case def:
  set space = "trans206x206.gif"
  set bodycomment = 'bgcolor="#c0c0c0"'
  set hr = "<hr>"
  breaksw
case black:
  set space = "trans206x206B.gif"
  set bodycomment = 'bgcolor="#000000" text="#ff9900" link="#ffbb00" vlink="#ff9900"' 
  set hr = '<img src="http://www.cs.ubc.ca/nest/imager/contributions/scharein/inlines/BRline0.gif"  width=600 height=2>'
  breaksw
endsw
  
if ($npages == $thispage) then
  set nextpage = 1
else
  @ nextpage = $thispage + 1
endif

if ($thispage == 1) then
  set prevpage = $npages
  set widefile = stereo.html
  set crossfile = stereo-cross.html
  set title = "Knots in Stereo"
else
  @ prevpage = $thispage - 1
  set widefile = "stereo"$thispage".html"
  set crossfile = "stereo-cross"$thispage".html"
  set title = "Knots in Stereo (page "$thispage")"
endif


if ($prevpage == 1) then
  set prevwidefile = stereo.html
  set prevcrossfile = stereo-cross.html
else
  set prevwidefile = "stereo"$prevpage".html"
  set prevcrossfile = "stereo-cross"$prevpage".html"
endif


if ($nextpage == 1) then
  set nextwidefile = stereo.html
  set nextcrossfile = stereo-cross.html
else
  set nextwidefile = "stereo"$nextpage".html"
  set nextcrossfile = "stereo-cross"$nextpage".html"
endif

foreach Ftype (Wide Cross)

switch ($Ftype)

case Wide:
  set  thismode = "wide-eyed stereo"
  set  othermode = "cross-eyed stereo"
  set  thisfile = $widefile
  set  prevfile = $prevwidefile
  set  nextfile = $nextwidefile
  set  otherfile = $crossfile
  set  A = "L.gif"
  set  B = "R.gif"
  breaksw

case Cross:
  set  othermode = "wide-eyed stereo"
  set  thismode = "cross-eyed stereo"
  set  thisfile = $crossfile
  set  prevfile = $prevcrossfile
  set  nextfile = $nextcrossfile
  set  otherfile = $widefile
  set  B = "L.gif"
  set  A = "R.gif"
  breaksw
endsw

echo -n  "Making $thisfile.   "

echo "<html><head>" > $thisfile
echo "<title>"$title"</title>" >> $thisfile
echo "</head>" >> $thisfile

echo "<body "$bodycomment">" >> $thisfile

echo "<center><b><font=+3>"$title"</b></font><p>" >> $thisfile

echo "<font size=-1>This page is designed for "$thismode".<br>" >> $thisfile
echo "Another page has " >> $thisfile
echo '<a href="'$otherfile'">'$othermode"</a> pairs.<br>" >> $thisfile

echo '[<a href="'$prevfile'">prev page</a>]' >> $thisfile
echo '[<a href="'$nextfile'">next page</a>]' >> $thisfile
echo "<br>" >> $thisfile

foreach pairname ($argv[4-])
  echo -n $pairname" "
  echo '<img src="inlines/'$space'" width=206 height=206><br>' >> $thisfile
  echo '<img src="inlines/'$pairname$A'" width=206 height=206>' >> $thisfile
  echo '<img src="inlines/'$pairname$B'" width=206 height=206><br>' >> $thisfile
end

echo " "
echo " "

echo '<img src="inlines/'$space'" width=206 height=206><br>' >> $thisfile
echo '<img src="inlines/'$space'" width=206 height=206><br>' >> $thisfile

echo '[<a href="'$prevfile'">prev page</a>]' >> $thisfile
echo '[<a href="'$nextfile'">next page</a>]' >> $thisfile
echo "<br>" >> $thisfile

echo "<p>"$hr"<p>" >> $thisfile

echo "</font><p>" >> $thisfile

echo "<p>Go to the" >> $thisfile
echo '<a href="http://www.cs.ubc.ca/nest/imager/contributions/scharein/KnotPlot.html">KnotPlot Site</a>' >> $thisfile
echo "or" >> $thisfile
echo -n '<a href="http://www.cs.ubc.ca/spider/scharein">' >> $thisfile
echo "Rob Scharein's</a>" >> $thisfile
echo "main WWW page." >> $thisfile
cat copy >> $thisfile
echo "</body></html>" >> $thisfile

end

chmod 644 $widefile $crossfile

