#!/bin/csh -f
#
# This is the script that finds on-line help files and fires up the
# appropriate help reader.
#

if ( $#argv != 1 ) then
	echo "Usage: $0 <application>"
	echo "<application> can be one of:"
	echo "	sage"
	echo "	modeler"
	echo "	action"
	echo "	actionkeyboard"
	echo "	imagetoolkit"
	echo "	spy"
	echo "	jive"
	echo "	lava"
	echo "	ice"
	echo "	mojo"
	echo "	moca"
	echo "	rendering"
	echo "	glossary"
	echo "	relnotes6.0"
	echo "	relnotes6.0.2"
	echo "	relnotes6.1"
	echo "	relnotes6.3"
	echo "	relnotes6.3a"
	echo "	relnotes6.4"
	exit 1
endif

set doc_dir = ${PRISMSROOT}/document/pdf
set searchpath=`echo "$path" | sed 's/:/ /g'`
set found = 0

foreach dir ( $searchpath ) 
	if ( ! -d $dir ) continue;
	if ( -f $dir/acroread ) then
		set found = 1
		break
	endif
end

if ( $found == 0 ) then
    confirm -t "You do not have the Adobe Acrobat documentation reader installed." \
	    -t "Please refer to your release notes for installation details."
    exit 1
endif

if ( ! -d "$doc_dir" ) then
    confirm -t "You do not have the Side Effects on-line documentation installed in"  -t "${doc_dir}. Help is not available."
    exit 1
endif

set base_app = $1:r

switch ( $base_app )
    case "sage":
    case "sage1":
    case "model":
    case "modeler":
    case "modeler1":
    case "modeller":
	set help_file = "${doc_dir}/sage6.pdf"
	breaksw

    case "action":
    case "acting":
	set help_file = "${doc_dir}/action6.pdf"
	breaksw

    case "actionkeyboard":
    case "actionKeyboard":
    case "ActionKeyboard":
	set help_file = "${doc_dir}/actionKeyboard6.pdf"
	breaksw

    case "imagetoolkit":
    case "ImageToolkit":
	set help_file = "${doc_dir}/ImageToolkit6.pdf"
	breaksw

    case "spy":
    case "spy1":
	set help_file = "${doc_dir}/spy6.pdf"
	breaksw

    case "jive":
	set help_file = "${doc_dir}/jive6.pdf"
	breaksw

    case "lava":
    case "lava2":
	set help_file = "${doc_dir}/lava6.pdf"
	breaksw

    case "ice":
    case "ice3":
	set help_file = "${doc_dir}/ice6.pdf"
	breaksw

    case "mojo":
	set help_file = "${doc_dir}/mojo6.pdf"
	breaksw

    case "moca":
    case "MotionCapture":
	set help_file = "${doc_dir}/MotionCapture6.pdf"
	breaksw

    case "rendering":
    case "Rendering":
    case "RenderingManual":
	set help_file = "${doc_dir}/RenderingManual6.pdf"
	breaksw

    case "glossary":
    case "Glossary":
	set help_file = "${doc_dir}/Glossary6.pdf"
	breaksw

    case "relnotes6":
    case "relnotes6.0":
	switch ( $1 )
	    case "relnotes6":
	    case "relnotes6.0":
	    case "Relnotes6.0":
		set help_file = "${doc_dir}/Appendices6.pdf"
		breaksw

	    case "relnotes6.1":
	    case "Relnotes6.1":
		set help_file = "${doc_dir}/Appendices6.1.pdf"
		breaksw

	    case "relnotes6.3":
	    case "Relnotes6.3":
		set help_file = "${doc_dir}/RelNotePrisms6.3.pdf"
		breaksw

	    case "relnotes6.3a":
	    case "Relnotes6.3a":
		set help_file = "${doc_dir}/RelNotePrisms6.3a.fmk.pdf"
		breaksw

	    case "relnotes6.4":
	    case "Relnotes6.4":
		set help_file = "${doc_dir}/RelNotePrisms6.4.pdf"
		breaksw

	    default:
		set help_file = "${doc_dir}/Appendices6.0.2.pdf"
		breaksw
	endsw
	breaksw

    case "appendix":
    case "Appendix":
    case "appendices":
    case "Appendices":
	set help_file = "${doc_dir}/Appendices6.0.2.pdf"
	breaksw

    default:
	if ( -f ${doc_dir}/${base_app}.pdf ) then
	    set help_file = ${doc_dir}/${base_app}.pdf
	else
	    confirm -t "Help for $base_app is not available." \
	    -t "" \
	    -t "Subjects: sage, modeler, action, actionkeyboard, imagetoolkit," \
	    -t " spy, jive, lava, ice, mojo, moca, rendering, glossary, appendices"
	    exit 1
	endif
endsw

exec acroread $help_file
