+. "$_EXEC/db_meta.sh"
+. "$_EXEC/cgilite/session.sh" nocookie
+. "$_EXEC/widgets.sh"
+
+# newtags='' # tags selected in ui
+# tags='' # taglist from database
+# detag='' # temporary remove list
+# extags='' # exclusive tags, tags that preclude others within their categorie
+# group='' # id for grouping videos (videos in a group get a common group id)
+# op='' # operation: add | del | flip
+
+newtags=''
+for tn in $(seq 1 $(POST_COUNT tag)); do
+ newtags="$(POST tag $tn)${BR}${newtags}"
+done
+newtags="$(POST newtag |tr -d '\r' |tr , '\n')${BR}${newtags}"
+
+if [ "$(POST makegroup)" = true ]; then
+ group="$(timeid)"
+fi
+
+# strip leading and trailing line breaks
+while [ "${newtags#${BR}}" != "${newtags}" ]; do newtags="${newtags#${BR}}"; done
+while [ "${newtags%${BR}}" != "${newtags}" ]; do newtags="${newtags%${BR}}"; done
+
+op="$(POST op)"