#!/bin/sh
#$Id: simsys_doc,v 1.6 2020/06/17 19:46:39 marcum Exp $

# Display SimSys Documentation

script_path="`readlink $0`"

if [ "${script_path}" = "" ]; then

	script_path="$0"
fi

doc_path="`dirname ${script_path}`/../doc"

if [ -d ${doc_path} ]; then

	cd ${doc_path}

	doc_path="`pwd`"

	doc_page=${doc_path}/system/index.html

	if [ ! -r ${doc_page} ]; then

		echo "
SimSys main documentation file ${doc_page}
was not found."
		doc_page=
	fi
else
	echo "
SimSys documentation directory ${doc_path} was not found."

	doc_page=
fi

if [ "${doc_page}" = "" ]; then

	echo "
SimSys documentation is not available for the current installation with this
script. Find the location of the SimSys documentation directory then manually
use a browser to open [full path]/doc/system/index.html (this will open the
Simsys main documentation page with links to all available documentation).
"
	exit
fi

if [ "`uname -s`" = "Darwin" ]; then
	if [ -d /Applications/Google\ Chrome.app/ ]; then
		echo "Starting Google Chrome to open ${doc_page}"
		open -a Google\ Chrome file://${doc_page}
	else
		echo "Starting Safari to open ${doc_page}"
		open -a Safari file://${doc_page}
	fi

elif [ "`uname -s`" = "Linux" ]; then
	if [ -x /opt/google/chrome/chrome ]; then
		echo "Starting Google Chrome to open ${doc_page}"
		/opt/google/chrome/chrome file://${doc_page} 2> /dev/null &
	else
		echo "Starting firefox to open ${doc_page}"
		firefox file://${doc_page} 2> /dev/null &
	fi

else
	echo "Unknown system - unable to open ${doc_page}"
fi
