Still a massive work in progress but you get the basic idea. I'll post the final version tomorrow if i can finish it in time.