package visual;

require Exporter;
@ISA    = (Exporter);
@EXPORT = qw( page html htmlstr ) ;

sub page {
	my ($bod,$title,$subtitle) =@_;
	print <<".";
<HTML>
<HEAD>
<title> $title </title>
</HEAD>
<BODY>
<CENTER>
<H1> $title</h1>
<H2> $subtitle</h2>
</CENTER>
<HR SIZE=4>
.

        html($bod);
        print "\n</BODY>\n</html>\n";


}

sub html {
	my $a = shift;
	if (!ref($a)) {
		print "$a\n";
	}
	elsif (ref($a) eq "ARRAY") {
           if (@$a) {
		print "<ul>\n";
		for(@$a) {
			print "\t<li>";
			html($_);
		}
		print "</ul>\n";
           }
	}
	elsif (ref($a) eq "HASH") {
		print "<DL>\n";
		for(keys %$a) {
			print "\t<DT>$_\n";
			print "\t<DD>";
			html ($a->{$_});
		}
		print "</DL>";
	}
	else {
		print "$a ?? \n";
	}
}
sub htmlstr {
	my $a = shift;
        my $c = "";
	if (!ref($a)) {
		$c .= "$a\n";
	}
	elsif (ref($a) eq "ARRAY") {
           if (@$a) {
 		$c .= "<ul>\n";
		for(@$a) {
			$c .= "\t<li>";
             	        $c .=	htmlstr($_);
		}
		$c .= "</ul>\n" ;
           }
	}
	elsif (ref($a) eq "HASH") {
		$c .= "<DL>\n";
		for(keys %$a) {
			$c .= "\t<DT>$_\n";
			$c .= "\t<DD>";
	                $c .=	htmlstr ($a->{$_});
		}
		$c .= "</DL>";
	}
	else {
		$c .= "$a ?? \n";
	}
        $c;
}
1;
