Thanks for that, but I'm not sure that solves my problem.
I don't have 4 separate gallery pages that I upload for each website, only two.
The 2 websites I have are both addon domains, that point to the same subdirectory of another website that I have.
So because I only have the two files that both websites work from for my gallery pages, I can't change that line
var GB_ROOT_DIR = "http://www.mysite.com/greybox/";
for the same gallery.
I hope you understand what I mean.
I guess an addon domain is a bit like a parked domain, in that they both point to the same folder and all the different domains point to the same files within that folder.
So for any of my gallery pages, there's only one page, not separate pages for each domain, so I can't change the code for each.
Any help would be appreciated.