// JavaScript Document

function initPopups() {
	// add an onclick event to every hyperlink with a class of 'popup'
	var els = document.getElementsByTagName("a");
	for(var i = 0; i < els.length; i++) {
		if (els[i].className.indexOf("popup") !=- 1) {
			els[i].onclick=popup;
		}
	}
}

function popup() {
	// load the popup image into a temporary Image structure
	// once its finished loading, open the window with the correct Image dimensions
	// pulled from the Image structure
	var img=new Image;
	img.src=this.href;
	img.onload=function() {
		var win=window.open(img.src, "popup", "width="+(img.width+16)+",height="+(img.height+16))
	};
	// prevent the hyperlink from doing its default behaviour
	return false; 
}

function imgSwap(imgid, imgsrc, shortd, linkid, linkref) {
	document.getElementById(imgid).src = imgsrc;
	document.getElementById(imgid).alt = shortd;
	document.getElementById(imgid).title = shortd;
	document.getElementById(linkid).href = linkref;
	document.getElementById(linkid).title = shortd;
}
