You should really use the entire file I posted; you left half of it out in your paste, and my code was not even remotely designed to be dropped into the middle of some other code. It's a total rewrite from scratch, not just a few changes here and there. If you're using code in your layout based on the example in the file I posted, of course you're going to get endless errors if you're not actually using the file I posted.