Although it may no handle everything you want (as I wrote it a long time ago and haven't doen muh with it) looking at te code shoul help you to determine what you may need to change to get what you want.
http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=268