fires when the user changes the state of a two-state button item
myToolbar.attachEvent("onStateChange", function(id, state){ //your code here });