#!/usr/bin/sh
. /etc/profile.d/msm.sh
if [ "${2}" == "" ]; then
  DOCLANG="$(echo ${LANG})"
  echo ${DOCLANG}
  EXTDIR="$(echo $DOCLANG | awk '{print substr($1,1,2)}')"
  if [ "$EXTDIR" = "zh" ]; then
    EXTDIR="$(echo ${DOCLANG} | awk '{print substr($1,1,5)}')"
    EXTDIR="$(echo ${EXTDIR} | sed 's/_/-/g')"
  fi
  if [ -d "${MSM_HOME}/docs/${EXTDIR}" ]; then
    DOCDIR="${MSM_HOME}/docs/${EXTDIR}"
  else
    DOCDIR="${MSM_HOME}/docs"
  fi
  PARAM="msmHELP.htm"
else
  DOCDIR="${MSM_HOME}/${1}"
  PARAM="${2}"
fi
CHECK="$(which xdg-open)"
if [ "${CHECK}" = "" ]; then
  echo "xdg-open not present"
else
  xdg-open "file:///${DOCDIR}/${PARAM}"
  exit
fi

echo "Support Browser are not installed on this system. Please install xdg-open to launch help"
