there are many posts on this subject that i'm sure will help you out, try to use the forum search feature (it could be your best friend cool). also try doing a web search using google on the subject, cause there are a few ready made snippets around as well on other sites..