function resizeImages() {
  var imageMaxWidth = 440;
  var imageMaxHeight = 340;
  
	for (var i = 0; i < document.images.length ;i++){
		if (document.images[i].src.match('/_data/')) {
			var imageWidth = document.images[i].width;
			var imageHeight = document.images[i].height;
			var imageClass = document.images[i].className;
			
			if ((imageMaxWidth != 0 && imageWidth > imageMaxWidth && imageClass != 'noresize') || (imageMaxHeight != 0 && imageHeight > imageMaxHeight && imageClass != 'noresize')) {
				if (imageMaxWidth != 0) var div1 = imageMaxWidth / imageWidth;
				else var div1 = 1;
				if (imageMaxHeight != 0) var div2 = imageMaxHeight / imageHeight;
				else var div2 = 1;
							
				if (div1 < div2) {
					var ih = Math.round(imageHeight * div1);

					document.images[i].width = imageMaxWidth;
					document.images[i].style.width = imageMaxWidth;
					document.images[i].height = ih;
					document.images[i].style.height = ih;
				}
				else {
					var iw = Math.round(imageWidth * div2);

					document.images[i].height = imageMaxHeight;
					document.images[i].style.height = imageMaxHeight;
					document.images[i].width = iw;
					document.images[i].style.width = iw;
				}


				if (!isLinked(document.images[i])) {
					var popupLink = document.createElement("a");
					popupLink.setAttribute('href', document.images[i].src);
					popupLink.setAttribute('target', '_blank');
					popupLink.setAttribute('class', 'resize');
					popupLink.appendChild(document.images[i].cloneNode(true));
					
					document.images[i].parentNode.replaceChild(popupLink, document.images[i]);
				}


			}


		}
	}
}

function isLinked(node) {
	do {
		node = node.parentNode;
		if (node.nodeName == 'A') return true;
	}
	while (node.nodeName != 'TD' && node.nodeName != 'BODY');
		
	return false;
}