You could create two different
commands, then have each command call the appropriate JS function.
Then have these commands attached to a single button via advanced
actions.
Add two action groups, one to fire the first command, another to
fire the next.
Then each time the button is pressed, it would fire a different
command.
Otherwise, you could use JS to send a command depending on the
state of the button, eg:
CF.getJoin("d10", function(j,v) {
if (v == "1") {
// call JS function1
} else {
// call JS function2
}
});