<?php 

// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB; ?>">
<?php
// BOF: Lango Added for template MOD
if (SHOW_HEADING_TITLE_ORIGINAL == 'yes') {
$header_text = '&nbsp;'
//EOF: Lango Added for template MOD
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
                        <td class="pageHeading">
             <?php 
               if ( (ALLOW_CATEGORY_DESCRIPTIONS == 'true') && (tep_not_null($sers_category['services_categories_heading_title'])) ) {
                 echo $sers_category['services_categories_heading_title'];
               } else {
                 echo HEADING_TITLE;
               }
             ?>
            </td>
            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $sers_category['services_categories_image'], $sers_category['services_categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
	  <?php if ( (ALLOW_CATEGORY_DESCRIPTIONS == 'true') && (tep_not_null($sers_category['services_categories_description'])) ) { ?>
	  <tr>
            <td align="left" colspan="2" class="category_desc"><?php echo $sers_category['services_categories_description']; ?></td>
	  </tr>
	  <?php } ?>
        </table></td>
      </tr>
<?php
// BOF: Lango Added for template MOD
}else{ 
    // Get the category name and description
	$sers_category_sql = "SELECT sucd.services_categories_name, sucd.services_categories_heading_title, sucd.services_categories_description, suc.services_categories_image from " . TABLE_SERVICES_CATEGORIES . " suc, " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " sucd where suc.services_categories_id='" . $current_services_category_id . "' and suc.services_categories_id=sucd.services_categories_id and sucd.language_id = '" . $languages_id . "'";
	$sers_category_query = tep_db_query($sers_category_sql);
	$sers_category = tep_db_fetch_array($sers_category_query);

               if ((tep_not_null($sers_category['services_categories_heading_title'])) ) {
                 $header_text= $sers_category['services_categories_heading_title'];
               } else {
                 $header_text=HEADING_TITLE;
               }
}
// EOF: Lango Added for template MOD
	if(!isset($hide_row_top)) {
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php } ?>	  

      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_top(false, false, $header_text);
}
// EOF: Lango Added for template MOD
?>
			<tr>
				<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php 
    if (isset($secPath) && strpos($secPath,'_')) {
// check to see if there are deeper categories within the current category
      $sers_category_links = array_reverse($secPath_array);
      for($i=0, $n=sizeof($sers_category_links); $i<$n; $i++) {
	  	$sers_categories_sql = "select count(*) as total from " . TABLE_SERVICES_CATEGORIES . " suc, " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " sucd where suc.parent_id = '" . (int)$sers_category_links[$i] . "' and suc.services_categories_id = sucd.services_categories_id and sucd.language_id = '" . (int)$languages_id . "'";
		$sers_categories_query = tep_db_query($sers_categories_sql);
        $sers_categories = tep_db_fetch_array($sers_categories_query);
        if ($sers_categories['total'] < 1) {
          // do nothing, go through the loop
        } else {
			$sers_categories_sql = "select suc.services_categories_id, sucd.services_categories_name, suc.services_categories_image, suc.parent_id from " . TABLE_SERVICES_CATEGORIES . " suc, " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " sucd where suc.parent_id = '" . (int)$sers_category_links[$i] . "' and suc.services_categories_id = sucd.services_categories_id and sucd.language_id = '" . (int)$languages_id . "' order by sort_order, sucd.services_categories_name";
		  $sers_categories_query = tep_db_query($sers_categories_sql);
          break; // we've found the deepest category the customer is in
        }
      }
    } else {
      $sers_categories_sql = "select suc.services_categories_id, sucd.services_categories_name, suc.services_categories_image, suc.parent_id from " . TABLE_SERVICES_CATEGORIES . " suc, " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " sucd where suc.parent_id = '" . (int)$current_services_category_id . "' and suc.services_categories_id = sucd.services_categories_id and sucd.language_id = '" . (int)$languages_id . "' order by sort_order, sucd.services_categories_name";
	  $sers_categories_query = tep_db_query($sers_categories_sql);
    }

    $number_of_sers_categories = tep_db_num_rows($sers_categories_query);

    $rows = 0;
    while ($sers_categories = tep_db_fetch_array($sers_categories_query)) {
      $rows++;
      $serPath_new = tep_get_service_path($sers_categories['services_categories_id']);
      $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
      echo '                <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, 'secPath=' . $serPath_new) . '">' . tep_image(DIR_WS_IMAGES . $sers_categories['services_categories_image'], $sers_categories['services_categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $sers_categories['services_categories_name'] . '</a></td>' . "\n";
      if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_sers_categories)) {
        echo '              </tr>' . "\n";
        echo '              <tr>' . "\n";
      }
    }

// needed for the new products module shown below
    $new_services_category_id = $current_services_category_id;
?>
			</table>
			</td>
              </tr>
<?php
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_bottom();
}
// EOF: Lango Added for template MOD
?>
            </table>
			</td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
          </tr>
          <tr>
            <td><?php include(DIR_WS_MODULES . FILENAME_NEW_SERVICES); ?></td>
          </tr>
        </table></td>
      </tr>
    </table>
