sub html_header {
  my $datetitle = shift;
  print
    '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', "\n",
    "<html>\n",
    "<head>\n",
    "<title>Firewall activity", ($datetitle ? " for $datetitle" : ""), "</title>\n";
  if (-f $opt{"basedir"} . "themes/" . $theme . "/theme.css") {
    print
      '<style type="text/css">', "\n",
      "<!--\n";
    open CSS, $opt{"basedir"} . "themes/" . $theme . "/theme.css" or die "ERROR: Unable to open theme style sheet.\n";
    while (<CSS>) { print; }
    close CSS;
    print
      "-->\n",
      "</style>\n";
  }
  print
    '<meta name="description" content="Firewall activity', ($datetitle ? " for $datetitle" : ""), '">', "\n",
    '<meta name="keywords" content="reptor raptor firewall ', $datetitle, '">', "\n",
    "</head>\n",
    "<body>\n",
    "<h3>", $title, ($datetitle ? "<br />$datetitle" : ""), "</h3>\n";
}

sub html_footer {
  print
    '<p class="credit">',
    'Generated by <a href="http://www.wankwood.com/reptor/" target="_blank">Reptor</a> version ', $reptor_version,
    "</p>\n",
    "</body>\n",
    "</html>\n";
}

sub html_link_pre {
  print '<p class="link"><a name="', shift, '"></a>', "\n";
}

sub html_link {
  my $text = shift;
  my $target = $text;
  $target =~ tr/A-Z/a-z/;
  $target =~ tr/ /_/;
  print '[<a href="#', $target, '">', $text, '</a>] ';
  return;
}

sub html_link_post {
  print "</p>\n";
}

sub begin_table {
  print
    $links ? "<p></p>\n" : "<br />\n",
    '<table border="0" cellpadding="2" cellspacing="2">', "\n";
  $toggle = 0;
}

sub end_table {
  print "</table><br />\n";
}

sub begin_row {
  my $type = shift;
  $cell_type = $type;
  print "<tr>\n";
  if ($cell_type eq "title" || $cell_type eq "header") {
    $toggle = 0;
  } else {
    $toggle = 1 - $toggle;
  }
}

sub cell {
  my $data = shift;
  my $extra = shift;
  if ($data eq "") { $data = '&nbsp'; }
  SWITCH: {
    if ($cell_type eq "title") {
      print '<th class="title" nowrap ', $extra, ">", $data, "</th>\n";
      last SWITCH;
    }
    if ($cell_type eq "header") {
      print '<th class="header" ', $extra, ">", $data, "</th>\n";
      last SWITCH;
    }
    if ($cell_type eq "data") {
      print '<td nowrap class="', ($toggle ? "odd" : "even"), '" ', $extra, ">", $data, "</td>\n";
      last SWITCH;
    }
  }
}

sub end_row {
  print "</tr>\n";
}

sub hbar {
  my $part = shift;
  my $whole = shift;
  my $width = $graphs * 1000 * $part / $whole;
  $width = $width < 1 ? 1 : int($width + 0.5);
  return '<img alt="graph" src="pixel.gif" height="12" width="' . $width . '">';
}

sub vbar {
  my $part = shift;
  my $whole = shift;
  my $height = $whole ? $graphs * 500 * $part / $whole : 0;
  $height = $height < 1 ? 1 : int($height + 0.5);
  return '<img alt="graph" src="pixel.gif" height="' . $height . '" width="10">';
}

1;
