You can see my shell configs for more details, e.g. the getcommand function which handles commands like fg in a nicer way.

raising the xterm that has a bash prompt otherwise starting a new one

Write a script that uses wmctrl -l to list windows, looking for one with bash in the title. If one is found, then run wmctrl -i -a <id returned by wmctrl -l> to raise it, else just call xterm.

Here is a script that does it:

#!/bin/bash
#
# bashprompt
#
# if there is an xterm open at a bash prompt, raise/focus that window
# if there isn't start a new xterm
#
# requires that your xterm window title has "bash" at the end
# when there is no command running and doesn't have "bash" at the end
# when a command is running
#
# see <http://unix.stackexchange.com/questions/6842> for more details
#
# Mikel Ward <mikel@mikelward.com>
# change this to whatever is unique about your window title
# (i.e. a string that appears in the title when the shell is at a prompt
# but does not appear when running a command)
prompttitle="bash$"
terminalprog="xterm"
if ! type wmctrl >/dev/null 2>&1; then
echo "wmctrl can't be found, please install it" 1>&2
exit 1
fi
if ! output="$(wmctrl -l)"; then
echo "Error running wmctrl -l" 1>&2
exit 1
fi
while IFS=$'\n' read -r line; do
if [[ $line =~ $prompttitle ]]; then
id=${line%% *}
break
fi
done <<EOF
$output
EOF
if test -n "$id"; then
wmctrl -i -a "$id"
else
"$terminalprog"&
fi

(translates to: on press windows-key + r: check, if there is a xterm with its title ending in 'bash'. if there is, go to that window; if not, open a new one. With a bleeding edge version (git) you can even go to windows on a different workspace.

The only thing you have to do is to modify the title (or any other property of the window carrying the bash) depending on what you do. if you look at the prompt you have to set a property, if you launch a command, you have to take away that property. fluxbox is not able to look inside the applications, it only knows about the windows.