The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
I suspect the OP was disguising and actual programming question, in hopes that you would eventually give him the answer. Which of course, you just did. You should at least get some points for coming up with the solution.