Variant spelling functionality working
I've implemented the variant spelling functionality. If you click on a variant spelling (either in the gazetteer or in the "List variant names and spellings" bit at the top of a location document), you'll see a popup with a list of documents which use that spelling. You can then click on the link to one of those documents to see it with only that spelling variant highlighted. That should help with proofing quite a lot.
One drawback is that the vast majority of spelling variants show up only in Stow, which is not published. Initially, I was hiding links to documents which are not published, but that meant that the majority of variant spellings seemed to be attested nowhere, so I've compromised by linking to them, but when you click you'll see the usual message for a document that's not published. Project members will be able to see those documents if the need to, of course.
I don't yet have a clear idea how we're going to handle the issue of large documents which can't be displayed all at once (like Stow); I think the best bet would be to divert the link to a pre-configured search which shows all the instances of that spelling for that name, each as a link to the particular page that it's on.
This was quite messy to implement; I think the JavaScript has grown to a point where it could do with some refactoring, since there are many functions doing quite similar things, and a lot of the XQuery would benefit from much better inline comments, as would general.xsl.