var i;
var nWin;

function openwin_image(wIMG,wName) {

	// 画像をロードしてサイズを取得
	i = new Image(); i.src = wIMG;

	// 画像のサイズに合った空ウィンドウを開く
	nWin = window.open("","CareProImageWindow","width="+i.width+",height="+(i.height+40)+",resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no");

	//ウィンドウにHTMLを出力
	nWin.document.open();
	nWin.document.write("<HTML><HEAD>");
	nWin.document.write("<TITLE>"+wName+"</TITLE></HEAD>");
	nWin.document.writeln("<BODY leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>");
	nWin.document.write("<A href='javascript:window.close()'><IMG src='"+wIMG+"' border='0' name='img'></A>"); 
	nWin.document.write("<center><span style='line-height: 120%'><font size='2'>");
	nWin.document.write(wName);
	nWin.document.write("<BR><A href='javascript:window.close()'>閉じる</A>");
	nWin.document.write("</font></span></center>");
	nWin.document.write("</BODY></HTML>");
	nWin.document.close();

	img_onload();

	//新しいウィンドウを前に
	nWin.focus();
}

function img_onload() {

	if ( ! i.complete ) {
		setTimeout("img_onload()", 100);
		return;
	}

	// 画像サイズに合わせてリサイズ
	var wWidth = i.width;
	var wHeight = i.height + 40;

	//nWin.window.resizeTo(wWidth, wHeight);

	//IE用の調整
	nWin.resizeBy(wWidth-nWin.document.body.clientWidth,wHeight-nWin.document.body.clientHeight);

	//FireFox用の調整
	nWin.innerWidth = wWidth;
	nWin.innerHeight = wHeight;
}

