funny you should mention that, andrew, I just wrote that code. like phynias says, it's javascirpt, and somewhat hairy js at that. try searching some of the js archives online and you'll find examples of making one menu change another, which is a good starting point.
best
eric