$(document).ready(function(){$('<div id="togglesearchformdiv"><a id="togglesearchformlink"></a></div>').insertAfter("#tbl_search_form").hide();$("#togglesearchformlink").html(PMA_messages.strShowSearchCriteria).bind("click",function(){var b=$(this);$("#tbl_search_form").slideToggle();b.text()==PMA_messages.strHideSearchCriteria?b.text(PMA_messages.strShowSearchCriteria):b.text(PMA_messages.strHideSearchCriteria);return false});$("#tbl_search_form.ajax").live("submit",function(b){$search_form=$(this);
b.preventDefault();$("#sqlqueryresults").empty();var c=PMA_ajaxShowMessage(PMA_messages.strSearching,false);PMA_prepareForAjaxRequest($search_form);var a={};$search_form.find(":input").each(function(){var e=$(this);if(e.attr("type")=="checkbox"||e.attr("type")=="radio"){if(e.is(":checked"))a[this.name]=e.val()}else a[this.name]=e.val()});b=$('select[name="param[]"] option').length;for(var d=0;d<b;d++)if(a["fields["+d+"]"]==""){delete a["fields["+d+"]"];delete a["func["+d+"]"];delete a["names["+d+
"]"];delete a["types["+d+"]"];delete a["collations["+d+"]"]}if(a["param[]"]!=null){if(a["param[]"].length==b){delete a["param[]"];a.displayAllColumns=true}}else a.displayAllColumns=true;$.post($search_form.attr("action"),a,function(e){PMA_ajaxRemoveMessage(c);if(typeof e=="string"){$("#sqlqueryresults").html(e);$("#sqlqueryresults").trigger("makegrid");$("#tbl_search_form").slideToggle().hide();$("#togglesearchformlink").text(PMA_messages.strShowSearchCriteria);$("#togglesearchformdiv").show();PMA_init_slider()}else{e.message!=
undefined&&$("#sqlqueryresults").html(e.message);e.error!=undefined&&$("#sqlqueryresults").html(e.error)}})});$(".open_search_gis_editor").hide();$(".geom_func").bind("change",function(){var b=$(this),c=["Contains","Crosses","Disjoint","Equals","Intersects","Overlaps","Touches","Within","MBRContains","MBRDisjoint","MBREquals","MBRIntersects","MBROverlaps","MBRTouches","MBRWithin","ST_Contains","ST_Crosses","ST_Disjoint","ST_Equals","ST_Intersects","ST_Overlaps","ST_Touches","ST_Within"],a=c.concat(["Envelope",
"EndPoint","StartPoint","ExteriorRing","Centroid","PointOnSurface"]),d=b.parents("tr").find("td:nth-child(5)").find("select");$.inArray(b.val(),c)>=0?d.attr("readonly",true):d.attr("readonly",false);c=b.parents("tr").find(".open_search_gis_editor");$.inArray(b.val(),a)>=0?c.show():c.hide()});$(".open_search_gis_editor").live("click",function(b){b.preventDefault();var c=$(this);b=c.parent("td").children("input[type='text']").val();var a=c.parents("tr").find(".geom_func").val();a=a=="Envelope"?"polygon":
a=="ExteriorRing"?"linestring":"point";c=c.parent("td").children("input[type='text']").attr("name");var d=$("input[name='token']").val();openGISEditor();gisEditorLoaded?loadGISEditor(b,"Parameter",a,c,d):loadJSAndGISEditor(b,"Parameter",a,c,d)})},"top.frame_content");
