Have you looked into this?
http://www.kirupa.com/forum/showthread.php?p=2336246

Been playing with it and it may be simpler to start with this.