// JavaScript Document
function showImage(url, width, height, legend)
{
	var max_width = screen.width-100;
	var max_height = screen.height-100;
	var full_view = max_width>=width && max_height>=height;
	var win_width = full_view ? width : Math.min(width, max_width);
	var win_height = full_view ? height : Math.min(height, max_height);
	var win_top = Math.floor((screen.height - win_height - 16)/2);
	var win_left = Math.floor((screen.width - win_width)/2);
	var sb = full_view ? '' : ',scrollbars=yes';
	var wnd = window.open("", "wf2image", "width=" + win_width + ",height=" + win_height + ",left=" + win_left + ",top=" + win_top + sb );
	var doc = wnd.document;
		
	doc.open();
				
	doc.write('<html><head><title></title></head>');
//	if(full_view) {
//		doc.write('<body style="margin: 0; background-color: #000000; background: url('+url+') no-repeat 0 0;" onBlur="self.close()">'); 
//	    doc.write(legend);
//		doc.write('</body></html>');
//		doc.close();
//		wnd.onmouseup = function(event) {
//			var e = event || window.event;
//			if(e.button<2) wnd.close();
//		}
//	}
//	else {
		doc.write('<body style="margin: 0; background-color: #000;" onBlur="self.close()">'); 
//		doc.write('<img onclick="window.close();" src="' + url + '" width="' + width + '" height="' + height + '" alt="" border="0">');
		doc.write('<img onclick="window.close();" src="' + url + '" alt="" />');
		doc.write('<p style="text-align: center; margin: 0px; font-family: Verdana, Arial, sans-serif; font-size: 11px; padding-top: 5px; color: #FFF; ">' + legend + '</p>');
		doc.write('</body></html>');
		doc.close();
//	}
	wnd.focus();
}