###############################################################################
# BizDesign ImageFolio Lite Edition 4.2 (Four-dot-Two)
###############################################################################
#
#          ##          ###        VERSION       :  4.2
#        ####        ##   ##      RELEASED ON   :  02/15/2007
#      ##  ##              ##     LAST MODIFIED :  02/15/2007
#    ##########          ##       
#          ##   ###    ##         
#          ##   ###  ########     
#
###############################################################################
# Released by BizDesign, Inc.
# written by Dirk Koppers and Greg Raaum of BizDesign
#
# Purchasing :  http://imagefolio.com/purchase/
# Support    :  http://imagefolio.com/support/
# Phone      :  (214) 642-9787
# Email      :  sales@bizdesign.com
###############################################################################
# COPYRIGHT AND LICENSE INFORMATION :
#
# Copyright (c) 1999-2007 BizDesign, Inc. All rights reserved.
#
# Selling or distributing the code for this program without prior written
# consent is expressly forbidden.
#
# One licensed copy of the program may reside on a single server, in use by a
# single domain.  For each installed instance of the program, a separate
# license is required.
#
# Licensed users may alter or modify this software, at their own risk, of
# course.  They may also hire others to modify their own copy of the code, as
# long as the code is not transferred to or retained by the individual who is
# hired (unless he/she is also a license holder). Although license-holders
# may modify the code for their use, modified code may NOT be resold or
# distributed.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BIZDESIGN,
# INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# BizDesign, Inc. is not liable for any conduct associated with image gallery
# activity, nor for any binary media posted using this program, including but
# not imited to images, photographs, movies, and clipart.
#
# The user must assume the entire risk of using the program.  Although this
# program has been thoroughly tested on BizDesign's servers, BizDesign does not
# warrant that it works on all servers and will not be held liable for anything,
# including but not limited to, misusage, error, or loss of data.  ANY
# LIABILITY OF THE SELLER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT
# OR REFUND OF PURCHASE PRICE.  Use at your own risk!
###############################################################################
# Do not modify below this line unless you know what you are doing.
###############################################################################


###############################################################################
# GEN HOME PAGE
# Generated if a category was not selected prior to calling the script
# outputs a page listing all the main categories, in two columns
###############################################################################
sub gen_home_page {

   @user_sorting_choices = ();
   @user_row_choices = ();
#   @user_skin_choices = ();
   $thumb_info_layout = ();
#   $nav_switching = ();

   $pagelinks = qq| <$font>Top</font>|;
   &build_pull_down_menu;
   &build_nav;
   &main_gallery_count;
   
   $site_title =~ s/\*\*\*Admin Mode\*\*\*// if $quickdisplay;

   open (TEMPLATE,"$home_template") or &Error("Could not open $home_template.  Reason $!");
   while (<TEMPLATE>) {
      if (/<!--#include\s+(virtual|file)\s*=\s*"*([^"\s]*)"*\s*-->/i) { $template .= &ssi_include($2); }
      elsif (/<!--#exec\s+(cgi)\s*=\s*"*([^"\s]*)"*\s*-->/i) { $template .= &ssi_exec_include($2); }
      else { $template .= $_; }
   }
   close(TEMPLATE);

   require "$libpath/headerfooter.pl";

   $template =~ s/%%%TEXTNAV%%%/$textnav/ig;
   
   if ($use_textlinks) {
      $template =~ s/%%%NAV%%%/<$font>$textnav<\/font>/ig;
   }
   else {
      $template =~ s/%%%NAV%%%/$nav/ig;      
   }
   $template =~ s/%%%CATEGORIES%%%/$columncat/ig;
   $template =~ s/%%%COUNTS%%%/$counts/ig;
   $template =~ s/%%%SITE_TITLE%%%/$site_title/ig;
   $template =~ s/%%%COUNTS%%%/$counts/ig;
   $template =~ s/%%%NAV%%%/$nav/ig;
   $template =~ s/%%%PAGELINKS%%%/$pagelinks/ig;
   $template =~ s/%%%IFIMAGES%%%/$if_images_directory/ig;
   $template =~ s/%%%JS_ROLLOVERS%%%/$jsrollovers/ig;
   $template =~ s/%%%COLUMN_WIDTH%%%/$cat_column_width/ig;
   $template =~ s/%%%TEXTPULLDOWN_MENU%%%/$textpulldown_menu/ig;
   $template =~ s/%%%PULLDOWN_MENU%%%/$pulldown_menu/ig;
   $template =~ s/%%%SEARCH_BOX%%%/$search_box/ig;

   $template =~ s/%%%MAIN_TABLE_BORDER_COLOR%%%/$main_table_border_color/ig;
   $template =~ s/%%%MAIN_HEADER_BGCOLOR%%%/$main_header_bgcolor/ig;
   $template =~ s/%%%MAIN_NAV_BGCOLOR%%%/$main_nav_bgcolor/ig;
   $template =~ s/%%%MAIN_HEADER_FONT%%%/$main_header_font/ig;

#   if ($is_admin) {
#      $if_javascript .= &admin_js_popup;
#      $admin_tools = &create_tools;
#      $template =~ s/%%%ADMIN_TOOLS%%%/$admin_tools/ig;
#   }

   $template =~ s/%%%IF_JAVASCRIPT%%%/$if_javascript/ig;
}

sub main_gallery_count {
   if ($allow_free_access) {
      open (FILE,"$indexfile") or &Error("Can't Open $indexfile, is it created?: $!");
      my(@BLAH)=<FILE>;
      close(FILE);
      $IMAGESIZE = @BLAH;
   }
   else {
      open (FILE,"$catfile") or &Error("Can't Open $catfile, is it created?: $!");
      my(@BLAH)=<FILE>;
      close(FILE);
      $CATSIZE = ();
      foreach $blah (@BLAH) {
         my($indexcat, $indexcount) = split(/\t/, $blah);
         foreach $this_cat_access (@current_cat_access) {
            if (($indexcat =~ /^$this_cat_access\//i) or ($indexcat eq $this_cat_access)) {
               $IMAGESIZE = $IMAGESIZE + $indexcount;
               $CATSIZE++;
               last;
            }
         }
      }
   }

   $counts = "$IMAGESIZE images in $CATSIZE categories";
}

1;
