<?php
$tmp_ggl_now = 0;
if (isset($_POST['is_ggl_auto'])){
	if ($_POST['ggl_autofind_on'] == "on"){
		$tmp_ggl_now = 1;
	}
}else{
	if (isset($_GET['q'])){
		$tmp_ggl_now = 1;
	}
}
 ?>
<div id="div_12" class="pg10">
<table><tr><td class="btm">
<a href="galary.php?u=<?php echo $gal1rand; ?>"><img style="border:1px solid #FCCE92;" src="galary/litle/interier/<?php echo $gal1rand; ?>.jpg" alt="Интерьеры." /></a></td><td class="btm">
<a href="galary.php?u=<?php echo 1000 + $gal2rand; ?>"><img style="margin:0px 2px;border:1px solid #FCCE92;" src="galary/litle/fon/<?php echo intval(mysql_num_rows(mysql_query("select jobid from obd_8 where (jobid > 999) and (jobid < 2000)")) - 1); ?>.jpg" alt="Фон." /></a><a href="galary.php?u=<?php echo 2000 + $gal3rand; ?>"><img style="margin:0px 2px 0px 0px;border:1px solid #FCCE92;" src="galary/litle/other/<?php echo intval(mysql_num_rows(mysql_query("select jobid from obd_8 where (jobid > 1999) and (jobid < 3000)")) - 1); ?>.jpg" alt="Другое." /></a></td><td class="sm rgt mdl" style="padding:3px 5px;">
<?php
for($i=1;$i<=count($odirection);$i++){
	if ($odirection[$i][2] == 1){
		echo $odirection[$i][0] . ' <span class="bld">[</span> ' . mysql_num_rows(mysql_query("select directionid from obd_0 where directionid = " . $i)) . ' <span class="bld">]</span><br />';
	}
}
?>
</td><td class="sm pg10 rgt mdl" style="padding:3px;">
<?php
for($i=1;$i<=count($odirection);$i++){
	if ($odirection[$i][2] == 2){
		echo $odirection[$i][0] . ' <span class="bld">[</span> ' . mysql_num_rows(mysql_query("select directionid from obd_0 where directionid = " . $i)) . ' <span class="bld">]</span><br />';
	}
}
?>
</td><td class="sm pg10 rgt mdl" style="padding:3px;">
<?php
for($i=1;$i<=count($odirection);$i++){
	if ($odirection[$i][2] == 3){
		echo $odirection[$i][0] . ' <span class="bld">[</span> ' . mysql_num_rows(mysql_query("select directionid from obd_0 where directionid = " . $i)) . ' <span class="bld">]</span><br />';
	}
}
?></td></tr></table>
<FORM class="black_block sm" style="color:#FCCE92;font-size: smaller;" METHOD="POST" id="fchangedirect">
<select class="cinline" name="direct_job" onchange="javascript:document.getElementById('fchangedirect').submit();">
<option>Выберите направление</option>
<?php 
for($k=1;$k<=count($odirection);$k++){
?>
<option value="<?php echo $k; ?>" <?php if ($_POST['direct_job'] == $k) {echo "selected";} ?>><?php echo $odirection[$k][0]; ?></option>
<?php 
}
?>
</select>
<input class="cinline" size="60" maxlength="70" type="text" id="id_un" name="user_name" value="<?php if (isset($_POST['user_name'])) {echo $_POST['user_name'];}else{echo 'Введите часть названия проекта';} ?>" onchange="document.getElementById('fchangedirect').submit();" onmouseout="fInputOut(this)" onmouseover="fInputOver(this)" />
<input class="cinline" title="Сортировать результаты поиска по возрастанию" name="in_orderby" type="Checkbox" <?php if ($_POST['in_orderby'] == 'on'){echo " checked";} ?> onclick="javascript:document.getElementById('fchangedirect').submit();">&nbsp;По возрастанию</FORM>
<?php


if (isset($_POST['direct_job'])){


if (isset($_GET['tag'])){
	$query = "select obd_0.name, obd_0.desk, obd_0.jobid, obd_0.directionid, tblTag_0.p_tag from obd_0, tblTag_0 where tblTag_0.p_tag = " . $_GET['tag'] . " and tblTag_0.word_id = obd_0.jobid";
	if ($_POST['direct_job'] <> "Выберите направление"){
		$_POST['direct_job'] = intval($_POST['direct_job']);
		$query .= " and obd_0.directionid = " . $_POST['direct_job'];
	}
	if ($_POST['user_name'] <> "" and $_POST['user_name'] <> "Введите часть названия проекта"){
		finds5last_set($_GET['p'], $_POST['user_name']);
		$query = $query . " and (obd_0.name like '%" . addslashes($_POST['user_name']) . "%')";
	}
}else{
	$query = "select name, desk, jobid, directionid from obd_0 where 1=1";
	if ($_POST['direct_job'] <> "Выберите направление"){
		$_POST['direct_job'] = intval($_POST['direct_job']);
		$query .= " and directionid = " . $_POST['direct_job'];
	}
	if ($_POST['user_name'] <> "" and $_POST['user_name'] <> "Введите часть названия проекта"){
		finds5last_set($_GET['p'], $_POST['user_name']);
		$query = $query . " and (name like '%" . addslashes($_POST['user_name']) . "%')";
	}
}
$query = $query . "  ORDER BY jobid";
if ($_POST['in_orderby'] == 'on'){$query .= " asc";}else{$query .= " desc";}

//проверка лимита
$result = mysql_query($query);
$z = mysql_num_rows($result);
if (isset($_GET['l'])){$query .= " limit " .$_GET['l'] . "," . $cur_list_numb;}else{$query = $query . " limit 0," . $cur_list_numb;}
//echo $query;
$result = mysql_query($query);
$num_result = mysql_num_rows($result);
?>
<div class="black_block_c">
<?php
	if ($num_result){
	$bBoolJob = 0;
	for ($i=0; $i<$num_result; $i++){
		$row = mysql_fetch_array($result);
require "../find_project.php";
	}
	}else{
		if ($_POST['direct_job'] == 1){
			echo '<div class="p_block">&nbsp;</div><center>Все проекты, связанные с дизайном интерьеров, представлены в <a class="sm" href="galary.php?u=0">галерее</a>.<br /><br /></center>';
		}else{none_project();}
	}
?>
</div>
<?php
require "../find_project_res.php";
}
?>
<?php finds5last_get($_GET['p']); ?>
</div>