#!/bin/ksh

for d in audio-gear computer-parts electronics lab-equipment manuals misc photography sf-books text-books; do
	(
		cd $d || continue
		grep href= index.html |
		sed 's/[^"]*"\([^"]*\)">\([^<]*\).*/\1 \2/' |
		while read f t; do
			if [ -f $f ]; then
				continue
			fi
			echo $d/$f
			i=${f%.*}
			s=$( ls -1 ${i}*.jpg |
				sed 's/\(.*\)/  <br><img src="\1">/'
			)
			cat > $f <<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>$t</title>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META http-equiv="Content-Language" content="en-US">
</head>
<body
  BGCOLOR="#FFFFFF"
  TEXT="#000000"
  LINK="#0000FF"
  VLINK="#000080"
  ALINK="#FF0000">
<h1 align=center>$t</h1>
<p>

$s

<br><a href="mailto:forsale@workingcode.com?subject=$i%20Question">Ask a question about this item.</a>
<br><a href="mailto:forsale@workingcode.com?subject=$i%20Offer">Make an offer on this item.</a>

</p>
</body>
</html>
EOF
		done
		rm -f ll
	)
done
