I'm wondering where did the OP pinched this piece of code from?

It's generally pretty well structured one although not very useful.

cheers,
</wqw>