package product;
require Exporter;

our @ISA = qw( Exporter );
our @EXPORT = qw( get_product );

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_product{
  
    my $self = shift;
    my $chpt = shift;
    my $page = shift;
    
    if($chpt ne "index"){
        product_opens( $self );
    }

    product_calls( $self, $chpt, $page );

    if($chpt ne "index"){
        product_closes( $self );
    }
}




#
#
# SETS OPENING PAGE TAGS ETC
sub product_opens{

    my $self = shift;

# INSERT TITLE HERE
    my $title = "Product ";

# 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>
 
      <td rowspan="2" align="center" valign="top" class="bottomLeft" > <div align="center"> 
          <Script language="JavaScript" src="http://GrillsByDesign.com/_scripts/productsBar.js"></Script>
      </div></td>
      
	<td class="bottomRight" align="center" valign="top" > 
		<SCRIPT language="JavaScript" src="http://GrillsByDesign.com/_scripts/accessoriesBar.js"></SCRIPT> 
	</td>
    </tr> 
    <tr>

EOF3
# TO HERE

$self->setTitle( $title );
$self->setHead( $head );
$self->setBody( $body );
}



#
#
# CALLS INNER-PAGE MODULES
sub product_calls{

    my $self = shift;
    my $chpt = shift;
    my $page = shift;

    if( $chpt eq 'index' ){
	use lib ".";
	use product_index;
	print "Index mod\n";
	product_index::get_index( $self );
    }

    elsif( $chpt eq 'accessory' ){
#	use lib "_produt/_accessory";
#	use accessory;
	print "Accessory mod\n";
#	accessory::get_accessory( $self, $page );
    }
    elsif( $chpt eq 'cabinet' ){
#	use lib "_product/_cabinet";
#	use cabinet;
	print "Cabinet mod\n";
#	cabinet::get_cabinet( $self, $page );
    }
    elsif( $chpt eq 'component' ){
#	use lib "_product/_component";
#	use component;
	print "Component mod\n";
#	component::get_components( $self, $page );
    }

  
    else{
	print "\n\n Not a valid section \n";
	break;
    }

}


#
#
# LOAD CLOSING TAGS
sub product_closes{

    my $self = shift;

my $body =<<EOFCLOSE;
  </tr>
  </table>

EOFCLOSE

    $self->setBody( $body );

}
