<?

  include_once '../../config.inc.php';
  if (!include '../autorization.php')
  {
    echo 'Access denied!';
    exit ();
  }

  echo '

<table border="0" cellspacing="0" cellpadding="3" ';
  if (cat_border == '1')
  {
    echo 'style="border: 1px solid ';
    echo cat_border_color;
    echo ';"';
  }

  if (cat_border == '2')
  {
    echo 'style="border-top-width:1px; border-top-style:solid; border-top-color:';
    echo cat_border_color;
    echo '; border-left-width:1px; border-left-style:solid; border-left-color:';
    echo cat_border_color;
    echo '; border-right-width:1px; border-right-style:solid; border-right-color:';
    echo cat_border_color;
    echo ';"';
  }

  echo '>
	';
  if (!($result1 = mysql_query ('SELECT * FROM categories')))
  {
    exit ('<b>Error:</b>' . mysql_error ());
    ;
  }

  while ($row1 = mysql_fetch_array ($result1))
  {
    echo '
	<tr><td ';
    if ($_GET['cat_id'] == urlencode ($row1['name']))
    {
      echo 'bgcolor=' . cat_color . ' ';
    }
    else
    {
      echo 'bgcolor=' . cat_bg_color . ' ';
    }

    if (cat_border == '2')
    {
      echo 'style="border-bottom-width:1px; border-bottom-style: solid; border-bottom-color:';
      echo cat_border_color;
      echo ';"';
    }

    echo '>
	';
    if (cat_bullet_display == 'yes')
    {
      echo '<img src="../../upload/Image/cat_bullet.gif" border="0" valign="middle">&nbsp;';
    }

    echo '	<a href="func_prev.php?func_prev_id=categories()&cat_id=';
    echo urlencode ($row1['name']);
    echo '" style="text-decoration:';
    echo cat_decoration;
    echo ';color:';
    if ($_GET['cat_id'] == urlencode ($row1['name']))
    {
      echo cat_bg_color;
    }
    else
    {
      echo cat_color;
    }

    echo '; font-family:';
    echo cat_font;
    echo '; font-size:';
    echo cat_font_size;
    echo '; font-weight:';
    echo cat_font_weight;
    echo ';">';
    echo $row1['name'];
    echo '</a>

	';
    if (!($result2 = mysql_query ('' . 'SELECT * FROM sub_categories WHERE parent=\'' . $row1['id'] . '\'')))
    {
      exit ('<b>Error:</b>' . mysql_error ());
      ;
    }

    $row2 = mysql_fetch_array ($result2);
    if ((($row2['name'] != '' AND $_GET['cat_id'] == $row1['name']) OR strstr ($_GET['cat_id'], $row1['name'] . '~')))
    {
      $pieces = split ('
', $row2['name']);
      for ($i = 0; $i < sizeof ($pieces); ++$i)
      {
        echo '			</td></tr><tr><td ';
        if ($_GET['cat_id'] == urlencode ($row1['name']) . '~' . $pieces[$i])
        {
          echo 'bgcolor=' . cat_color . ' ';
        }
        else
        {
          echo 'bgcolor=' . cat_bg_color . ' ';
        }

        echo '>
				&nbsp;&nbsp;';
        if (cat_bullet_display == 'yes')
        {
          echo '<img src="../../upload/Image/cat_sub_bullet.gif" border="0" valign="middle">&nbsp;';
        }

        echo '<a href="func_prev.php?func_prev_id=categories()&cat_id=';
        echo urlencode ($row1['name']);
        echo '~';
        echo urlencode ($pieces[$i]);
        echo '" style="text-decoration:';
        echo cat_decoration;
        echo ';color:';
        if ($_GET['cat_id'] == urlencode ($row1['name']) . '~' . $pieces[$i])
        {
          echo cat_bg_color;
        }
        else
        {
          echo cat_color;
        }

        echo '; font-family:';
        echo cat_font;
        echo '; font-size:';
        echo cat_font_size;
        echo '; font-weight:';
        echo cat_font_weight;
        echo ';">';
        echo $pieces[$i];
        echo '</a>
			</td></tr>';
      }
    }

    echo '
	
	</td></tr>
	
	';
  }

  echo '
</table>
';
?>
