<?
////////////// - tinytext- /////////////////
function field_func_search_1 ($d, $arr, $data)
{
}

//////////// - числовое - ///////////////////
function field_func_search_3 ($d, $arr, $data)
{
	$data[0]='';
	$data[1]=_chis($data[1], 'intval');
	$data[2]=_chis($data[2], 'intval');
	if($data[1]>0 && $data[2]>0 && $data[1]>$data[2]) {$tmp=$data[1]; $data[1]=$data[2]; $data[2]=$tmp;}
	if(!$data[1]) $datas1=''; else $datas1=$data[1];
	if(!$data[2]) $datas2=''; else $datas2=$data[2];

	if($d=='add')
	{
	$uf=explode("|", $arr['field_search']);
	?>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[1]">
			<option value="0" ><?=$uf[0]?></option>
		<?
		if($arr['field_d_1']<$arr['field_d_2'])
			{
			for($i=$arr['field_d_1']; $i<=$arr['field_d_2']; $i++)
				{
				?>
				<option value="<?=$i?>" <? if($data[1]==$i) echo 'selected'; ?> ><?=$i?></option>
				<?		
				}
			}
		else
			{
			for($i=$arr['field_d_1']; $i>=$arr['field_d_2']; $i--)
				{
				?>
				<option value="<?=$i?>" <? if($data[1]==$i) echo 'selected'; ?> ><?=$i?></option>
				<?		
				}
			}
		?>
		</select>
	</span>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[2]">
		<option value="0" ><?=$uf[1]?></option>
		<?
		if($arr['field_d_1']<$arr['field_d_2'])
			{
			for($i=$arr['field_d_1']; $i<=$arr['field_d_2']; $i++)
				{
				?>
				<option value="<?=$i?>" <? if($data[2]==$i) echo 'selected'; ?> ><?=$i?></option>
				<?		
				}
			}
		else
			{
			for($i=$arr['field_d_1']; $i>=$arr['field_d_2']; $i--)
				{
				?>
				<option value="<?=$i?>" <? if($data[2]==$i) echo 'selected'; ?> ><?=$i?></option>
				<?		
				}
			}
		?>
		</select>
	</span>
	<?
	}
	
	if($d=='prov')
	{
	if($data[1]!=$data[2])
		{
		if ($data[1]) 
		$data[0] .= ' AND '.$arr['field_field'].' >= '.$data[1].' ';
		if ($data[2]) 
		$data[0] .= ' AND '.$arr['field_field'].' <= '.$data[2].' ';
		}
	else
		{
		if ($data[1])
		$data[0] .= ' AND '.$arr['field_field'].' = '.$data[1].' ';
		}
	return $data;
	}
}
//////////// - цена - ///////////////////
function field_func_search_31 ($d, $arr, $data)
{
	$data[0]='';
	$data[1]=_chis($data[1], 'intval');
	$data[2]=_chis($data[2], 'intval');
	if($data[1]>0 && $data[2]>0 && $data[1]>$data[2]) {$tmp=$data[1]; $data[1]=$data[2]; $data[2]=$tmp;}
	if(!$data[1]) $datas1=''; else $datas1=$data[1];
	if(!$data[2]) $datas2=''; else $datas2=$data[2];

	if($d=='add' && $arr['field_intval_spis'])
	{
	$dia=explode(",",$arr['field_intval_spis']);
	$uf=explode("|", $arr['field_search']);
	?>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[1]">
		<option value="0" ><?=$uf[0]?></option>
		<?
		foreach ($dia as $di)
			{
			?>
			<option value="<?=$di?>" <? if($data[1]==$di) echo 'selected'; ?> ><?=_font($di, $arr['field_format'], $arr['field_font'], $arr['field_znak'])?></option>
			<?		
			}
		?>
		</select>
	</span>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[2]">
		<option value="0" ><?=$uf[1]?></option>
		<?
		foreach ($dia as $di)
			{
			?>
			<option value="<?=$di?>" <? if($data[2]==$di) echo 'selected'; ?> ><?=_font($di, $arr['field_format'], $arr['field_font'], $arr['field_znak'])?></option>
			<?		
			}
		?>
		</select>
	</span>
	<?
	}
	
	if($d=='prov')
	{
	if($data[1]!=$data[2])
		{
		if ($data[1]) 
		$data[0] .= ' AND '.$arr['field_field'].' >= '.$data[1].' ';
		if ($data[2]) 
		$data[0] .= ' AND '.$arr['field_field'].' <= '.$data[2].' ';
		}
	else
		{
		if ($data[1])
		$data[0] .= ' AND '.$arr['field_field'].' = '.$data[1].' ';
		}
	return $data;
	}
}

//////////// - Этаж - ///////////////////
function field_func_search_32 ($d, $arr, $data)
{
	$data[0]='';

	if($d=='add' && $arr['field_intval_spis'])
	{
	$dia=explode(",",$arr['field_intval_spis']);
	$uf=explode("|", $arr['field_search']);
	?>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[1]">
		<option value="0" ><?=$uf[0]?></option>
		<option value="1" <? if($data[1]==1) echo 'selected'; ?> >не первый</option>
		<option value="2" <? if($data[1]==2) echo 'selected'; ?> >не последний</option>
		<option value="3" <? if($data[1]==3) echo 'selected'; ?> >не первый и не последний</option>
		</select>
	</span>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[2]">
		<option value="0"><?=$uf[1]?></option>
		<?
		foreach ($dia as $di)
			{
			?>
			<option value="<?=$di?>" <? if($data[2]==$di) echo 'selected'; ?> ><?=$di?></option>
			<?		
			}
		?>
		</select>
	</span>
	<?
	}
	
	if($d=='prov')
	{
	if ($data[1]==1) 
	$data[0] .= ' AND '.$arr['field_field'].' != 1 ';
	elseif ($data[1]==2) 
	$data[0] .= ' AND '.$arr['field_field'].' < '.$arr['field_field_two'].' ';
	elseif ($data[1]==3) 
	$data[0] .= ' AND '.$arr['field_field'].' < '.$arr['field_field_two'].' AND '.$arr['field_field'].' != 1 ';
		
		
	if ($data[2]) 
		{
		if(strpos($data[2],"<") !==false)
			{
		 	$pp=explode("<", trim($data[2]));
			$data[0] .= ' AND '.$arr['field_field_two'].' < '.intval(trim($pp[1])).' ';
			}
		elseif(strpos($data[2],">") !==false)
			{
		 	$pp=explode(">", trim($data[2]));
			$data[0] .= ' AND '.$arr['field_field_two'].' > '.intval(trim($pp[1])).' ';
			}
		elseif(strpos($data[2],"-") !==false)
			{
		 	$pp=explode("-", trim($data[2]));
			$data[0] .= ' AND '.$arr['field_field_two'].' >= '.intval(trim($pp[0])).' AND '.$arr['field_field_two'].' <= '.intval(trim($pp[1])).' ';
			}
		}

	return $data;
	}
}


//////////// - числовой список - ///////////////////
function field_func_search_4 ($d, $arr, $data)
{
	$data[0]='';
	$data[1]=_chis($data[1], 'floatval');
	$data[2]=_chis($data[2], 'floatval');
	if($data[1]>0 && $data[2]>0 && $data[1]>$data[2]) {$tmp=$data[1]; $data[1]=$data[2]; $data[2]=$tmp;}
	if(!$data[1]) $datas1=''; else $datas1=$data[1];
	if(!$data[2]) $datas2=''; else $datas2=$data[2];

	if($d=='add' && $arr['field_intval_spis'])
	{
	$dia=explode(",",$arr['field_intval_spis']);
	$uf=explode("|", $arr['field_search']);
	?>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[1]">
		<option value="0" ><?=$uf[0]?></option>
		<?
		foreach ($dia as $di)
			{
			?>
			<option value="<?=$di?>" <? if($data[1]==$di) echo 'selected'; ?> ><?=_font($di, $arr['field_format'], $arr['field_font'], $arr['field_znak'])?></option>
			<?		
			}
		?>
		</select>
	</span>
	<span>
		<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[2]">
		<option value="0" ><?=$uf[1]?></option>
		<?
		foreach ($dia as $di)
			{
			?>
			<option value="<?=$di?>" <? if($data[2]==$di) echo 'selected'; ?> ><?=_font($di, $arr['field_format'], $arr['field_font'], $arr['field_znak'])?></option>
			<?		
			}
		?>
		</select>
	</span>
	<?
	}
	
	if($d=='prov')
	{
	if($data[1]!=$data[2])
		{
		if ($data[1]) 
		$data[0] .= ' AND '.$arr['field_field'].' >= '.$data[1].' ';
		if ($data[2]) 
		$data[0] .= ' AND '.$arr['field_field'].' <= '.$data[2].' ';
		}
	else
		{
		if ($data[1])
		$data[0] .= ' AND '.$arr['field_field'].' = '.$data[1].' ';
		}
	return $data;
	}
}
/////////////// - список - /////////////////
function field_func_search_5 ($d, $arr, $data)
{
	global $arr_element;
	global $arr_element_fon;
	global $arr_element_text;

	$data[0]='';
	$data[1]=intval($data[1]);

	if($d=='add')
	{
	?>
	<span>
		<select <? if($arr_element_fon[$arr['field_spisok']]) echo 'id="s_'.$arr['field_spisok'].'" onchange="func5(\'s_'.$arr['field_spisok'].'\');"'; ?> class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[1]">
			<option value="0" ><?=$arr['field_search']?></option>
			<?
			foreach($arr_element[$arr['field_spisok']] as $index=>$arr_el)
			{
			?>
			<option <? if($arr_element_fon[$arr['field_spisok']][$index]) echo 'style="background-color:'.$arr_element_fon[$arr['field_spisok']][$index].'; color:'.$arr_element_text[$arr['field_spisok']][$index].';"';?> value="<?=$index?>" <? if($index==$data[1]) echo 'selected'; ?>><?=$arr_el?></option>
			<?
			}
		?>
		</select>
	</span>
	<?
	}
	
	if($d=='prov')
	{
	if ($data[1]) $data[0] = " AND ".$arr['field_field']." = ".$data[1]." ";
	return $data;
	}
}
/////////////// - двойной список - /////////////////
function field_func_search_7 ($d, $arr, $data)
{
	global $arr_element;
	global $arr_element_two;
	$data[0]='';
	$data[1]=intval($data[1]);
	$data[3]=$arr['id_field'];

	if($d=='add')
	{
	$uf=explode("|", $arr['field_search']);
	?>
	<span>
	<select  class="search_se" style="width: 150px" name="<?=$arr['field_field']?>[1]" onChange="send_element_two(this.value, <?=$arr['id_field']?>, <?=$arr['field_spisok']?>, '<?=$arr['field_field']?>', '<?=urlencode(trim($uf[1]))?>')">
		<option value="0" ><?=$uf[0]?></option>
		<?
		foreach($arr_element[$arr['field_spisok']] as $index=>$arr_el)
			{
			?>
			<option value="<?=$index?>" <? if($index==$data[1]) echo 'selected'; ?>><?=$arr_el?></option>
			<?
			}
		?>
	</select>
	</span>
	<?
	
	if($arr_element_two[$data[1]])	
		{
			$data[2]=intval($data[2]);
			$sel_element='<select  class="search_se" style="width: 150px" name="'.$arr['field_field'].'[2]">';
			$sel_element .='<option value="0">'.$uf[1].'</option>';
	
			foreach($arr_element_two[$data[1]] as $ind=>$el)
				{
				$sel_element .= '<option value='.$ind;
				if($ind==$data[2]) 
				$sel_element .= ' selected '; 
				$sel_element .= '>'.$el.'</option>'; 
				}
			$sel_element .='</select>';
		} 
		else 
		{
		$sel_element='';
		}
	
	?>
	<span id="www<?=$arr['id_field']?>"><? echo $sel_element; ?></span>
	<?
	}
	
	if($d=='prov')
	{
	if ($data[1]) $data[0] = " AND ".$arr['field_field']." = ".$data[1]." ";
	if ($data[2]) $data[0] = " AND ".$arr['field_field_two']." = ".$data[2]." ";
	return $data;
	}
}

////////////// - URL- /////////////////
function field_func_search_9 ($d, $arr, $data)
{
}

?>