#!/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>"
	exit 1
endif

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

if ( `uname` == Linux || `uname` == SunOS ) then
	set CONFIRM="xmessage -center"
else
	set CONFIRM="confirm -t"
endif

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

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

if ( ! -d "$doc_dir" ) then
    $CONFIRM "You do not have the Side Effects Software documentation installed in ${doc_dir}. On-line help is not available."
    exit 1
endif

set base_app = $1:r

switch ( $base_app )
    case "install":
    case "GettingStarted":
    case "Installation":
	set help_file = "${doc_dir}/Installation.fmk.pdf"
	breaksw
  
    case "houdini":
    case "hmaster":
    case "hselect":
    case "hescape":
    case "hhalo":
    case "Houdini":
    case "Interface":
	set help_file = "${doc_dir}/Interface.fmk.pdf"
	breaksw

    case "Objects":
    case "objecteditor":
    case "ObjectEditor":
	set help_file = "${doc_dir}/Objects.fmk.pdf"
	breaksw

    case "hselect":
    case "SOPs":
    case "sopeditor":
    case "SopEditor":
    case "EditingGeometry":
    case "Geometry":
    case "model":
    case "model":
    case "modeler":
    case "ModelEditor":
	set help_file = "${doc_dir}/Geometry.fmk.pdf"
	breaksw

    case "CHOPs":
    case "Channels":
    case "chopnet":
    case "ChopNet":
    case "ChopNetEditor":
    case "chopeditor":
    case "chopEditor":
	set help_file = "${doc_dir}/Channels.fmk.pdf"
	breaksw

    case "POPs":
    case "Particles":
    case "popnet":
    case "PopNet":
    case "PopNetEditor":
    case "popeditor":
    case "PopEditor":
	set help_file = "${doc_dir}/Particles.fmk.pdf"
	breaksw

    case "VOPs":
    case "VexOps":
    case "vexbuilder":
    case "VexBuilder":
	set help_file = "${doc_dir}/VexBuilder.fmk.pdf"
	breaksw

    case "SHOPs":
    case "ShaderOps":
    case "Shaders":
	set help_file = "${doc_dir}/Shaders.fmk.pdf"
	breaksw

    case "hescape":
    case "dopesheet":
    case "DopeSheet":
    case "animation":
    case "Animation":
    case "AnimationEditor":
    case "channeleditor":
    case "ChannelEditor":
	set help_file = "${doc_dir}/Animation.fmk.pdf"
	breaksw

    case "Rendering":
    case "Outputs":
    case "outputlist":
    case "OutputList":
	set help_file = "${doc_dir}/Outputs.fmk.pdf"
	breaksw

    case "mantra":
	set help_file = "${doc_dir}/Outputs.fmk.pdf"
	breaksw

    case "mdisplay":
	set help_file = "${doc_dir}/Outputs.fmk.pdf"
	breaksw

    case "hhalo":
    case "COPs":
    case "Compositing":
    case "complist":
    case "CompList":
    case "CompListEditor":
    case "copeditor":
    case "CopEditor":
	set help_file = "${doc_dir}/Compositing.fmk.pdf"
	breaksw

    case "ExpressionLang":
    case "ExpressionLanguages":
    case "expressionLanguages":
	set help_file = "${doc_dir}/ExpressionLang.fmk.pdf"
	breaksw

    case "hscript":
    case "Scripting":
    case "scripting":
	set help_file = "${doc_dir}/Scripting.fmk.pdf"
	breaksw

    case "GeometryTypes":
    case "geometryTypes":
	set help_file = "${doc_dir}/GeometryTypes.fmk.pdf"
	breaksw


    case "formats":
    case "Formats":
	set help_file = "${doc_dir}/Formats.fmk.pdf"
	breaksw

    case "spy":
    case "Spy":
	set help_file = "${doc_dir}/spy.fmk.pdf"
	breaksw
        
    case "iblur":
    case "ibulge":
    case "ibumpmap":
    case "icineon":
    case "iclear":
    case "icomposite":
    case "icp":
    case "icurve":
    case "idof":
    case "iexabyte":
    case "ifilter":
    case "iflip":
    case "iflop":
    case "ifractal":
    case "ihot":
    case "info":
    case "ijpeg":
    case "ijpeg2":
    case "ilookup":
    case "inewtoold":
    case "ipaint":
    case "iplay":
    case "iprint":
    case "iquantize":
    case "iramp":
    case "iscroll":
    case "ishear":
    case "isi":
    case "isixpack":
    case "istipple":
    case "itim":
    case "izmatte":
    case "redit":
    case "rmands":
    case "mplay":
    case "StandAlone":
	set help_file = "${doc_dir}/StandAlone.fmk.pdf"
	breaksw

    case "tutorial":
    case "Tutorial":
    case "TutorialGuide":
    case "userguide":
    case "UserGuide":
	set help_file = "${doc_dir}/TutorialGuide.fmk.pdf"
	breaksw

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

    case "helpcard":
    case "HelpCard":
	set help_file = "${doc_dir}/HelpCard.pdf"
	breaksw

    default:
	if ( -f ${doc_dir}/${base_app}.pdf ) then
	    set help_file = ${doc_dir}/${base_app}.pdf
	else
	    $CONFIRM "Help for $base_app is not available." &
	    exit 1
	endif
endsw

exec acroread $help_file &
