<ensure variable="get.q" value="">
<var get.q = trim(get.q)>
<var C = GLOBAL.Def.Style.color>
<var _result_count = 0>
<var Filters = ArrayNew(1)>
<loop collection="#get#" item="x">
<if listFirst(x,"_") EQ "ft">
<var _filter_tbl = replaceNoCase(x,"ft_","")>
<var _filter_list = get[x]>
<loop list="#_filter_list#" index="xx">
<var xx = trim(xx)>
<if trim(xx) NEQ "">
<var Obj = StructNew()>
<var Obj.tbl = _filter_tbl>
<var Obj.val = xx>
<var Filters[arrayLen(Filters)+1] = Obj>
</if>
</loop>
</if>
</loop>
<var Results = QueryNew('id')>
<if get.q NEQ "" OR arrayLen(Filters) GT 0>
<var _where = "(user.balloon <> '' AND user.balloon IS NOT null)">
<if get.q NEQ "">
<var _where = _where & " AND user.name LIKE ('%#escapeSingleQuotes(get.q)#%')">
</if>
<if arrayLen(Filters) GT 0>
<loop from="1" to="#arrayLen(Filters)#" index="x">
<var Obj = Filters[x]>
<var _where = _where & " AND user.affiliations LIKE ('%""val"":""#escapeSingleQuotes(Obj.val)#"",""tbl"":""#Obj.tbl#""%')">
</loop>
</if>
<set orb="user" select="user.id,user.balloon,user.name" where="#_where#" maxrows="100">
<var Results = set>
<var _result_count = set.recordcount>
</set>
</if>
<var _pw = 42>
<if _result_count EQ 0>
<form method="get" enctype="application/x-www-form-urlencoded">
<input type="hidden" style="display:none;" name="x" value="">
<div>
<div>
<small><small><div style="padding-bottom:3px;">
Person's Name:
</div></small></small>
<div style="margin-left:1em;">
<input name="q" value="#escapeDoubleQuotes(escapeMarkup(get.q))#" class="<if get.q EQ ''>select_this</if>" autocomplete="off">
</div>
</div>
<tag.bn_affiliations function="search_filters">
<div> </div>
<div align="left" class="pagebtn" style="margin-right:2em;">
<input type="submit" class="submit" style="cursor:pointer;" value="Search Balloon">
</div>
</div>
</form>
<div style="clear:both;"> </div>
</if>
<if _result_count EQ 0 AND ( get.q NEQ "" OR arrayLen(Filters) GT 0 )>
<div style="margin-left:#_pw+11#px;">
<p>
No results. Please try your search again.
</p>
</div>
</if>
<if _result_count GT 0>
<div>
<div>
<h3 style="margin:0px; margin-bottom:0.2em;">
<if _result_count EQ 1>
One result
<else>
#numberFormat(_result_count)# results
</if>
</h3>
<div style="padding:2px;">
<small><small>
<if get.q NEQ "">
<div>
<div style="padding-bottom:2px;">
Search Term:
</div>
<div style="margin-left:1em; padding-bottom:5px;">
<b>#escapeMarkup(get.q)#</b>
</div>
</div>
</if>
<if arrayLen(Filters) GT 0>
<div>
<div style="padding-bottom:2px;">
Searching Within...
</div>
<div style="margin-left:1em; padding-bottom:5px;">
<loop from="1" to="#arrayLen(Filters)#" index="x">
<var Obj = Filters[x]>
<div>• #escapeMarkup(Obj.val)#</div>
</loop>
</div>
</div>
</if>
</small></small>
</div>
</div>
<div> </div>
<div>
<var _upw = 32>
<loop query="Results">
<var _name = "/user-#Results.id#">
<if Results.name NEQ "">
<var _name = escapeMarkup(Results.name)>
</if>
<var _balloon = Results.balloon>
<var _color = "blue">
<if listLen(Results.balloon,'/') EQ 2>
<var _balloon = listFirst(Results.balloon,'/')>
<var _color = listLast(Results.balloon,'/')>
</if>
<var _href = "http://#this_domain#/#Results.id#">
<a class="buttonish buttonish_small" href="#_href#" style="clear:both; display:block; color:#C.text#;">
<div style="float:left; width:#_upw#px; padding-bottom:3px;">
<tag.balloon picwidth="#_upw#"
bg="#_balloon#" color="#_color#">
</div>
<div style="margin-left:#_upw+8#px; padding-bottom:3px;">
<b>#_name#</b>
</div>
<small><small><small><small><div style="clear:both; height:1px;"> </div></small></small></small></small>
</a>
<small><small><div style="clear:both;"> </div></small></small>
</loop>
<small><small><small><small><div style="clear:both;"> </div></small></small></small></small>
</div>
<div style="clear:both;"> </div>
<tag.bn_btn val="Search Again" slash="people" style="margin-right:0.5em;">
</div>
</if>