var ul = document.getElementsByTagName('ul');
for (var i = 0; i < ul.length; i++) {
	if (ul.item(i).className != 'photolinks')
		continue;
	var li = ul.item(i).getElementsByTagName('a');
	for (var j = 0; j < li.length; j++) {
		if (li.item(j).innerHTML == 'More Photos') {
			li.item(j).onclick = launchSlideshow;
		}
	}
}

function launchSlideshow(e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var url = targ.href.split('/');
	var plan = url[4];

	var winl = (screen.width - 320) / 2;
	var wint = (screen.height - 470) / 2;
	winprops = 'height=' + 470 + ',width=' + 320 + ',top=' + wint + ',left='
		+ winl + ',scrollbars=no,resizable';
	win = window.open('http://' + document.location.host + '/plans/' + plan + '/photos/popup/',
		'slideshow', winprops)
	win.window.focus();

	window.onunload = function() { win.close(); };

	return false;
}
