#!/bin/ksh
#
#ident	"@(#)help.eng	1.17	04/12/08 SMI"
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#


# variables
hctsdir=SUNWhcts		# base directory
hname=$1			# test system
mname=$2			# menu name
technology=$3
prgdir=prgs			# program directory
act=				# action to be taken
gotocgi="http://$HTTP_HOST/cgi-bin/$hctsdir/$hdir/`basename $0`"	# program name
i=0				# loop counter

lvfile=/tmp/level.dat
stfile=/tmp/suite.dat

if [ -s $stfile ]
then
    suite=`cat $stfile`
fi

if [ -s $lvfile ]
then
    level=`cat $lvfile`
fi

hdir=help		# help directory

# detect the browser type
browser=`echo $HTTP_USER_AGENT | grep -i "Mozilla/4"`
if [ -n "$browser" ]
then
    browser="netscape4"
else
    browser="mozilla"
fi

# functions

# do function
go_fun()
{
	$prgdir/funcs "$*" 2>&1
}


### MAIN ###

# change to base directory
cd `dirname $0`
while [ `basename $PWD` != $hctsdir ]
do
	cd ..
done

# parse input 
if [ -n "$CONTENT_LENGTH" ]
then
	eval `$prgdir/pq.p`
	CONTENT_LENGTH=
fi

# display help

if [ -n "$suite" ]
then
	hdir=$hdir/$suite
fi

if [ -n "$level" ]
then
	hdir=$hdir/$level
fi

if [ $technology = "storage" ]
then
	hdir=$hdir/str
elif [ $technology = "network" ]
then
	hdir=$hdir/net

elif [ $technology = "serial" ]
then
        hdir=$hdir/ser
elif [ $technology = "system" ] #add for motherboard certification 
then
        hdir=$hdir/sys
elif [ $technology = "motherboard" ] #add for motherboard certification 
then
        hdir=$hdir/mb
fi

# help menu for start and home

if [ $mname = "home" ]
then
	hdir=help/$suite
elif [ $mname = "start" ]
then
	hdir=help
fi

# Fix 5007723 by Matthew, guess if no help help/$suite/$level/$technology/$mname.hlp exist
if [ ! -f $hdir/$mname.hlp ]
then
	hdir=help/$suite/$level
	if [ ! -f $hdir/$mname.hlp ]
	then
		hdir=help/$suite
		if [ ! -f $hdir/$mname.hlp ]
		then
			hdir=help
		fi
	fi
fi

go_fun bhtml $hname "help"

echo '<DIV ALIGN="RIGHT"><A HREF="'http://$HTTP_HOST/cgi-bin/$hctsdir/$prgdir/about?$hname'">About</A></DIV>'
echo '<CENTER><FONT SIZE="+2">Help Screen</FONT></CENTER>'
if [ -s $hdir/$mname.hlp ]
then
    cat $hdir/$mname.hlp
fi

go_fun ehtml

