This sounds EXACTLY like something I made a while ago. Feel free to use it as inspiration. You should remake it from scratch though, so you know the code and can edit it as you like.
EDIT: Just to be clear "use it as inspiration" means open it up and look at the code
