var newwindow = ''
function imageWindow(url) {
	if (newwindow && !newwindow.closed) {
		newwindow.window.close();
		//newwindow.window.focus();
	}
	
	newwindow = window.open("",'htmlname','width=600,height=600,resizable=1');
	newwindow.window.focus();
	
	// write to window
	newwindow.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	newwindow.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
	newwindow.document.writeln('<head>');
	newwindow.document.writeln('<title>' + url + '</title>');
	newwindow.document.writeln('<script type="text/javascript">');
	newwindow.document.writeln('function resize(){');
	newwindow.document.writeln('var width=document.getElementById(\'image\').width;');
	newwindow.document.writeln('var height=document.getElementById(\'image\').height;');
	
	/*
	newwindow.document.writeln('if (window.innerWidth) {');
	newwindow.document.writeln('window.innerWidth=width;');
	newwindow.document.writeln('window.innerHeight=height;');
	newwindow.document.writeln('} else {');
	newwindow.document.writeln('window.resizeBy((width - 600),(height - 600));');
	newwindow.document.writeln('}');
	*/
	
	newwindow.document.writeln('window.resizeBy((width - 600),(height - 600));');
	
	newwindow.document.writeln('}');
	newwindow.document.writeln('</script>');
	newwindow.document.writeln('</head>');
	newwindow.document.writeln('<body onload="resize();" style="margin:0px;"><img src="' + url + '" id="image" alt="" /></body>');
	newwindow.document.writeln('</html>');
	newwindow.document.close();
}