Ah, very interesting. So the double alert from JS in your infowindow HTML was a red herring. That alert was something you added to the test code you posted and isn't present in the actual site.
The real problem you're trying to troubleshoot is that you get six images in your lightbox instead of three. That could have the same underlying cause as the double alert - or not.
Do you know how to use Firebug? If not, go get it and learn enough of it to follow along...
Open your infowindow.js in Firebug's Script tab and scroll to this function:
function showInfoWindow() {
$.ajax({
url: 'content.html',
success: function(result) {
infowindow.setContent(result);
infowindow.open(map, marker);
$('a.lightbox').lightBox();
}
});
}
Set a breakpoint on this line:
$('a.lightbox').lightBox();
and click your marker. Your code will stop at the breakpoint.
Now go to the Console tab and enter this into the console input line (>>>):
$('a.lightbox').length
Yes, it's found six 'a.lightbox' elements in the DOM, not the three you expected. Or try it this way:
If you use Firebug's HTML tab you can find these elements in the DOM, inside a couple of DIVs listed just below your map_canvas DIV.
On a wild hunch - this is only a small step from cargo cult programming - I thought, "infowindow.setContent() accepts either HTML text or a DOM node. What if we give a DOM node instead?". So I ran this line of code in the Firebug console:
result = $('<div>').html(result)[0];
(If you added this to your code, it would be immediately above the infowindow.setContent() line.)
This creates a jQuery object with a single DIV - $('<div>') - then inserts the downloaded HTML into it - .html(result) - and then finally grabs the DIV's DOM node since we need that and not the jQuery object - the [0] at the end. So now result contains a single DOM node with the A elements a children, instead of HTML text.
Then I let execution continue (F8 on Windows or click the > button). Bingo - only three images in the lightbox.
I couldn't tell you that this is the right way to do it and the HTML text was the wrong way - in fact I'd be most curious to hear from anyone on the Maps team why it turned out this way. It was just a hunch that maybe the Maps API code would have to do less work - or at least *different* work - to process the DOM node and wouldn't end up duplicating it.
If you do this, you may as well include the <div> and </div> wrapper as part of the HTML text you download. Then the code would be simpler:
Or just do it in one line:
infowindow.setContent( $(result)[0] );
-Mike
p.s. If you're still curious about the double alert in the test version, that could have been something else entirely. When you use $.ajax() to download the HTML, jQuery searches through that downloaded code looking for <script> tags and executes them! At least it used to - I haven't checked it lately.