well, that might not work as listed, but it should certainly give you an option for handling it. My script works, but I wont copy/paste the whole thing here. There's at least a start to what you want (from a scripted POV - that doesnt mean it's not a valid suggestion).
ALSO, where I said
REST OF CODE HERE, you're suppose to insert your OWN custom handling/displaying code there
If you need more help, let me know