#! /bin/sh
###############################################################################
#																			  #
#				Copyright (C) 1985 - 1993, Alias Research, Inc.				  #
#																			  #
#	  These coded instructions,  statements and  computer programs contain	  #
#	  unpublished information proprietary to Alias Research, Inc.  and are	  #
#	  protected by the Canadian and US Federal copyright law. They may not	  #
#	  be disclosed to third parties  or copied  or duplicated, in whole or	  #
#	  in part,  without the prior written consent of Alias Research,  Inc.	  #
#																			  #
# Unpublished-rights reserved under the Copyright Laws of the United States.  #
#																			  #
###############################################################################
#
#	$Source: /u/bfreeman/src/RCS/onlineDocs.sh,v $
#	$Revision: 6.14 $
#	$Author: bfreeman $
#	$Date: 96/11/21 10:26:12 $
#
###############################################################################
#
#	filename: onlineDocs
#	purpose : to run the online document system
#
#	usage:
#
#	onlineDocs [-h]
#
#	where -h displays a help message and exits.
#
###############################################################################

ALIAS_LOC=${ALIAS_LOCATION-/usr/aw/alias}
# Hyperhelp does not default to :0 so we must set DISPLAY explicitly
DISPLAY=${DISPLAY-':0'} export DISPLAY
HHHOME=$ALIAS_LOC/Help export HHHOME
MACHINE=`uname`
case $MACHINE in
	IRIX|IRIX64)   mt=sgi;;
	AIX)    mt=ibm;;
	esac

HYPER_PROGRAM=$HHHOME/bin/$mt/hyperhelp
HTML_PROGRAM=/usr/sbin/nr

programname=`basename $0`

usage()
{
	/bin/cat << EOF
PURPOSE:   To Run The Online Document System
USAGE:     $programname
FLAGS:     -h - displays this help message.
EOF

	exit 0
}

while getopts h arg
do
	case $arg in
	h)	usage;;
	\?)
		error "invalid option -$arg" ;;
	esac
done

if test ! -d $HHHOME
then
	REPLY=`aliasWarning -b Ok -t "" \
		-s "Online Documentation is not installed." \
		-S "If you wish to use online documentation please" \
		-s "install online help from your distribution CDROM." \
		-S "As the owner of the ALIAS software do:" \
		-s "         cd <mount point of CD-ROM>/Products/Alias3D/doc" \
		-s "         cp -r Help /usr/aw/alias"`
	exit 1
fi

if [ -r $HHHOME/bookshelf.html ]; then

	if [ -x $HTML_PROGRAM ]; then
		$HTML_PROGRAM $HHHOME/bookshelf.html
		echo $HTML_PROGRAM $HHHOME/bookshelf.html
	else
		REPLY=`aliasWarning -b Ok -t Error -s "Online Documents" -S "Can not execute: $HTML_PROGRAM"`
		exit 1
	fi
else 
	
	if [ -x $HYPER_PROGRAM ]; then
		cd $HHHOME
		$HYPER_PROGRAM bookshelf.hlp
		echo $HYPER_PROGRAM $HHHOME/bookshelf.hlp
	else 
		REPLY=`aliasWarning -b Ok -t Error -s "Online Documents" -S "Can not execute: $HYPER_PROGRAM"`
		exit 1
	fi
fi
