#!@@_perl_root_@@/bin/perl.exe
package FormatdictyBase;

##########################################################
#                                                        #
# dictyBase Extension of FormatdictyBase                 #
#                                                        #
##########################################################

use FormatdictyBase_base;
no warnings 'redefine';
BEGIN { %FormatdictyBase:: = %FormatdictyBase_base:: }


use CGI::SSI;



#
#
# changed to use serverside include to make code between html and cgi common
#
#  user can call any page with noheader option, then it doesn't create whole
#  header
#
##############################################################################
sub PrintPageTop {
##############################################################################
# this subroutine simply prints out the top of the sub pages, including
# the tool bar.  In addition to the database, it takes a page header as 
# an argument and optionally a help file. 

    my $database = shift;
    my $title = shift;
    my $helpfile = shift;
    my $help2 = shift;

    my $ssi = CGI::SSI->new();
    $ssi->set(var => "title", value => "$title");
#    print $ssi->include(virtual => "/inc/header_noSide.html") if (!param('noheader'));
    print $ssi->include(virtual => "/inc/page-header-curation.html") if (!param('noheader'));
    print $ssi->include(virtual => "/inc/page-layout-top-wide.html") if (!param('noheader'));

    print '<div class="page-curation">';
    &PrintTitleWithHelp($database, $title, $helpfile, $help2);

   #
   # for gbrowse, need it to return a non null value, so use &nbsp; as a dummy
   #
    return "&nbsp;";
 
}


#
##############################################################################
sub PrintPopupTop {
##############################################################################
# this subroutine simply prints out the top of the sub pages, including
# the tool bar.  In addition to the database, it takes a page header as 
# an argument and optionally a help file. 

    my $database = shift;
    my $title = shift;
    my $helpfile = shift;
    my $help2 = shift;

    my $ssi = CGI::SSI->new();
    $ssi->set(var => "title", value => "$title");

    print $ssi->include(virtual => '/inc/header_popup.html') if (!param('noheader'));

   # &PrintTitleWithHelp($database, $title, $helpfile, $help2);

   #
   # for gbrowse, need it to return a non null value, so use &nbsp; as a dummy
   #
    return "&nbsp;";
 
}

#
# changed to server side include
#
#  user can call any page with noheader option, then it doesn't create whole
#  footer
#
#
##############################################################################
sub FooterReturnEmail {
##############################################################################
# Standard dictyBase footer with return gif and email

    my $ssi = CGI::SSI->new();
#    print $ssi->include(virtual => "/inc/footer_noSide.html") if (!param('noheader'));;
    print '</div>';
    print $ssi->include(virtual => "/inc/page-layout-bottom.html") if (!param('noheader'));    
    print $ssi->include(virtual => "/inc/page-footer.html") if (!param('noheader'));

}

#
# changed to server side include
#
#  user can call any page with noheader option, then it doesn't create whole
#  footer
#
#
##############################################################################
sub FooterPopup {
##############################################################################
# Standard dictyBase footer with return gif and email
    my $ssi = CGI::SSI->new();
    print $ssi->include(virtual => "/inc/footer_popup.html") if (!param('noheader'));;

}


##############################################################################
sub FooterPlain {
##############################################################################
#  footer with nothing but line at bottom
    my $ssi = CGI::SSI->new();
    print $ssi->include(virtual => "/inc/footer_plain.html") if (!param('noheader'));;

}


#
# changed to server side include
#
##############################################################################
sub Copyright{
##############################################################################
# return copyright message
    my $ssi = CGI::SSI->new();
    print $ssi->include(virtual => "/inc/copyright.html");
}

#
#  took out gotutorial link functionality (we don't have a go tutorial),
#  changed help to a popup
#
##############################################################################
sub Help{
##############################################################################
# This subroutine returns a string, which prints out the help graphic
# button aligned to the right hand side, and will use whatever is
# passed in as the link, or by default will link to the specs page.


    my $url = help_url(@_);

    return "<table cellspacing='0' cellpadding='0'><Tr><td><a href=\"$url\"><img src=\"http://dictybase.org/db/html/images/help.png\" align=\"RIGHT\" valign=\"MIDDLE\" alt=\"Help\" border=\"0\"></a></td></Tr><Tr><td>$goTutHelp</td></Tr></table>";

}


##############################################################################
sub help_url{
##############################################################################
# This subroutine returns a string, which prints out the help graphic
# button aligned to the right hand side, and will use whatever is
# passed in as the link, or by default will link to the specs page.

    my $helpfile = shift;
    my $database = uc(shift);
    my $goTut = shift;

    my $url;
    if ($helpfile =~ /\/staff\/dictyBase\/help\/(.+)$/) {
	$url = "http://dictybase.org/db/staff/dictyBase/help/$1";
    }
    elsif ($helpfile =~ /^http:/ && $helpfile !~ /html/i) {
	$url = $helpfile;
    }
    else {
	$helpfile =~ s/^.+\/([^\/]+)$/$1/;
    	$url = "http://dictybase.org/db/html/help/$helpfile";
    }
#    my $goTutHelp;
#    if ($goTut) {
#	$goTutHelp = "<br><a href=http://dictybase.org/db/html/help/gotutorial.html><img src=http://dictybase.org/db/html/images/GOT.gif align=RIGHT valign=MIDDLE border=0></a>";
#    }




    $url = "javascript:NewWindow('$url', 'Help', '650', '650', 'center','front');";

    return $url;
 
}

1;