Thanks for the great code. I have integrated this into the original snippet and have tweaked it a bit so you can set the functionality from the snippet call. Here is the link for full details:
http://modxcms.com/forums/index.php/topic,3501.msg33538.html#msg33538
Thanks,
Kyle