#!/bin/csh -f

#
# first argument is a URL, second argument is process ID 
# (process ID of -1 means that a new process is needed)
# 

set noglob = 1

#echo "in WWW script"
#echo "  URL is $1"
#echo "  geometry is $2"
#echo "  pid is $3"
#echo "WEBBROWSER" $WEBBROWSER

if ($?WEBBROWSER) then
    if ($WEBBROWSER == xmosaic) then
    which xmosaic >& /dev/null
    if ($status == 0) then
        if ($3 != -1) then
	    # there's already a xmosaic process running, so do
   	    # the signal protocol
	    cat > /tmp/Mosaic.$3 << EOF
goto
$1
EOF
	    kill -USR1 $3
        else
	    # there's no xmosaic running, so go ahead and start one
	    exec xmosaic $1
        endif		
        exit
    endif
    endif	
endif

which netscape >& /dev/null
if ($status == 0) then
    # first, try the remote control thing

    netscape -remote openURL\($1\) >& /dev/null 

    # if it didn't work, then you're either running an old
    # version of netscape that doesn't support the -remote
    # command, or there's no netscape process running
    if ($status != 0) then
        if ($2 == NONE) then
	    exec netscape $1 
	else
	    exec netscape $1 -geometry $2
	endif
    endif
else
   # can't find netscape 
   exit -1
endif

