+ ' "$w_refuri"
+}
+
+w_advsearch(){
+ local n lbid tag category tn filter f
+ filter="${FILTER}^"
+
+ printf '[form #advsearch action=?a=advsearch method=POST
+ [a href="#" Hide]
+ [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br]
+ Refine the search further by setting additional search tags using the [strong "+and"] button.]
+ [hidden "ref" "%s"]
+ ' "$w_refuri"
+
+ for n in 1 2 3 4 5 6 7 8 9 10; do
+ f="${filter%%^*}"; filter="${filter#*^}"
+
+ lbid="$(HTML "cat_${n}_(none)")"
+ printf '[input .and type=checkbox name=and id="and_%i" %s][label for="and_%i" +and
+ ][fieldset .select
+ [input .pol type="radio" name=pol_%i %s id="pol_pos_%i"][label for=pol_pos_%i Any]
+ [input .pol type="radio" name=pol_%i %s id="pol_neg_%i"][label for=pol_neg_%i None]
+ [label .head Category:]
+ [input .cat type=radio name="cat_%i" %s id="%s" ][label for="%s" %s]
+ [select name=tag_%s size=10 multiple="multiple"' \
+ $n "$([ "$f" ] && printf 'checked="checked"')" $n \
+ $n "$([ "$f" -a \! "${f%%~*}" ] || printf 'checked="checked"')" $n $n \
+ $n "$([ "$f" -a \! "${f%%~*}" ] && printf 'checked="checked"')" $n $n \
+ $n "$([ "$f" = "${f%:*}" ] && printf 'checked="checked"')" "$lbid" "$lbid" "(none)" \
+ $n
+
+ f="|${f#~}|"
+ printf %s "$w_tags" |grep -vF ":" \
+ | while read -r tag; do
+ [ ! "$tag" ] && continue
+ tg="$(HTML "$tag")"
+ printf '[option %s value="%s" %s]' \
+ "$([ "$f" != "${f%|${tag}|*}" ] && printf 'selected="selected"')" \
+ "$tg" "$tg"
+ done
+ printf ']'
+ printf %s "$w_tags" |cut -sd: -f1 |sort -u \
+ | while read -r category; do
+ lbid="$(HTML "cat_${n}_${category}")"
+ printf '[input .cat type=radio name="cat_%i" %s id="%s"][label for="%s" %s]
+ [select name=tag_%s size=10 multiple="multiple"' \
+ $n "$([ "$f" != "${f%|${category}:*}" ] && printf 'checked="checked"')" \
+ "$lbid" "$lbid" "$(HTML "$category")" $n
+ printf %s "$w_tags" |grep -wF "${category}" \
+ | while read -r tag; do
+ tg="$(HTML "$tag")"; tn="${tg#*:}"
+ printf '[option %s value="%s" %s]' \
+ "$([ "$f" != "${f%|${tag}|*}" ] && printf 'selected="selected"')" \
+ "$tg" "$tn"
+ done
+ printf ']'
+ done
+ printf ']'
+ done
+
+ printf ']'