<?
session_start();
require_once('../connect/connect.php');
include_once('../lib/lib.php');
require('pdk.php');

$base_path="../";
$bp="../";

$name_region="Все регионы";
$name_razdel="Все разделы";

$tree_reg=array(0);
$tree_cat=array(0);

if($_GET['id_catalog'])
$id_catalog=intval($_GET['id_catalog']);


if($_GET['id_region'])
{
$id_region=intval($_GET['id_region']);
$r = mysql_query("SELECT id_region, parent_glob, path FROM region WHERE id_region = '".$id_region."'");
$rr = mysql_fetch_array($r);
$glob_region=$rr['parent_glob'];
if(!$glob_region)
$glob_region=$rr['id_region'];
$tree_reg = explode(' ', trim($rr['path'].' '.$id_region));
}

if(file_exists($base_path.'cashe_region/_svod_region_0.php'))
include_once($base_path.'cashe_region/_svod_region_0.php'); // регионы первого уровня

if($glob_region && file_exists($base_path.'cashe_region/_svod_region_'.$glob_region.'.php'))
include_once($base_path.'cashe_region/_svod_region_'.$glob_region.'.php'); // наш регион

for ($i=1; $i<count($tree_reg); $i++)
{
if($i<2)
$name_region = $arr_regions[$tree_reg[($i-1)]][$tree_reg[$i]];
else
$name_region .= ', '.$arr_regions[$tree_reg[($i-1)]][$tree_reg[$i]];
}

include_once($base_path.'cashe_catalog/_svod_catalog.php'); // дерево каталогов


if($id_catalog)
{
include_once($base_path.'cashe_catalog/_svod_catalog_'.$id_catalog.'.php');
include_once($base_path.'plugin/board/func_search_user.php'); 
include_once($base_path.'plugin/board/func_view.php');

if($arr_sp)
	{
	foreach($arr_sp as $ars)
		{
		if(file_exists($base_path.'cashe_n/_svod_element_'.$ars[0].'.php'))
		include_once($base_path.'cashe_n/_svod_element_'.$ars[0].'.php');
		
		if(file_exists($base_path.'cashe_n/_svod_element_two_'.$ars[1].'.php'))
		include_once($base_path.'cashe_n/_svod_element_two_'.$ars[1].'.php');
		}
	}
$name_razdel=$arr_catalog['catalog'];
}

$title=$name_razdel.'. '.$name_region;

if($id_catalog && !$arr_razdel[$arr_catalog['id_catalog']])
$con_razdel=1;

$titl=$title;
require ('top.php'); 

?>

<table width="100%" cellpadding="3" cellspacing="3" class="table" >
	<tr>
		<td >
			<table width="100%">
				<tr>
					<td valign="top" width="90%" >
					<?
					include_once("search_form_magazin.php"); 
					?>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	
	<tr>
		<td>
		<?
		include_once("tab_magazin.php"); 
		?>
		</td>
	</tr>
</table>


<?
require('bottom.php');
?>