Thank you mechsin -- this was just what I was looking for! I shared your answer also on Stack Overflow here:

http://stackoverflow.com/questions/1...31642#15231642