<?php
/*
  $Id: footer.php,v 1.26 2003/02/10 22:30:54 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require(DIR_WS_INCLUDES . 'counter.php');
?>

             </td>
             <td width=4></td>
             <td width=258 valign=top height=100%>
              <table cellspacing=0 cellpadding=0>
               <tr><td width=131 bgcolor=#5A87C2>
                    <table cellspacing=0 cellpadding=0 width=100 align=center>
                     <tr><td height=23></td></tr>
                     <tr><td class=gc1>Currencies:</td></tr>
                     <tr><td height=5></td></tr>
                     <tr><td>

<? // CURRENCIES

    echo tep_draw_form('currencies', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get');

    reset($currencies->currencies);
    $currencies_array = array();
    while (list($key, $value) = each($currencies->currencies)) {
      $currencies_array[] = array('id' => $key, 'text' => $value['title']);
    }

    $hidden_get_variables = '';
    reset($HTTP_GET_VARS);
    while (list($key, $value) = each($HTTP_GET_VARS)) {
      if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) {
        $hidden_get_variables .= tep_draw_hidden_field($key, $value);
      }
    }

    echo tep_draw_pull_down_menu('currency', $currencies_array, $currency, 'onChange="this.form.submit(); " style="width:100px; font-size: 9px" ') . $hidden_get_variables . tep_hide_session_id();
    echo '</form>';
    
?>               

                     </td></tr>
                     <tr><td height=14></td></tr>
                    </table>
                   </td>
                   <td width=131 bgcolor=#5A87C2>
                    <table cellspacing=0 cellpadding=0 width=100 align=center>
                     <tr><td height=10></td></tr>
                     <tr><td class=gc1>Choose<br>your language:</td></tr>
                     <tr><td height=5></td></tr>
                     <tr><td>
<? // LANGUAGES

  if (!isset($lng) || (isset($lng) && !is_object($lng))) {
    include(DIR_WS_CLASSES . 'language.php');
    $lng = new language;
  }

  $languages_string = '';
  reset($lng->catalog_languages);
  while (list($key, $value) = each($lng->catalog_languages)) {
    $languages_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES .  $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a> ';
  }

  echo $languages_string;

?>     
                     </td></tr>
                     <tr><td height=14></td></tr>
                    </table>                   
               </td></tr>
              </table>
              <table cellspacing=0 cellpadding=0 width=193 align=center>
               <tr><td height=20></td></tr>
               <tr><td><img src=images/m29.gif width=193 height=24></td></tr>
               <tr><td height=6></td></tr>


<?   // ---- CATEGORIES

  function tep_show_category($counter) {
    global $tree, $categories_string, $cPath_array;

   if(!$tree[$counter]['level']){               
                     
    $categories_string .= $categories_string ? '<tr><td><img src=images/m28.gif width=193 height=1></td></tr><tr><td height=3></td></tr>' : '';             

    $categories_string .= '<tr><td><img src=images/m27.gif width=4 height=4 align=absmiddle> &nbsp; <a class=ml1  href=';
    
    if ($tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $tree[$counter]['path'];
    }
    $categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display categry name
    $categories_string .= $tree[$counter]['name'];
    $categories_string .= '</a></td></tr><tr><td height=3></td></tr>';
   
   }else{  // SUBCATEGORY
   
    $categories_string .= '<tr><td>&nbsp; &nbsp; ';

    for($i=0;$i<$tree[$counter]['le vel'];$i++)
     $categories_string .= '&nbsp;&nbsp;&nbsp;';
    
    $categories_string .= ' - <a class=ml1 style="font-weight:normal;" href=';   
    if ($tree[$counter]['parent'] == 0) {
      $cPath_new = 'cPath=' . $counter;
    } else {
      $cPath_new = 'cPath=' . $tree[$counter]['path'];
    }
    $categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display category name
    $categories_string .= $tree[$counter]['name'];
    $categories_string .= '</a></td></tr><tr><td height=3></td></tr>';
   }  

    if ($tree[$counter]['next_id'] != false) {
      tep_show_category($tree[$counter]['next_id']);
    }  
  }



  define(TABLE_CATEGORIES, "categories");
  define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");
  $categories_string = '';
  $tree = array();

  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
  while ($categories = tep_db_fetch_array($categories_query))  {
    $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
                                                'parent' => $categories['parent_id'],
                                                'level' => 0,
                                                'path' => $categories['categories_id'],
                                                'next_id' => false);

    if (isset($parent_id)) {
      $tree[$parent_id]['next_id'] = $categories['categories_id'];
    }

    $parent_id = $categories['categories_id'];

    if (!isset($first_element)) {
      $first_element = $categories['categories_id'];
    }
  }

  //------------------------
  if ($cPath) {
    $new_path = '';
    reset($cPath_array);
    while (list($key, $value) = each($cPath_array)) {
      unset($parent_id);
      unset($first_id);
      $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
      if (tep_db_num_rows($categories_query)) {
        $new_path .= $value;
        while ($row = tep_db_fetch_array($categories_query)) {
          $tree[$row['categories_id']] = array('name' => $row['categories_name'],
                                               'parent' => $row['parent_id'],
                                               'level' => $key+1,
                                               'path' => $new_path . '_' . $row['categories_id'],
                                               'next_id' => false);

          if (isset($parent_id)) {
            $tree[$parent_id]['next_id'] = $row['categories_id'];
          }

          $parent_id = $row['categories_id'];

          if (!isset($first_id)) {
            $first_id = $row['categories_id'];
          }

          $last_id = $row['categories_id'];
        }
        $tree[$last_id]['next_id'] = $tree[$value]['next_id'];
        $tree[$value]['next_id'] = $first_id;
        $new_path .= '_';
      } else {
        break;
      }
    }
  }
  $categories_string .=  '';
  tep_show_category($first_element); 
  $categories_string .=  '';

  echo $categories_string;
?>





               <tr><td height=10></td></tr>
              </table>
              <table cellspacing=0 cellpadding=0>
               <tr><td bgcolor=#5A87C2 height=10></td></tr>
               <!--<tr><td valign=bottom><a href=<?=tep_href_link('specials.php')?>><img src=images/m30.jpg width=258 height=157 border=0></a></td></tr>-->
              </table>
             </td>
             <td width=4></td></tr>
             
             
        </table>
        <table cellspacing=0 cellpadding=0 width=758 align=center bgcolor=#ffffff>
         <tr><td height=5 width=758 bgcolor=#5A87C2></td></tr>
         <tr><td height=8 width=758 background="/images/bg_pattern.gif"></td></tr>
         <tr><td height=23></td></tr>
         <tr><td bgcolor=#ffffff><font color=#131379>Copyright &copy; 2005 zkids.com</font> &nbsp;<a class=ml3 href=http://oscommerce.com target=_blank class=m13>Powered by osCommerce</a></td></tr>
         <tr><td height=26></td></tr>
        </table>
   </td></tr>
  </table>


<?php
  if ($banner = tep_banner_exists('dynamic', '468x50')) {
?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><?php echo tep_display_banner('static', $banner); ?></td>
  </tr>
</table>
<br>
<?php
  }
?>
