I use version verison 5.1 with an enterprise license.
Unfortunally, our development environment isn't possible to expose public.
I can reproduce the problem with a simple project. It is the first line in our common javascript file, which setting document.domain to our domain. The problem is that we are needing this in other pages.
I thought the solution should be to set document.domain in the template.aspx, but it wasn't :-(