function viewLarge(article_id, filename) {
	window.open(
	 '/content/large_image.php?article_id=' + article_id + '&filename=' + filename,
	 'ViewImage',
	 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');

	return true;
}

function enlargeImage(filename) {
	window.open(
	 '/content/large_image.php?filename=' + filename,
	 'ViewImage',
	 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no');

	return true;
}

function changeImage(nextimage) {
	// Hide current
	document.getElementById(ig[ig_current]).style.display = 'none';
	
	// Show next, change ig_current
	if ( nextimage ) { // Show next image
		ig_current = ig_current + 1;
	
		if ( ig_current == ig.length ) { // Last image in list
			ig_current = 0;
		}
	} else { // Show previous image
		ig_current = ig_current - 1;
		if ( ig_current < 0 ) { // First image in list
			ig_current = ig.length - 1;
		}
	}
	
	// Show new current
	document.getElementById(ig[ig_current]).style.display = 'block';
}

function checkForCaptionedThumbnails() {
	var articleObj;
	var thumbnailLinkObj;
	var divs;
	var tmpObjs

	if ( document.getElementById && document.getElementsByTagName && ( articleObj = document.getElementById("article") ) ) {

		divs = articleObj.getElementsByTagName("DIV");

		for (i=0; i < divs.length; i++) {
			if ( divs[i].className && divs[i].className.match(/article_content/) ) {
				tmpObjs = divs[i].getElementsByTagName("A");
				for ( j = 0; j < tmpObjs.length; j++ ) {
					if ( tmpObjs[j].className && tmpObjs[j].className.match(/main_image/) ) {
						tmpObjs[j].onclick = function() { return ! enlargeImage(this); }
					}
				}
			}

			if ( divs[i].className && divs[i].className.match(/captioned/) ) {
				tmpObjs = divs[i].getElementsByTagName("A");
				for ( j = 0; j < tmpObjs.length; j++ ) {
					tmpObjs[j].onclick = function() { return ! enlargeImage(this); }
				}
			}
		}
	}
}
addEvent(window, 'load', checkForCaptionedThumbnails);