chapter=1
function mkPages {
	cat >> toc.html <<TOC1
$subDir = add0("$chapter: $subDir")
addLeaves(
	$subDir,"$subDir",
TOC1
	cnt=0
	let "lastIndex = ${#titles[*]} - 1"
	while [[ $cnt -le $lastIndex ]]
	do
		title=${titles[$cnt]}
		if [[ $cnt > 0 ]]
		then
			let "prevIndex = $cnt-1"
			prev=\"${titles[$prevIndex]}.html\"
		else
			prev=$prevDir
			if [[ $prev != null ]]
			then
				prev=\"$prev.html\"
			fi
			
		fi
		if [[ $cnt -lt $lastIndex ]]
		then
			let "nextIndex = $cnt+1"
			next=\"${titles[$nextIndex]}.html\"
			comma=","
		else
			next=$nextDir
			if [[ $next != null ]]
			then
				next=\"$next.html\"
			fi
			comma=''
		fi
			
		let "pagenr=$cnt+1"
		if [[ $subDir != globals ]]
		then
			headerSubDir=$subDir.
		else
			headerSubDir=""
		fi
		header=$title
		isProperty=false
		for i in ${properties[*]}
		do
			if [[ $i == $title ]]
			then
				isProperty=true
			fi
		done
		if [[ $isProperty != true ]]
		then
			header="$header()"
		fi
				
		tocHeader=$header
		if [[ $title == Constructor ]]
		then
			header="new $subDir()"
			headerSubDir=""
			tocHeader="Constructor()"
		fi
		if [ -e $subDir/$title.html ]
		then
			cat $subDir/$title.html | sed 1,4d > tmpfile
		fi
		cat > $subDir/$title.html<<EOF
<script src="../../page.js"></script>
<body>
<script>mkPage("$chapter.$pagenr",$prev,$next)</script>
<h2><center>$headerSubDir$header</center></h2>
EOF

		if [ -e tmpfile ]
		then
			cat tmpfile >> $subDir/$title.html
			rm tmpfile
		fi

		cat >> toc.html <<TOC2
	"$title.html","$pagenr: $tocHeader"$comma
TOC2

		let "cnt += 1"
	done
	cat >>toc.html <<TOC3
)
TOC3
	let "chapter += 1"
}

cat > toc.html <<TOC0
<script src="../toc.js"></script>
<body>
<script>
TOC0

subDir=button
prevDir=null
nextDir=../globals/domain
titles=("Constructor")
mkPages

subDir=globals
prevDir=../button/Constructor
nextDir=../helpFrame/Constructor
titles=("domain" "getScreenHeight" "getScreenWidth" "WinList")
properties=("domain" "WinList")
mkPages

subDir=helpFrame
prevDir=../globals/WinList
nextDir=../menu/Constructor
titles=("Constructor" "addPage" "maxmin" "nextPage" "prevPage"  \
		"showPage" "visible"  \
)
mkPages

subDir=menu
prevDir=../helpFrame/visible
nextDir=../serverFrame/Constructor
titles=("Constructor" "addButton" "hide" "realSticky" \
		"showAt" "sticky" "stickyButtons"  \
		"toggleButtons" "vertical" \
)
mkPages

subDir=serverFrame
prevDir=../menu/vertical
nextDir=../slider/Constructor
titles=( "Constructor" "contentWindow" "flush"   \
		"getVar" "getVars" "removeVar" "scheduleAfter" "setExecOnReturn"  \
		"setServerURL" "setTarget" "setVar" "submit" "win" \
)
properties=("contentWindow" "win")
mkPages

subDir=slider
prevDir=../serverFrame/win
nextDir=../win/Constructor
titles=("Constructor" "getValue" "setMoveFunc" \
	"setStopFunc"  "setTitle" "setValue" "showAt" "vertical" "visible" \
)
mkPages

subDir=win
prevDir=../slider/visible
nextDir=null
titles=("Constructor" "addServerFrame" "contentHeight" \
		"contentLeft" "contentTop" "contentWidth" "contentWindow" \
		"deIconify" "getReturnedVar" "hideLed" "iconify" \
		"maxmin" "removeVar" "serverFrames" "setExecAfterAllReturn" \
		"setExecBeforeSubmit" "setExecOnResize" \
		"setExecOnReturn" "setPosition" "setTitle" "setVar" \
		"setServerURL" "showLed" "submit"
)
properties=("contentHeight" "contentLeft" "contentTop" "contentWidth" \
			"contentWindow" "serverFrames" 
)
mkPages

cat >> toc.html <<TOC4
document.getElementsByTagName("a")[0].style.color = "red"
</script>
TOC4
