var currentImage = null;
var imageWidth = 600;
var imageHeight = 500;

function showImageWindow(img) {
	currentImage = new Image();
	currentImage.src = img;
	openWindow();
}

function checkImg() {
	if (currentImage.width != 0) openWindow();
	else setTimeout("checkImg()", 100);
}
						 
function openWindow() {
	var width = imageWidth + 70;
	var height = imageHeight + 80;
	var win = top.open('/imagepage.html', 'imagewin', 'width=' + width + ',height=' + height + ',menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
	win.focus();
	return;
}

function getCurrentImage() {
	return currentImage;
}

function setImage(imgName) {
	image = top.opener.getCurrentImage();
	// set image
	document[imgName].src = image.src;	
	return;
}