/*
	anikistit.net javascript image gallery - extented from alistapart's article
	lauri j
	v1.11 28.3.2007
*/

/*	get title from object, extract 3 character id, display rest, show loader and then full image
	tarttee toisen konstin, tää mähnää tooltipit */
function swapimage(x, target) {
	if (document.getElementById) {
		if (x.title) {
			var cid = "jscaption_";
			var gid = "jsgallery_";
			var caption_id = cid.concat(target);
			var gallery_id = gid.concat(target);

			document.getElementById(gallery_id).src = "/kuvat/loading.gif";

			preload = new Image();
			preload.onload = function () {
				document.getElementById(gallery_id).src = x.href;
			};
			/* src pitää laittaa event handlerin asettamisen jälkeen */
			preload.src = x.href;
			document.getElementById(caption_id).childNodes[0].nodeValue = x.title;
		}
		return false;
	} else {
		return true;
	}
}