<?
if (isset($_REQUEST[session_name()])) 
@session_start();

$name_stranica='catalog';

$base_path="../";
$bp="../";
if(isset($_GET['id_catalog']))
$bp="../../../";

$name_region="Россия";
$name_title="Доска объявлений";
$title="Доска объявлений";

require_once($base_path.'connect/connect.php');
include_once($base_path.'lib/lib.php');
include_once($base_path.'connect/_svod_rec.php');

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

if($_GET['id_catalog'])
	{
	$id_catalog=intval($_GET['id_catalog']);
	$cam=urlencode(anti($_GET['cam']));
	}

if($_GET['id_region'])
	{
	$rem=urlencode(anti($_GET['rem']));
	$id_region=intval($_GET['id_region']);
	$r = mysql_query("SELECT id_region, parent_glob, path FROM region WHERE id_region = '".$id_region."' AND url='".$rem."'");
	$nr=mysql_num_rows($r);
	if(!$nr)
		{
		header('HTTP/1.1 404 Not Found');
		header('Status: 404 Not Found');
		echo "<HTML><HEAD><meta http-equiv='Refresh' charset='utf-8' content='0; URL=".$bp."404.php'></HEAD></HTML>";
		exit;
		}
	$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)
	{
	if(file_exists($base_path.'cashe_catalog/_svod_catalog_'.$id_catalog.'.php'))
		{
		include_once($base_path.'cashe_catalog/_svod_catalog_'.$id_catalog.'.php');
		if($arr_catalog['url'] != $cam)
			{
			header('HTTP/1.1 404 Not Found');
			header('Status: 404 Not Found');
			echo "<HTML><HEAD><meta http-equiv='Refresh' charset='utf-8' content='0; URL=".$bp."404.php'></HEAD></HTML>";
			exit;
			}
		}
	else
		{
		header('HTTP/1.1 404 Not Found');
		header('Status: 404 Not Found');
		echo "<HTML><HEAD><meta http-equiv='Refresh' charset='utf-8' content='0; URL=".$bp."404.php'></HEAD></HTML>";
		exit;
		}
	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_title=$arr_catalog['catalog'];
	$title=$arr_catalog['catalog'];
	
	if($arr_catalog['title'])
	$name_title=$arr_catalog['title'];
	
	if($arr_catalog['h1'])
	$title=$arr_catalog['h1'];
	
	
	if($arr_field)
		{
		foreach ($arr_field as $index=>$arr_fie)
			{
			if($arr_fie['field_param_search'] && $arr_field[$index]['field_spisok'] && $_GET[$arr_field[$index]['field_field']][1] )
				{
				$mark = $arr_element[$arr_field[$index]['field_spisok']][$_GET[$arr_field[$index]['field_field']][1]];
				if($_GET[$arr_field[$index]['field_field']][2])
				$mark .= ' '.$arr_element_two[$_GET[$arr_field[$index]['field_field']][1]][$_GET[$arr_field[$index]['field_field']][2]];
				break;
				}
			}
		}
		
	if($mark) 
		{
		$name_title .= ', '.$mark;
		$title .= ', '.$mark;
		}
	}

if($name_region)
	{
	$name_title=$name_title.'. '.$name_region;
	$title=$title.'. '.$name_region;
	}

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

if($_GET['map'])
	{
	$tab_mapp='onLoad="initialize()"';
	$tab_map=intval($_GET['map']);
	}
else
	$tab_mapp='';
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?=$name_title?></title>
<?
if($arr_catalog['description'])
{
?>
<meta name="description" content="<?=$arr_catalog['description']?>"/>
<?
}
if($arr_catalog['keywords'])
{
?>
<meta name="keywords" content="<?=$arr_catalog['keywords']?>"/>
<?
}
?>
<link rel="shortcut icon" href="<?=$bp?>icon/favicon.ico" type="image/x-icon">
<meta name="Author" content="aikuvshinov@mail.ru, http://script-ks.narod.ru" />
<link rel="stylesheet" type="text/css" href="<?=$bp?>style/style.css" />
<link rel="stylesheet" type="text/css" href="<?=$bp?>style/jquery.fancybox.css" media="screen" />

<script type="text/javascript" src="<?=$bp?>lib/flash.js"></script>
<script type="text/javascript" charset="utf-8" src="<?=$bp.'js/'?>jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?=$bp.'js/'?>jquery.easing.1.3.js"></script>
<script type="text/javascript" src="<?=$bp.'js/'?>jquery.fancybox-1.2.1.pack.js"></script>
<script type="text/javascript" src="<?=$bp.'js/'?>fancy.js"></script>
<script type="text/javascript">
$("#fancy_registr, #fancy_zabili, #fancy_vhod, #fancy_send_email, #fancy_zhaloba, #fancy_map, #fancy_mess, #fancy_vip1, #fancy_vip2, #fancy_vip3").live('click', function(){$(".fl_hidden").hide();});
$("#fancybox-close").live('click', function(){$(".fl_hidden").show();});
$("#fancybox-overlay").live('click', function(){$(".fl_hidden").show();});

		function scrollTo(el)
			{
			var duration = 700;
			var element = $(el).offset();
			var pos = element.top;
			$('html, body').animate({scrollTop: pos}, duration);
			}

		jQuery( function($) {
			$('tbody tr[data-href]').addClass('clickable').click( function() {
			window.location = $(this).attr('data-href');
			});
		});
</script>

<![if !IE]>
<?
if($rru['round'])
{
?>
<script type="text/javascript" src="<?=$bp.'js/'?>jquery.corner.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".imground").corner("round");
$(".submit").corner("round");
$(".str").corner("round");
});
</script>
<?
}
?>
<![endif]>

<?
if($tab_map==1) 
	{
	?>
<script src="http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script>
	<?
	}
	
if($tab_map==2) 
	{
	?>
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
	<script src="<?=$bp.'js/'?>markerclusterer.js" type="text/javascript"></script>
	<?
	}
	
?>

</head>
<BODY <?=$tab_mapp?> style="MARGIN: 0px auto; POSITION: inherit; width: 1000px">
<?
include_once($base_path."blok/top_form.php"); 
?>



<table width="100%" class="table">
	<tr>
		<td >
			<table width="100%">
				<tr>
					<td valign="top" class="td" width="90%">

					<?
					include_once($base_path."blok/search_form.php"); 
					?>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	
	<tr>
		<td align="center">
		<?
		_rec ($id_catalog, 1);
		?>
		</td>
	</tr>
	
	
	<tr>
		<td class="td" >
		<?
		if(!$_GET['id'])
		{
		if($tab_map)
		include_once($base_path."blok/tab_map.php"); 
		else
			{
			if($arr_catalog['tab'])
			include_once($base_path."blok/tab_tab.php"); 
			else
			include_once($base_path."blok/tab.php"); 
			}
		}
		?>
		
		
		</td>
	</tr>
	
	<tr>
		<td>
			<table width="100%" cellpadding="5" cellspacing="5">
				<tr>
					<td>
					<?
					include_once($base_path.'cashe_n/_map.php');
					?>
					<p>
					<?
					include_once($base_path."blok/bottom_form.php"); 
					?>
					</td>
					<td>

					</td>
				</tr>
			</table>
		</td>
	</tr>
	
</table>

</body>
</html>