<?php

/*

  osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare 

Released under the GNU General Public License 
*/
// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
//if(HIDE_FROM_BACKEND_MENU_SUBSCRIPTIONS=='false'){
if(!defined('BOX_HEADING_STATIC'))define('BOX_HEADING_STATIC', 'Static');
function tep_show_static_category($counter) {
    //global $subscription_foo, $subscription_categories_string, $subscription_display_id, $subscription_aa,$current_view;
    global $static_foo, $page_categories_string, $page_display_id, $page_aa,$current_view;
   
    if ($static_foo[$counter]['parent'] == 0) {
      $stcPath_new = 'stcPath=' . $counter;
    } else {
      $stcPath_new= 'stcPath=' . $static_foo[$counter]['path'];
    }
	
	
     $page_categories_string .= '<table border=0 cellpadding=0 width="100%"><tr height="20" valign="middle" onmouseover="javascript:this.className=\'boxRowOver\';" onmouseout="javascript:this.className=\'boxRow\';"><td class="infoBoxNavigationSub"><div style="padding-left:';
	$padding="10";
	if ($static_foo[$counter]['parent'] != 0) {
	  //$events_categories_string .=tep_draw_separator('pixel_trans.gif',$events_foo[$counter]['level']*10,1);
	  $padding+=$static_foo[$counter]['level']*10;
    }
	$page_categories_string .=$padding . 'px">' . '-&nbsp;';

    if ( ($page_display_id) && (in_array($counter, $page_display_id)) ) {
    	$page_categories_string .= '<b><a class="navBlue" href="';
	} else{
	   $page_categories_string .='<a href="';
	}

    $page_categories_string.= tep_href_link(FILENAME_DEFAULT, $stcPath_new);
	
    $page_categories_string.= '">' .$static_foo[$counter]['name'] . '</a></td></tr></table>';

    if ($static_foo[$counter]['next_id']) {
      tep_show_static_category($static_foo[$counter]['next_id']);
    }
  }
  
 /* function tep_show_static_category_ori($counter) {
    global $static_foo, $page_categories_string, $page_display_id, $page_aa,$current_view;

    for ($a=0; $a<$static_foo[$counter]['level']; $a++) {
      if ($a == $static_foo[$counter]['level']-1)
	  	{
		$page_categories_string .= "<font color='#ff0000'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>";
     	} else
	  		{
	  		$page_categories_string .= "<font color='#ff0000'>&nbsp;&nbsp;&nbsp;&nbsp;</font>";
     		}

		}
    if ($static_foo[$counter]['level'] == 0)
	{
		if ($page_aa == 1)
		{
		$page_categories_string .= "<br  style='LINE-HEIGHT:5px' >";
	    }
		else
		{$page_aa=1;}

	}


    $page_categories_string .= '<nobr>';
	//if ($static_foo[$counter]['parent'] == 0) $page_categories_string .= '<img src="images/custom/arrow1.gif" align="absmiddle" >';
	//$page_categories_string .='<table border=1 cellpadding=0 width="100%"><tr  valign="middle"><td class="infoBoxNavigationSub">'. '&nbsp;&nbsp; -<font color="#000000"><a href="';
	$page_categories_string .='&nbsp;&nbsp; -<font color="#000000"><a  href="';
	
    if ($static_foo[$counter]['parent'] == 0) {
	     $stcPath_new = 'stcPath=' . $counter;
    } else {
      $stcPath_new = 'stcPath=' . $static_foo[$counter]['path'];
    }

    $page_categories_string .= tep_href_link(FILENAME_DEFAULT,$stcPath_new);
	
    $page_categories_string .= '">';

    if ( ($page_display_id) && (in_array($counter, $page_display_id)) ) {
      $page_categories_string .= "<b><font color=''>";
    }

// display category name
   // $page_categories_string .= '&nbsp;' . $static_foo[$counter]['name'] . '</td></tr></table>';
   $page_categories_string .= '&nbsp;' . $static_foo[$counter]['name'];

    if ( ($page_display_id) && (in_array($counter, $page_display_id)) ) {
      $page_categories_string .= '</font></b>';
    }

   // if (tep_has_subscription_category_subcategories($counter)) {
   //   $categories_string .= '-&gt;';
   // }

    $page_categories_string .= '</nobr></a></font>';

   // if (SHOW_COUNTS == 'true') {
   //   $subscription_in_subscription_category = tep_count_subscription_in_subscription_category($counter);
   //   if ($subscription_in_category > 0) {
   //     $page_categories_string .= '&nbsp;(' . $subscription_in_subscription_category . ')';
   //   }    }

    $page_categories_string .= '<br>';

    if ($static_foo[$counter]['next_id']) {
		tep_show_static_category($static_foo[$counter]['next_id']);
    }
  }*/
?>
<!-- categories //-->
          <tr>
            <td>
<?php

  $page_aa = 0;
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
  							'text'  => BOX_HEADING_STATIC 
							   );
  new infoBoxHeading($info_box_contents, true, true);
$page_categories_string = '';


$static_sql = "select md.page_name, md.description, md.page_id, m.parent_id from " . TABLE_MAINPAGE . " m, " . TABLE_MAINPAGE_DESCRIPTIONS . " md where m.parent_id = '0' and m.page_id=md.page_id and m.page_status=1 and md.language_id='" . $languages_id ."' order by sort_order, md.page_name";

$static_query = tep_db_query($static_sql);
  while ($static_pages = tep_db_fetch_array($static_query))  {
    $static_foo[$static_pages['page_id']] = array(
                                        'name' => $static_pages['page_name'],
                                        'parent' => $static_pages['parent_id'],
                                        'level' => 0,
                                        'path' => $static_pages['page_id'],
                                        'next_id' => false
                                       );

    if (isset($static_prev_id)) {
      $static_foo[$static_prev_id]['next_id'] = $static_pages['page_id'];
    }

    $static_prev_id = $static_pages['page_id'];

    if (!isset($static_first_element)) {
      $static_first_element = $static_pages['page_id'];
	}
	
  }
  //------------------------
  if ($stcPath) {
    $static_new_path = '';
    $page_display_id = split('_', $stcPath);
    reset($page_display_id);

    while (list($static_key, $static_value) = each($page_display_id)) {
      unset($static_prev_id);
      unset($static_first_id);

      $static_query = tep_db_query("select md.page_id, md.page_name, m.parent_id from " . TABLE_MAINPAGE . " m, " . TABLE_MAINPAGE_DESCRIPTIONS . " md where m.parent_id = '" . $static_value . "' and m.page_id=md.page_id and m.page_status=1 and md.language_id='" . $languages_id ."' order by sort_order, md.page_name");
      $static_category_check = tep_db_num_rows($static_query);

      if ($static_category_check > 0) {
        $static_new_path .= $static_value;
        while ($row = tep_db_fetch_array($static_query)) {
          $static_foo[$row['page_id']] = array(
                                              'name' => $row['page_name'],
                                              'parent' => $row['parent_id'],
                                              'level' =>$static_key+1,
                                              'path' =>$static_new_path . '_' . $row['page_id'],
                                              'next_id' => false
                                             );

          if (isset($static_prev_id)) {
            $static_foo[$static_prev_id]['next_id'] = $row['page_id'];
          }

          $static_prev_id = $row['page_id'];

          if (!isset($static_first_id)) {
            $static_first_id = $row['page_id'];
          }

          $static_last_id = $row['page_id'];
        }
        $static_foo[$static_last_id]['next_id'] = $static_foo[$static_value]['next_id'];
        $static_foo[$static_value]['next_id'] =$static_first_id;
        $static_new_path .= '_';
      } else {
        break;
      }
    }
  }

  tep_show_static_category($static_first_element);

  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
                               'text'  =>$page_categories_string);
  new infoBox($info_box_contents);
  
$info_box_contents = array();
  $info_box_contents[] = array('align' => 'left',
'text'  => tep_draw_separator('pixel_trans.gif', '100%', '1')
                              );
  new infoboxFooter($info_box_contents, true, true);

?>

		    </td>
          </tr>
 <?PHP  //} ?>
<!-- categories_eof //-->