I wrote this snippet overnight as an attemp to help a guy in the coderanch forums.
Download Here
Hope you enjoyed it.
N.B : its in zip format, everything is in it.