csináltam ennél szofisztikáltabbat, ajánlom a figyelmetekbe
http://forum.index.hu/Article/showArticle?t=9195090