// Include this file AFTER a set of popup links.

// Find all links with target="YMCAprogramPopup" and make them open in a Javascript popup.
// Find all links with target="parent" and make them open in the parent window.
function initPopupLinks() {
	for (var i=0; i < document.links.length; i++) {
		link = document.links[i];
		if (link.target == "YMCAprogramPopup")
			link.onclick = popup;
		if (link.target == "parent")
			link.onclick = parentLink;
	}
}

// Open the clicked link in a new window.
function popup() {
	window.open(this.href, "YMCAprogramPopup", "width=475,height=350,scrollbars=1,resizable=0");
	return false;
}

// parentLink: If possible, open this link in the window that opened this frameset.
// CLOSE this window afterwards.
function parentLink() {
	if (window.opener && !window.opener.closed) {
		window.opener.location = this.href;
		window.opener.focus();
		window.close();
		return false;
	}
	else {
		window.open(this.href, "_blank");
		window.close();
		return false;
	}
	return true;
}

initPopupLinks();
