<?php 
ini_set("display_errors","1");
ini_set("display_startup_errors","1");
set_magic_quotes_runtime(0);

include("include/dbcommon.php");
include("include/pf_camara_variables.php");


//connect database
$conn = db_connect();

include('libs/Smarty.class.php');
$smarty = new Smarty();


$includes=
"<STYLE>
	.vis1	{ visibility:\"visible\" }
	.vis2	{ visibility:\"hidden\" }
</STYLE>
<script language=\"JavaScript\" src=\"include/calendar.js\"></script>
<script language=\"JavaScript\" src=\"include/jsfunctions.js\"></script>\r\n";
if ($useAJAX) {
$includes.="<script language=\"JavaScript\" src=\"include/jquery.js\"></script>
<script language=\"JavaScript\" src=\"include/ajaxsuggest.js\"></script>\r\n";
}
$includes.="<script language=\"JavaScript\" type=\"text/javascript\">\r\n".
"var locale_dateformat = ".$locale_info["LOCALE_IDATE"].";\r\n".
"var locale_datedelimiter = \"".$locale_info["LOCALE_SDATE"]."\";\r\n".
"var bLoading=false;\r\n".
"var TEXT_PLEASE_SELECT='".addslashes("Por favor seleccione")."';\r\n";
if ($useAJAX) {
$includes.="var SUGGEST_TABLE = \"pf_camara_searchsuggest.php\";\r\n".
"var SUGGEST_LOOKUP_TABLE='pf_camara_lookupsuggest.php';\r\n".
"var AUTOCOMPLETE_TABLE=\"pf_camara_autocomplete.php\";\r\n";
}
$includes.="var detect = navigator.userAgent.toLowerCase();

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function ShowHideControls()
{
	document.getElementById('second_id_camara').style.display =  
		document.forms.editform.elements['asearchopt_id_camara'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_nombre_camara').style.display =  
		document.forms.editform.elements['asearchopt_nombre_camara'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_estado_actual').style.display =  
		document.forms.editform.elements['asearchopt_estado_actual'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_tipo_camara').style.display =  
		document.forms.editform.elements['asearchopt_tipo_camara'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_proceso_actual').style.display =  
		document.forms.editform.elements['asearchopt_proceso_actual'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_posicion_puerta').style.display =  
		document.forms.editform.elements['asearchopt_posicion_puerta'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_x').style.display =  
		document.forms.editform.elements['asearchopt_x'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_y').style.display =  
		document.forms.editform.elements['asearchopt_y'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_w').style.display =  
		document.forms.editform.elements['asearchopt_w'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_h').style.display =  
		document.forms.editform.elements['asearchopt_h'].value==\"Between\" ? '' : 'none'; 
	document.getElementById('second_maxpallet').style.display =  
		document.forms.editform.elements['asearchopt_maxpallet'].value==\"Between\" ? '' : 'none'; 
	return false;
}
function ResetControls()
{
	var i;
	e = document.forms[0].elements; 
	for (i=0;i<e.length;i++) 
	{
		if (e[i].name!='type' && e[i].className!='button' && e[i].type!='hidden')
		{
			if(e[i].type=='select-one')
				e[i].selectedIndex=0;
			else if(e[i].type=='select-multiple')
			{
				var j;
				for(j=0;j<e[i].options.length;j++)
					e[i].options[j].selected=false;
			}
			else if(e[i].type=='checkbox' || e[i].type=='radio')
				e[i].checked=false;
			else 
				e[i].value = ''; 
		}
		else if(e[i].name.substr(0,6)=='value_' && e[i].type=='hidden')
			e[i].value = ''; 
	}
	ShowHideControls();	
	return false;
}";

if ($useAJAX) {
$includes.="
$(document).ready(function() {
	document.forms.editform.value_id_camara.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_id_camara,'advanced')};
	document.forms.editform.value1_id_camara.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_id_camara,'advanced1')};
	document.forms.editform.value_id_camara.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_id_camara,'advanced')};
	document.forms.editform.value1_id_camara.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_id_camara,'advanced1')};
	document.forms.editform.value_nombre_camara.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_nombre_camara,'advanced')};
	document.forms.editform.value1_nombre_camara.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_nombre_camara,'advanced1')};
	document.forms.editform.value_nombre_camara.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_nombre_camara,'advanced')};
	document.forms.editform.value1_nombre_camara.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_nombre_camara,'advanced1')};
	document.forms.editform.value_estado_actual.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_estado_actual,'advanced')};
	document.forms.editform.value1_estado_actual.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_estado_actual,'advanced1')};
	document.forms.editform.value_estado_actual.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_estado_actual,'advanced')};
	document.forms.editform.value1_estado_actual.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_estado_actual,'advanced1')};
	document.forms.editform.value_tipo_camara.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_tipo_camara,'advanced')};
	document.forms.editform.value1_tipo_camara.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_tipo_camara,'advanced1')};
	document.forms.editform.value_tipo_camara.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_tipo_camara,'advanced')};
	document.forms.editform.value1_tipo_camara.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_tipo_camara,'advanced1')};
	document.forms.editform.value_proceso_actual.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_proceso_actual,'advanced')};
	document.forms.editform.value1_proceso_actual.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_proceso_actual,'advanced1')};
	document.forms.editform.value_proceso_actual.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_proceso_actual,'advanced')};
	document.forms.editform.value1_proceso_actual.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_proceso_actual,'advanced1')};
	document.forms.editform.value_posicion_puerta.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_posicion_puerta,'advanced')};
	document.forms.editform.value1_posicion_puerta.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_posicion_puerta,'advanced1')};
	document.forms.editform.value_posicion_puerta.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_posicion_puerta,'advanced')};
	document.forms.editform.value1_posicion_puerta.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_posicion_puerta,'advanced1')};
	document.forms.editform.value_x.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_x,'advanced')};
	document.forms.editform.value1_x.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_x,'advanced1')};
	document.forms.editform.value_x.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_x,'advanced')};
	document.forms.editform.value1_x.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_x,'advanced1')};
	document.forms.editform.value_y.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_y,'advanced')};
	document.forms.editform.value1_y.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_y,'advanced1')};
	document.forms.editform.value_y.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_y,'advanced')};
	document.forms.editform.value1_y.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_y,'advanced1')};
	document.forms.editform.value_w.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_w,'advanced')};
	document.forms.editform.value1_w.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_w,'advanced1')};
	document.forms.editform.value_w.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_w,'advanced')};
	document.forms.editform.value1_w.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_w,'advanced1')};
	document.forms.editform.value_h.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_h,'advanced')};
	document.forms.editform.value1_h.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_h,'advanced1')};
	document.forms.editform.value_h.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_h,'advanced')};
	document.forms.editform.value1_h.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_h,'advanced1')};
	document.forms.editform.value_maxpallet.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value_maxpallet,'advanced')};
	document.forms.editform.value1_maxpallet.onkeyup=function(event) {searchSuggest(event,document.forms.editform.value1_maxpallet,'advanced1')};
	document.forms.editform.value_maxpallet.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value_maxpallet,'advanced')};
	document.forms.editform.value1_maxpallet.onkeydown=function(event) {return listenEvent(event,document.forms.editform.value1_maxpallet,'advanced1')};
});
</script>
<div id=\"search_suggest\"></div>
";
} else {
$includes.="
function OnKeyDown(e)
{ if(!e) e = window.event; 
if (e.keyCode == 13){ e.cancel = true; document.forms[0].submit();} }

</script>";
}

$smarty->assign("includes",$includes);
$smarty->assign("noAJAX",!$useAJAX);

$onload="onLoad=\"javascript: ShowHideControls();\"";
$smarty->assign("onload",$onload);

if(@$_SESSION[$strTableName."_asearchtype"]=="or")
{
	$smarty->assign("any_checked"," checked");
	$smarty->assign("all_checked","");
}
else
{
	$smarty->assign("any_checked","");
	$smarty->assign("all_checked"," checked");
}

$editformats=array();

// id_camara 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["id_camara"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["id_camara"];
	$smarty->assign("value_id_camara",@$_SESSION[$strTableName."_asearchfor"]["id_camara"]);
	$smarty->assign("value1_id_camara",@$_SESSION[$strTableName."_asearchfor2"]["id_camara"]);
}	
if($not)
	$smarty->assign("not_id_camara"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_id_camara\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_id_camara",$searchtype);
//	edit format
$editformats["id_camara"]="Text field";
// nombre_camara 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["nombre_camara"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["nombre_camara"];
	$smarty->assign("value_nombre_camara",@$_SESSION[$strTableName."_asearchfor"]["nombre_camara"]);
	$smarty->assign("value1_nombre_camara",@$_SESSION[$strTableName."_asearchfor2"]["nombre_camara"]);
}	
if($not)
	$smarty->assign("not_nombre_camara"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_nombre_camara\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_nombre_camara",$searchtype);
//	edit format
$editformats["nombre_camara"]="Text field";
// estado_actual 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["estado_actual"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["estado_actual"];
	$smarty->assign("value_estado_actual",@$_SESSION[$strTableName."_asearchfor"]["estado_actual"]);
	$smarty->assign("value1_estado_actual",@$_SESSION[$strTableName."_asearchfor2"]["estado_actual"]);
}	
if($not)
	$smarty->assign("not_estado_actual"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_estado_actual\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_estado_actual",$searchtype);
//	edit format
$editformats["estado_actual"]="Text field";
// tipo_camara 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["tipo_camara"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["tipo_camara"];
	$smarty->assign("value_tipo_camara",@$_SESSION[$strTableName."_asearchfor"]["tipo_camara"]);
	$smarty->assign("value1_tipo_camara",@$_SESSION[$strTableName."_asearchfor2"]["tipo_camara"]);
}	
if($not)
	$smarty->assign("not_tipo_camara"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_tipo_camara\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_tipo_camara",$searchtype);
//	edit format
$editformats["tipo_camara"]="Text field";
// proceso_actual 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["proceso_actual"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["proceso_actual"];
	$smarty->assign("value_proceso_actual",@$_SESSION[$strTableName."_asearchfor"]["proceso_actual"]);
	$smarty->assign("value1_proceso_actual",@$_SESSION[$strTableName."_asearchfor2"]["proceso_actual"]);
}	
if($not)
	$smarty->assign("not_proceso_actual"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_proceso_actual\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_proceso_actual",$searchtype);
//	edit format
$editformats["proceso_actual"]="Text field";
// posicion_puerta 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["posicion_puerta"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["posicion_puerta"];
	$smarty->assign("value_posicion_puerta",@$_SESSION[$strTableName."_asearchfor"]["posicion_puerta"]);
	$smarty->assign("value1_posicion_puerta",@$_SESSION[$strTableName."_asearchfor2"]["posicion_puerta"]);
}	
if($not)
	$smarty->assign("not_posicion_puerta"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_posicion_puerta\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_posicion_puerta",$searchtype);
//	edit format
$editformats["posicion_puerta"]="Text field";
// x 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["x"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["x"];
	$smarty->assign("value_x",@$_SESSION[$strTableName."_asearchfor"]["x"]);
	$smarty->assign("value1_x",@$_SESSION[$strTableName."_asearchfor2"]["x"]);
}	
if($not)
	$smarty->assign("not_x"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_x\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_x",$searchtype);
//	edit format
$editformats["x"]="Text field";
// y 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["y"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["y"];
	$smarty->assign("value_y",@$_SESSION[$strTableName."_asearchfor"]["y"]);
	$smarty->assign("value1_y",@$_SESSION[$strTableName."_asearchfor2"]["y"]);
}	
if($not)
	$smarty->assign("not_y"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_y\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_y",$searchtype);
//	edit format
$editformats["y"]="Text field";
// w 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["w"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["w"];
	$smarty->assign("value_w",@$_SESSION[$strTableName."_asearchfor"]["w"]);
	$smarty->assign("value1_w",@$_SESSION[$strTableName."_asearchfor2"]["w"]);
}	
if($not)
	$smarty->assign("not_w"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_w\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_w",$searchtype);
//	edit format
$editformats["w"]="Text field";
// h 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["h"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["h"];
	$smarty->assign("value_h",@$_SESSION[$strTableName."_asearchfor"]["h"]);
	$smarty->assign("value1_h",@$_SESSION[$strTableName."_asearchfor2"]["h"]);
}	
if($not)
	$smarty->assign("not_h"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_h\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_h",$searchtype);
//	edit format
$editformats["h"]="Text field";
// maxpallet 
$opt="";
$not=false;
if(@$_SESSION[$strTableName."_search"]==2)
{
	$opt=@$_SESSION[$strTableName."_asearchopt"]["maxpallet"];
	$not=@$_SESSION[$strTableName."_asearchnot"]["maxpallet"];
	$smarty->assign("value_maxpallet",@$_SESSION[$strTableName."_asearchfor"]["maxpallet"]);
	$smarty->assign("value1_maxpallet",@$_SESSION[$strTableName."_asearchfor2"]["maxpallet"]);
}	
if($not)
	$smarty->assign("not_maxpallet"," checked");
//	write search options
$options="";
$options.="<OPTION VALUE=\"Contains\" ".(($opt=="Contains")?"selected":"").">"."Contiene"."</option>";
$options.="<OPTION VALUE=\"Equals\" ".(($opt=="Equals")?"selected":"").">"."Equivale"."</option>";
$options.="<OPTION VALUE=\"Starts with ...\" ".(($opt=="Starts with ...")?"selected":"").">"."Empieza con"."</option>";
$options.="<OPTION VALUE=\"More than ...\" ".(($opt=="More than ...")?"selected":"").">"."Más que"."</option>";
$options.="<OPTION VALUE=\"Less than ...\" ".(($opt=="Less than ...")?"selected":"").">"."Menos que"."</option>";
$options.="<OPTION VALUE=\"Equal or more than ...\" ".(($opt=="Equal or more than ...")?"selected":"").">"."Igual o más"."</option>";
$options.="<OPTION VALUE=\"Equal or less than ...\" ".(($opt=="Equal or less than ...")?"selected":"").">"."Igual o menos"."</option>";
$options.="<OPTION VALUE=\"Between\" ".(($opt=="Between")?"selected":"").">"."Entre"."</option>";
$options.="<OPTION VALUE=\"Empty\" ".(($opt=="Empty")?"selected":"").">"."Vacio"."</option>";
$searchtype = "<SELECT ID=\"SearchOption\" NAME=\"asearchopt_maxpallet\" SIZE=1 onChange=\"return ShowHideControls();\">";
$searchtype .= $options;
$searchtype .= "</SELECT>";
$smarty->assign("searchtype_maxpallet",$searchtype);
//	edit format
$editformats["maxpallet"]="Text field";

$linkdata="";

if ($useAJAX) {
	$linkdata .= "<script type=\"text/javascript\">\r\n";
	$linkdata .= "$(document).ready(function(){ \r\n";
	$linkdata .= "
function loadSelectContent(txt, selectControl, selectValue) 
{
	$('#'+selectControl).get(0).options[0]=new Option(TEXT_PLEASE_SELECT,'');
	var str = txt.split('\\n');
	var index = 0;
	for(i=0,j=0; i < str.length - 1; i=i+2, j++) {
		$('#'+selectControl).get(0).options[j+1]=new Option(unescape(str[i+1]),unescape(str[i]));
		if ( unescape(str[i]) == selectValue ) {index = j+1;}
	}
	$('#'+selectControl).get(0).selectedIndex = index;
}"."\r\n";
	$linkdata .= "});\r\n";
	$linkdata .= "</script>\r\n";
} else {
}

$smarty->assign("linkdata",$linkdata);

$templatefile = "pf_camara_search.htm";
if(function_exists("BeforeShowSearch"))
	BeforeShowSearch($smarty,$templatefile);

$smarty->display($templatefile);

?>