package gallery;
require Exporter;

our @ISA = qw( Exporter );
our @EXPORT = qw( get_gallery );

use lib ".";


# START HERE
# If we want the index page, then just call to the index mod
# If we want something else, then open call and close
sub get_gallery{
  
    my $self = shift;
    my $chpt = shift;
    my $page = shift;
    
    if($chpt ne "index"){
        gallery_opens( $self );
    }

    gallery_calls( $self, $chpt, $page );

    if($chpt ne "index"){
        gallery_closes( $self );
    }
}




#
#
# SETS OPENING PAGE TAGS ETC
sub gallery_opens{

    my $self = shift;

# INSERT TITLE HERE
    my $title = "Gallery ";

# INSERT HEADER HTML BETWEEN EOF1'S
my $head =<<EOF1;
EOF1

# INSERT SCRIPT HTML BETWEEN EOF2'S
my $script =<<EOF2;
EOF2
   
# INSERT BODY HTML FROM BETWEEN EOF3'S
my $body =<<EOF3;

<tr> 

<!-- SECONDARY MENU BAR -->
    <td class='bottomLeft' align='center' valign='top' > 
	<SCRIPT language='JavaScript' src='http://grillsbydesign.com/_scripts/galleryListBar.js'></SCRIPT>
    </td>

EOF3
# TO HERE

$self->setTitle( $title );
$self->setHead( $head );
$self->setScript ($script );
$self->setBody( $body );
}



#
#
# CALLS INNER-PAGE MODULES
sub gallery_calls{

    my $self = shift;
    my $chpt = shift;
    my $page = shift;

    if( $chpt eq 'index' ){
	use lib ".";
	use gallery_index;
	print "Index mod\n";
	gallery_index::get_index( $self );
    }

    elsif( $chpt eq 'custom' ){
	use lib "_gallery/_custom";
	use custom;
	print "Custom mod\n";
	custom::get_custom( $self, $page );
  
    }

    elsif( $chpt eq 'showCase'){
#	use lib "_gallery/_showCase";
#	use showCase;
	print "ShowCase mod\n";
#	showCase::get_showCase( $self, $page );
    }

    elsif( $chpt eq 'islandPak' ){
#	use lib "_gallery/_islandPak";
#	use islandPak;
	print "IslandPak mod\n";
#	islandPak::get_islandPak( $self, $page );
    }

    else{
	print "\n\n Not a valid section \n";
	break;
    }

}


#
#
# LOAD CLOSING TAGS
sub gallery_closes{

    my $self = shift;

my $body =<<EOFCLOSE;

</tr>

EOFCLOSE

    $self->setBody( $body );

}
