#!/usr/local/bin/perl

#unshift (@INC, "/home/global-language/PERL");

&parse_form_data (*simple_form);
$query = $simple_form{'query'};
$frametype = $simple_form{'frametype'};
$type = $simple_form{'type'};
$search = $simple_form{'search'};
$skel = $simple_form{'skel'};
$ctext = $simple_form{'ctext'};
$format = $simple_form{'format'};

$CAT = "/bin/cat";
$SED = "/bin/sed";
$EGREP = "/bin/egrep";
$ZCAT = "/bin/zcat";
$GZCAT = "/bin/zcat";
$SKEL = "/home/global-language/bin/enhaml";
$TAB = "/home/global-language/bin/tab2html";
$GREEK = "/home/global-language/bin/wwwgreek";
$SGMLGREP = "/home/global-language/bin/sgmlgrep3";
#$CGREP = "/home/global-language/bin/fooctextgrep";
$CGREP = "/home/global-language/bin/ctextgrep";
#$CGREP = "/usr/local/share/bin/cgrep";
$MATCH = "/home/global-language/bin/enhammatch.perl";
$VARP = "/home/global-language/bin/varp";

$enfile = "/home/global-language/HTML/enham2.html";
&printheader ();
#unless ($frametype eq "frames") {
#	&printoedbar ();
#}

if ($frametype eq "frames") {
	$page = "corpusframe";
	$align = "top";
} else {
	$page = "corpus";
	$align = "left";
}
if ( $ARGV[0] eq '-p' ) {
	shift;
	$printit = 1;
} else { $printit = 1; }

if ($frametype eq "frames") {
#	require ("quicksearchframe.pl");
} else {
#	require ("quicksearch.pl");
}

if ($type eq "F1") {
	$filetype = "First Folio";
	$color = "red";
	$enfile = "/home/global-language/HTML/F1.hamlet.html";
}
elsif ($type eq "Q2") {
	$filetype = "Second Quarto";
	$color = "green";
}
elsif ($type eq "F1 Only") {
	$opt = "F1";
	$filetype = "First Folio Only";
	$skel = "yes";
	$color = "red";
}
elsif ($type eq "Q2 Only") {
	$opt = "Q2";
	$filetype = "Second Quarto Only";
	$skel = "yes";
	$color = "green";
}
else {
	$filetype = "Enfolded";
	$color = "blue";
}
#require ("authillus.pl");

if ($search eq "yes") {
		$format = "Exact Spellings";
	$qquery = $query;
	unless ($query =~ /^[0-9]*$/) {
		if ($ctext > 100) {
			$ctext = 100;
		}
	}
	if ($query =~ /^[0-9]*$/) {
		$query =~ s/^/\\b/g;
		$query =~ s/$/\\b/g;
		$format = "Exact Spellings";
	}
	if ($format eq "Variant Spellings") {
		$query = `/home/global-language/bin/varp \"$query\"`;
#		print "<h3>Variant query is: $query</h3>\n";
	} else {
		$query =~ s/ /\.\*/g;
	}
}

if ($search eq "yes" && $skel eq "yes") {
	unless (open(TARGFILE, "$CAT $enfile | $CGREP -$ctext \"$query\" | $MATCH \"$query\" | $SKEL -$opt | $TAB | $EGREP \"<$opt>|<hr>|<li>\" |")) {
		die ("could not open target file\n");
	}
}
elsif ($search eq "yes") {
	unless (open(TARGFILE,  "$CAT $enfile | $CGREP -$ctext \"$query\" | $TAB | $MATCH \"$query\" |")) {
		die ("could not open target file\n");
	}
}
elsif ($skel eq "yes") {
	unless (open(TARGFILE, "$CAT $enfile | $SKEL -$opt | $TAB | $EGREP \"<$opt>\" |")) {
		die ("could not open target file\n");
	}
}
else {
	unless (open(TARGFILE, "$TAB < $enfile |")) {
		die ("could not open target file\n");
	}
}

if ($search eq "yes") {
	$header = "Search for \"$qquery\"";
}
else {
	$header = "Text";
}

print "<title>Enfolded Hamlet: $filetype $header</title>\n";
if ($search eq "yes") {
	&fulltexts();
}
print "<center><h3><i>Enfolded Hamlet</i>: $filetype $header</h3></center>\n";

&printhamlettpage();

if ($search eq "yes") {
print "<ol>\n";
}

while (<TARGFILE>) {
if ($type eq "F1") {
	s/<Q2>/<\!-- $&/g;
	s/<\/Q2>/$& -->/g;
	s/<F1BR>/<br>$&/g;
}
elsif ($type eq "Q2") {
	s/<F1>/<\!-- $&/g;
	s/<\/F1>/$& -->/g;
}
else {
	s/<Q2>/<font color=green>\{/g;
	s/<\/Q2>/\}<\/font>/g;
	s/<F1>/<font color="\#d83487">\&lt;/g;
	s/<\/F1>/\&gt;<\/font>/g;
	s/<F1BR>/<font color="\#d83487">\|<\/font>/g;
}
#s/	/\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;\&nbsp;/;
#if (/^(.*	)/ {
#	$lnum = length($1);
#	s/	/        /;
#	for ($count=1; $count <= ($lnum + 8); $count++) {
#		s/ /\&nbsp;/;
#	}
#}
if (/<text/) {
	$printit = 1;
}
if (/<l.*(> *)/) {
	$tabnum = length($1);
	for ($count=1; $count <= ($tabnum - 1); $count++) {
		s/ /\&nbsp;/;
	}
}
##if (/<pv>GB/) {
##	s/ ([A-Z][a-z]*)<\/dAuthor>/<A href="\/cgi\/author2.getter\?query=$1"> $1<\/A><\/dAuthor>/;
##	}
s/<stage type=["'][a-z]*["']>/\[$&/;
s/<stage type=[a-z]*>/\[$&/;
s/<\/stage>/$&\]/g;
s/<dDate>/<b>$&/g;
s/<\/dDate>/$&<\/b>/g;
s/<quote>/<blockquote>$&/g;
s/<\/quote>/$&<\/blockquote>/g;
s/<tPage>/<center>$&/g;
s/<\/tPage>/$&<\/center>/g;
s/<gloss>/{$&/g;
s/<\/gloss>/$&}/g;
s/<trailer>/[$&/g;
s/<\/trailer>/$&]/g;
s/<spkr>/<i>$&/g;
s/<\/spkr>/$&<\/i>/g;
#s/<sp>/$&<a href="javascript:quickwindow()" onMouseOver="window.status='Open Quick Search Pop-up Form for OED';return true;"><img src=\/images\/tab1.gif border=0 alt=""><\/a>/g;
#s/<p>/$&<a href="javascript:quickwindow()" onMouseOver="window.status='Open Quick Search Pop-up Form for OED';return true;"><img src=\/images\/tab1.gif border=0 alt=""><\/a>/g;
s/<sp>/$&<a href="javascript:quickwindow()" onMouseOver="window.status='Open Quick Search Pop-up Form for OED';return true;"><img src=\/images\/oedtab1.gif border=0 alt=""><\/a>/g;
s/<p>/$&<a href="javascript:quickwindow()" onMouseOver="window.status='Open Quick Search Pop-up Form for OED';return true;"><img src=\/images\/oedtab1.gif border=0 alt=""><\/a>/g;
s/<strong>/$&<a href="javascript:quickwindow()" onMouseOver="window.status='Open Quick Search Pop-up Form for OED';return true;"><img src=\/images\/oedtab1.gif border=0 alt=""><\/a>/g;
s/<ptr target=(N)([0-9\.]*)>/<a href="\#$1$2">$2<\/a>/g;
s/<note place=f id=(N)([0-9\.]*)>/<p><note><a name="$1$2">$2<\/a>/g;
s/\&th;/\&thorn;/g;
s/\&Th;/\&THORN;/g;
s/\&Thorn;/\&THORN;/g;
s/\&ygh;/<img src=\/IPA\/ipa.yGH.gif align=top alt="3">/g;
s/\&Ygh;/<img src=\/IPA\/ipa.YGH.gif align=top alt="3">/g;
s/\&oelig;/<img src=\/IPA\/ipa.oe.gif alt="oe">/g;
s/\&Oelig;/<img src=\/GREEK\/OElig2.gif alt="Oe">/g;
s/\&asper;\&acute;/\&asperacute;/g;
s/\&asper;\&grave;/\&aspergrave;/g;
s/\&lenis;\&acute;/\&lenisacute;/g;
s/\&lenis;\&grave;/\&lenisgrave;/g;
s/\&asper\./<img src=\/greek\/rougr.gif alt="">/g;
s/\&lenis\./<img src=\/greek\/smogr.gif alt="">/g;
s/(a-z)\&grave;/\&$1grave;/g;
s/(a-z)\&acute;/\&$1acute;/g;
s/\&odq;/``/g;
s/\&cdq;/''/g;
s/\&onq;/`/g;
s/\&cnq;/'/g;
s/\&es;/\&nbsp;/g;
s/\&mdash;/\&#45;/g;
s/<su>/<sup>/g;
s/<\/su>/<\/sup>/g;
s/<head>/<h3>/g;
s/<\/head>/<\/h3>/g;
s/^<l/<br>$&/;
s/><pv/> <pv/g;
s/<hr><hr><li>\-<hr>/<img src=\/images\/bluefountainl.gif width=45% height=3 alt=""><img src=\/images\/bluefountainr.gif width=45% height=3 alt=""><br><br><li> <img src=\/eh$color.gif align=middle alt="[EH]">/;
s/<hr><hr><li> \-<hr>/<br><br><img src=\/images\/bluefountainl.gif width=45% height=3 alt=""><img src=\/images\/bluefountainr.gif width=45% height=3 alt=""><br><br><li> <img src=\/eh$color.gif align=middle alt="[EH]">/;
if ( $printit eq "1" ) { print; }
}

close(TARGFILE);

if ($search eq "yes") {
	print "</ol>\n";
	unless ($frametype eq "frames") {
		&newsearch();
	}
}

sub printoedbar
{
($titletext = $enfile) =~ s/\/u\/triggs\/TEXTS\/...\///;
print "<title>OED Historical Corpus - %s</title>\n", $titletext;
print "<center>\n";
print "<a href=\"/cgi/openbin/imagemap/oetcbar6.map\"><IMG ALIGN=center SRC=/tricolorbar1.gif ismap border=1 alt=\"Home Page\"></a>\n";
print "<br>\n";
print "<img width=418 height=2 src=/images/oupline.gif alt=\"\">\n";
print "<br>\n";
print "</font>\n";
print "<br>\n";
print "</center>\n";
}

sub printheader
{
print "Content-type: text/html\n\n";
if ($type eq "F1") {
	print "<body bgcolor=\"#ffffff\" text=\"#d83487\" vlink=\"blue\">\n";
}
elsif ($type eq "Q2") {
	print "<body bgcolor=\"#ffffff\" text=\"green\" vlink=\"blue\">\n";
}
else {
	print "<body bgcolor=\"#ffffff\" text=\"#0000aa\" vlink=\"blue\">\n";
}
print "<basefont size=\"4\">\n";
}

sub parse_form_data
{

local (*FORM_DATA) = @_;
local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value);

$request_method = $ENV{'REQUEST_METHOD'};

if ($request_method eq "GET") {
	$query_string = $ENV{'QUERY_STRING'};
} elsif ($request_method eq "POST") {
	read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
} else {
	print "Unknown method\n";
	exit (1);
}

@key_value_pairs = split (/&/, $query_string);

foreach $key_value (@key_value_pairs) {
	($key, $value) = split (/=/, $key_value);
	$value =~ tr/+/ /;
	$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
	if (defined($FORM_DATA{$key})) {
		$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
	} else {
		$FORM_DATA{$key} = $value;
	}
   }

}
sub authillus
{
$page="corpus";
$align="left";

if ($enfile =~ /^.*Austen..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/austen.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Bronte.J.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/cbronte.gif border=3></a>";
}
elsif ($enfile =~ /^.*Cather..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/cather.gif border=3></a>";
}
elsif ($enfile =~ /^.*Chaucer..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/chaucer.gif border=3></a>";
}
elsif ($enfile =~ /^.*\/ColWork.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/coleridge.gif border=3></a>";
}
elsif ($enfile =~ /^.*\/Coleridge..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/coleridge.gif border=3></a>";
}
elsif ($enfile =~ /^.*Cooper..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/cooper.gif border=3></a>";
}
elsif ($enfile =~ /^.*Crane..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/crane.gif border=3></a>";
}
elsif ($enfile =~ /^.*Crevecoeur..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/creve.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Darwin..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/darwin.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Dickens.C.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/dickens.gif border=3></a>";
}
elsif ($enfile =~ /^.*Dickens.[G-Z].*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/dickens.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Donne..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/donne.gif border=3></a>";
}
elsif ($enfile =~ /^.*Doy.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/doyle.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Douglass..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/f.douglas.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Dou[A-R].*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/f.douglas.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Eliot.Prufrock.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/tseliot.gif border=3></a>";
}
elsif ($enfile =~ /^.*Eliot.Poems.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/tseliot.gif border=3></a>";
}
elsif ($enfile =~ /^.*Eliot..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/geliot.gif border=3></a>";
}
elsif ($enfile =~ /^.*Emerson..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/emerson.gif border=3></a>";
}
elsif ($enfile =~ /^.*Fra[A-Z2].*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/franklin.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Franklin..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/franklin.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Frost.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/frost.gif border=3></a>";
}
elsif ($enfile =~ /^.*FroPoem.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/frost.gif border=3></a>";
}
elsif ($enfile =~ /^.*Godwin..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/godwin.gif border=3></a>";
}
elsif ($enfile =~ /^.*Hardy..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/hardy.gif border=3></a>";
}
elsif ($enfile =~ /^.*Hawthorne..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/hawthorne.gif border=3></a>";
}
elsif ($enfile =~ /^.*Irving..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/irving.jpg border=3></a>";
}
elsif ($enfile =~ /^.*James..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/james.gif border=3></a>";
}
elsif ($enfile =~ /^.*.Jam.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/james.gif border=3></a>";
}
elsif ($enfile =~ /^.*Jefferson..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/jefferson.gif border=3></a>";
}
elsif ($enfile =~ /^.*Jonson..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/jonson.gif border=3></a>";
}
elsif ($enfile =~ /^.*Kip.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/kipling.jpg border=3></a>";
}
elsif ($enfile =~ /^.*\/London..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/london.gif border=3></a>";
}
elsif ($enfile =~ /^.*Melville..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/melville.gif border=3></a>";
}
elsif ($enfile =~ /^.*Milton.A.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/milton.gif border=3></a>";
}
elsif ($enfile =~ /^.*Milton.P.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/milton.gif border=3></a>";
}
elsif ($enfile =~ /^.*Milton.S.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/milton.gif border=3></a>";
}
elsif ($enfile =~ /^.*Milton.Th.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/milton.gif border=3></a>";
}
elsif ($enfile =~ /^.*Mil67PL.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/milton.gif border=3></a>";
}
elsif ($enfile =~ /^.*\/Poe.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/poe.gif border=3></a>";
}
elsif ($enfile =~ /^.*Scott.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/scott.jpg border=3></a>";
}
elsif ($enfile =~ /^.*ScoCasD*.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/scott.jpg border=3></a>";
}
elsif ($enfile =~ /^.*ScoPoem.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/scott.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Shakespeare.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/shake.gif border=3></a>";
}
elsif ($enfile =~ /^.1609Son.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/shake.gif border=3></a>";
}
elsif ($enfile =~ /^.*Q..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/shake.gif border=3></a>";
}
elsif ($enfile =~ /^.*Shaw..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/shaw.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Stevenson..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/stevenson.gif border=3></a>";
}
elsif ($enfile =~ /^.*Stowe..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/stowe.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Thoreau..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/thoreau.gif border=3></a>";
}
elsif ($enfile =~ /^.*Trollope..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/trollope.gif border=3></a>";
}
elsif ($enfile =~ /^.*Twain..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/twain.gif border=3></a>";
}
elsif ($enfile =~ /^.*TwaMiss..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/twain.gif border=3></a>";
}
elsif ($enfile =~ /^.*Wells..*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wells.gif border=3></a>";
}
elsif ($enfile =~ /^.*Wollstonecraft.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wollstonecraft.gif border=3></a>";
}
elsif ($enfile =~ /^.*WolM.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wollstonecraft.gif border=3></a>";
}
elsif ($enfile =~ /^.*Woolf.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/woolf.gif border=3></a>";
}
elsif ($enfile =~ /^.*Woo[D-IK-Z].*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/woolf.gif border=3></a>";
}
elsif ($enfile =~ /^.*Wordsworth.Coleridge.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/coleridge.gif border=3> <IMG SRC=/AUTHORS/wordsworth.gif border=3></a>";
}
#if ($enfile =~ /^.*\/Wordsworth..*$/) {
#	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wordsworth.jpg border=3></a>";
#}
elsif ($enfile =~ /^.*Wordsworth.Excursion.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wordsworth.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Wordsworth.Prelude.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wordsworth.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Wordsworth.Immortality.*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/wordsworth.jpg border=3></a>";
}
elsif ($enfile =~ /^.*Yea[E,P].*$/) {
	print "<a href=/$page.html><IMG align=$align hspace=15 SRC=/AUTHORS/yeats.gif border=3></a>";
}
}
sub printhamlettpage
{
print "<center>\n";
print "<img src=/images/bluefountainl.gif width=45% height=3 alt=\"\"><img src=/images/bluefountainr.gif width=45% height=3 alt=\"\">\n";
print "</center>\n";
print "<br>\n";
print "<center>\n";
if ($frametype eq "frames") {
	print "<a href=/cgi/openbin/enhamp?type=EN onMouseOver=\"window.status='Full Enfolded Hamlet Text';return true;\"><img align=left src=/shakespeare.small.gif border=0 alt=\"Enfolded Hamlet Page\"></a>\n";
#	print "<a href=enfolded.html onMouseOver=\"window.status='Return to the Enfolded Hamlet Page';return true;\" target=_top><img align=left src=/AUTHORS/shake.gif border=2 alt=\"Enfolded Hamlet Page\"></a>\n";
#	print "<a href=/cgi/openbin/enhamp?type=EN onMouseOver=\"window.status='Full Enfolded Hamlet Text';return true;\"><img align=left src=/AUTHORS/shake.gif border=2 alt=\"Enfolded Hamlet Page\"></a>\n";
} else {
#	print "<img align=left src=Millais.Ophelia.gif border=0 alt=\"\">\n";
	print "<img align=left src=/shakespeare.small.gif border=0 alt=\"\">\n";
#	print "<img align=left src=/AUTHORS/shake.gif border=2 alt=\"\">\n";
}
print "<h1>The Tragedie of<br> H A M L E T</h1>\n";
print "<h2><i>Prince of Denmarke.</i></h2>\n";
@otypes = ('Enfolded','F1','F1 Only','Q2','Q2 Only');
print "<form ACTION=\"/cgi/openbin/enhamp\">\n";
print "<input type=\"hidden\" name=\"search\" value=\"$search\">\n";
print "<input type=\"hidden\" name=\"query\" value=\"$qquery\">\n";
print "<input type=\"hidden\" name=\"frametype\" value=\"$frametype\">\n";
print "<input type=\"hidden\" name=\"format\" value=\"$format\">\n";
print "<table><tr><th>";
if ($search eq "yes") {
	print "Context: <input  name=\"ctext\" value=\"$ctext\" size=5>\n";
}
print "<select name=\"type\" onchange=\"submit()\">\n";
foreach $otype (@otypes) {
	if ($otype eq $type) {
		print "<option selected>$otype\n";
	} else {
		print "<option>$otype\n";
	}
}
print "</select>\n";
print "</th></tr></table>";

print "</form>\n";
print "</center>\n";
print "<br clear=all>\n";
}

sub newsearch
{
@otypes = ('Enfolded','F1','F1 Only','Q2','Q2 Only');
print "<hr><form ACTION=\"/cgi/openbin/enhamp\">\n";
print "Enter a word, phrase, or through-line number:<br> <input name=\"query\" size=40>\n";
print "<input type=\"submit\" value=\"Search\"><input type=\"reset\" value=\"Clear\">\n";
print "<input type=\"hidden\" name=\"search\" value=\"yes\">\n";
print "<br>Surrounding lines of context: <input  name=\"ctext\" value=\"$ctext\" size=5>\n";
print "Text display type:\n";
print "<select name=\"type\" onchange=\"submit()\">\n";
foreach $otype (@otypes) {
	if ($otype eq $type) {
		print "<option selected>$otype\n";
	} else {
		print "<option>$otype\n";
	}
}
print "</select>\n";
if ($format eq "Variant Spellings") {
	print "\n<select name=\"format\">\n<option>Exact Spellings\n<option selected>Variant Spellings\n</select>\n";
} else {
	print "\n<select name=\"format\">\n<option selected>Exact Spellings\n<option>Variant Spellings\n</select>\n";
}

print "</form>\n";
}

sub fulltexts
{
print "<center>\n";
print "<table colspan=3 width=100% cellspacing=3 border=0>\n";
print "<tr>\n";
print "<th colspan=1><a href=\"/cgi/openbin/enhamp?type=Q2\" onMouseOver=\"window.status='Open the Full Text in Q2 Only Form';return true;\" target=textwindow>Q2</a></th>\n";
print "<th colspan=1><a href=\"/cgi/openbin/enhamp?type=EN\" onMouseOver=\"window.status='Open the Full Text in Enfolded Form';return true;\" target=textwindow>Enfolded</a></th>\n";
print "<th colspan=1><a href=\"/cgi/openbin/enhamp?type=F1\" onMouseOver=\"window.status='Open the Full Text in F1 Only Form';return true;\" target=textwindow>F1</a></th>\n";
print "</tr>\n";
print "</table>\n";
print "</center>\n";
print "<center>\n";
print "<img src=/images/bluefountainl.gif width=45% height=3 alt=\"\"><img src=/images/bluefountainr.gif width=45% height=3 alt=\"\">\n";
print "</center>\n";
#print "<hr>\n";
}
