#! /bin/sh

IMGDIR=images
HTMLDIR=html
TOC=toc.html
FIRST=a.html
INDEX=index.html
CURRDIR=`pwd`

if test ! -d ${CURRDIR}/${IMGDIR}
	then	
		echo I did not find the directory \"${IMGDIR}\" in the current directory. Exiting ...
		exit 1
fi

if test ! -d ${CURRDIR}/${HTMLDIR}
	then
		mkdir html
fi

cat /dev/null > ${CURRDIR}/${HTMLDIR}/${INDEX}
cat /dev/null > ${CURRDIR}/${HTMLDIR}/${TOC}

echo \<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 3.0//EN\"\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo \<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 3.0//EN\"\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo \<!-- Written by Panagiotis Velissariou \(takis@superior.eng.ohio-state.edu\) --\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo \<!-- Written by Panagiotis Velissariou \(takis@superior.eng.ohio-state.edu\) --\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo \<HTML\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo \<HTML\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo          \<HEAD\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \<HEAD\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo          \<TITLE\>Counter Digits -- Choose and Display\</TITLE\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \<TITLE\>Counter Digits\</TITLE\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo          \</HEAD\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \</HEAD\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo          \<FRAMESET COLS=\"254,*\"\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \<NOFRAMES\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          The browser you are using doesn\'t support frames.  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          Although you can\'t see this page, it\'s really no great loss to you,  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          in which case you can go to the \<A HREF=\"${TOC}\"\>Table of Contents\</A\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \</NOFRAMES\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \<FRAME SRC=\"${TOC}\" NAME=\"TOC\"\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \<FRAME SRC=\"${FIRST}\" NAME=\"CONTENT\"\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \</FRAMESET\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}
echo          \</HTML\>  >> ${CURRDIR}/${HTMLDIR}/${INDEX}

echo          \<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo          \<CENTER\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}
echo          \<H1\>Table of Contents\</H1\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}
echo          \</CENTER\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo  \<HR WIDTH=\"100%\" SIZE=\"8\" NOSHADE\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo           \<UL\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

#
# BEGIN :: GO THROUGH THE IMAGES (*.gif) IN THE IMGDIR/*/ AND CREATE THE HTML FILES
#
cd ${CURRDIR}/${IMGDIR}
for i in *
do
	if test  -d $i
	then
	  cat /dev/null > ${CURRDIR}/${HTMLDIR}/$i.html

	  echo \<LI\>Directory : ${CURRDIR}/${IMGDIR}/\<A HREF=\"$i.html\" NAME=\"$i\" TARGET=\"CONTENT\"\>\<B\>$i\</B\>\</A\> >> ${CURRDIR}/${HTMLDIR}/${TOC}

	  echo \<\!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 3.0//EN\"\>  >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo \<\!-- Written by Panagiotis Velissariou \(takis@superior.eng.ohio-state.edu\) --\>  >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo \<HTML\>  >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo          \<HEAD\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo          \<TITLE\>Counter Digits : display them\!\</TITLE\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo          \</HEAD\>  >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo          \<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"\>  >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo          \<CENTER\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo          \<B\>All Digits in : \</B\>${CURRDIR}/${IMGDIR}/$i  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo          \<BR\>\<BR\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo          \</CENTER\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo \<CENTER\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo \<BR\>\<BR\> >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo \<CENTER\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  cd ${CURRDIR}/${IMGDIR}/$i
	  for j in *.gif
	    do
	      echo \<IMG SRC=\"../images/$i/$j\"\> >> ${CURRDIR}/${HTMLDIR}/$i.html
	    done
	  cd ${CURRDIR}/${IMGDIR}
	  echo \</CENTER\>  >> ${CURRDIR}/${HTMLDIR}/$i.html

	  echo \<HR WIDTH=\"100%\" SIZE=\"2\" NOSHADE\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo Go Back to \<A HREF=\"toc.html#$i\" TARGET=\"TOC\"\>\<B\>INDEX\</B\>\</A\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo          \</BODY\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	  echo \</HTML\>  >> ${CURRDIR}/${HTMLDIR}/$i.html
	fi
done
#
# END :: GO THROUGH THE IMAGES (*.gif) IN THE IMGDIR/*/ AND CREATE THE HTML FILES
#

echo           \</UL\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}
echo  >> ${CURRDIR}/${HTMLDIR}/${TOC}
echo          \</BODY\>  >> ${CURRDIR}/${HTMLDIR}/${TOC}

echo \</HTML\> >> ${CURRDIR}/${HTMLDIR}/${TOC}

exit
