I can't effectively debug hand coded sections without direct access to the page for debugging.
I could debug this for you and get it working, but since the issue is with a hand coded and not supported section of your code I'd have to bill you for an hour of premier support in order to fix it ($100).
If you are interested you can just reply to this thread with FTP information and a URL to view the current page and I'll get it working.