#!/bin/csh -f
echo "Content-type: text/html"
echo ""

setenv HD /data/globec

if ( ! -e /jgofsopt/$REMOTE_HOST ) then
 mkdir /jgofsopt/$REMOTE_HOST
 cp $HD/htmlsrc/setup/* /jgofsopt/$REMOTE_HOST
 endif
cd /jgofsopt/$REMOTE_HOST

set tmp=$PATH_INFO
setenv OBJ $tmp:r
setenv FULLOBJ $OBJ
setenv QS ""
unsetenv PATH_INFO

echo "<html><head><title>Sub-selections page</title></head>"
echo "<body>"

cat <<EOFSEL
<a href="http://usjgofs.whoi.edu/datasys/subhelp.html" target="_blank">
<img alt="[HELP]" src="http://usjgofs.whoi.edu/images/help.gif" align=right>
</a>
<h1>Selections and Projections</h1>
EOFSEL

echo "<form method="\""POST"\"" action="\""/jg/selopt1${tmp}?${QS}"\"" >"
echo "<b>Current object is: $OBJ<br>"

if ( "$QUERY_STRING" != "" ) then
  setenv QS "`$HD/htmlbin/bin/htmlesc '$QUERY_STRING'`"
  setenv FULLOBJ "$OBJ($QS)"
  echo "Active sub-selections - $QS"
else
  echo "Active sub-selections - [none]"
endif

cat << XXstuffXX
</b>
<hr noshade><p>
<input type="submit" value="Reset all">
</form>
XXstuffXX

$HD/bin/listvar "$OBJ" > variables
#
# begin the form part of the script
#
cat <<EOFSEL
<b><font size="5">
To add to the active sub-selections list, either :</font>
<br>
<img alt="<li>" src="/icons/ball.red.gif">
<font size="4">
 Choose from the cells below, and then click on an 'Add ...' button
</font></b>
<center>
<table border=4>
<tr border=2>
<td><center>Selections</center></td>
<td><center>Projections</center></td>
</tr>
<tr valign="top">
<td valign="top">
EOFSEL
#
# SELECTIONS
#
echo "<form method="\""POST"\"" action="\""/jg/selopt2${tmp}?${QS}"\"">"
echo "<select name="\""var"\"">"
$HD/htmlbin/bin/nawkscr < variables
echo "</select>"

echo "<select name="\""op"\"">"
$HD/htmlbin/bin/nawkscr << XXSTUFFXX
=
&lt;
&gt;
&lt;&gt;
&lt;=
&gt;=
XXSTUFFXX
echo "</select>"

echo "<input name="\""val"\"" type="\""text"\"" size="\""5"\"">"
echo "<input type="\""submit"\"" value="\""Add selection"\"">"

echo "</form></td><td valign="\""top"\"">"

echo "<form method="\""POST"\"" action="\""/jg/selopt3${tmp}?${QS}"\"">"
echo "Multiple projections are accepted.<p>"
echo "<select multiple size=6 name="\""var"\"" align=middle>"
$HD/htmlbin/bin/nawkscr < variables
cat <<EOFSEL
</select>
<input type="submit" value="Add projection(s)">
</form>
</td>
</tr>
</table>
</center>

<img alt="<li>" src="/icons/ball.red.gif">
<b><font size="5">Or, enter the criteria for sub-selection</font></b>
EOFSEL

echo "<form method="\""POST"\"" action="\""/jg/selopt4${tmp}?${QS}"\"">"

cat <<XXstuffXX
<center>
<input type="text" name="sel" size=50>
<input type="submit" value="Replace criteria">
</center>
</form>
</body>
</html>
XXstuffXX

setenv PATH_INFO $tmp
echo "<h3><a href="\""/jg/otheropt${tmp}?${QS}"\"">Continue</a> using new sub-selections</h3>"
