this snippet from ms.org echos your code.. with a few modifications, it could work for your needs.

link


------
deep down, i'm really superficial.