Thanks for your help, that script tag was indeed the issue. I've removed it and it seems to run fine now.