#!/usr/bin/perl

use strict;

use DBI;

use CGI ":all";
use lib qw(/usr/local/modules/);
use birds;

use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

# params
my ($bird) = param('bird');

my ($dothis) = param('dothis');	
if (!$dothis) {
	$dothis = 1;
}

# html
my ($spaces) = "&nbsp;&nbsp;&nbsp;";

# start

my ($nospace) = "";

if (!$bird) {
	$dothis = 0;
}

my ($id) = &birds::lookup("species","id","nospace_name","$bird");
my ($code) = &birds::lookup("species","species_code","id","$id");

my ($uc_code) = uc $code;
my ($lc_code) = lc $code;

my ($dbh) = &birds::connect_to_db;
my ($cur,$cur2,$timestamp) = "";

print header,start_html(-title=>"$uc_code Graphs");

print "<CENTER>
<TABLE BORDER=0>\n";

if ($dothis == 0) {
	print "some error";
}

if ($dothis == 1) {

	&make_buttons;

	my ($temp) = "";

	my ($graph_hp) = "_HP.gif";
	my ($graph_sp) = "_SP.gif";
	my ($graph_sh) = "_SH.gif";

	print "<TR><TD ALIGN=CENTER WIDTH=900>\n\n";

	print "<A NAME=\"HP\"><BR></A><A HREF=\"./bird-details.pl?bird=$bird\#graphs\"><IMG SRC=\"../graphs/$lc_code$graph_hp\" BORDER=0></A><BR>
<A NAME=\"SP\"><BR></A><A HREF=\"./bird-details.pl?bird=$bird\#graphs\"><IMG SRC=\"../graphs/$lc_code$graph_sp\" BORDER=0></A><BR>
<A NAME=\"SH\"><BR></A><A HREF=\"./bird-details.pl?bird=$bird\#graphs\"><IMG SRC=\"../graphs/$lc_code$graph_sh\" BORDER=0></A><BR></TD>\n";

}

print "</TR></TABLE>\n";

$dbh->disconnect;


# subs
sub make_buttons {

	# make the nav table
   	print "<TR>\n   <TD ALIGN=RIGHT><!-- buttons -->
<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0>
<TR>
   <TD ALIGN=CENTER><A HREF=\"./species.pl\"><IMG SRC=\"../graphics/button-species.gif\" BORDER=0></A></TD>
   <TD ALIGN=CENTER><A HREF=\"../index.html\"><IMG SRC=\"../graphics/button-main.gif\" BORDER=0></A></TD></TR>
</TABLE><!-- end buttons -->\n\n</TD></TR>\n";


} # end make_buttons

# reference

# revisions
# 2/26/2015 - Suzanne - program created
