This should actually be pretty easy to code. I can't give a solution off the top of my head but... If you can't find something usefull or figure it out, let me know, I'll give you some idea's on how it would work. Just note I won't give a fully working code.
|