var newWin;
var newPic;
var imgTimerID;
var checkCount, checkCountMax = 50;

function WinCenter(url){
	newPic = new Image();
	newPic.src = url;
	
	window.status = "画像読み込み中";

	var Size = "width=100,height=100";
	newWin=	window.open(url,"",Size);
	
	checkCount = 0;
	clearInterval(imgTimerID);
	imgTimerID = setInterval("loadImage('"+newPic.src+"')", 100);
}

function loadImage(url) {
	checkCount++;
	if (newPic.complete || (checkCount > checkCountMax)) {
		if (newPic.complete) {
			window.status = "画像読み込み完了";
		} else {
			window.status = "画像読み込み失敗";
			alert("画像が読み込めませんでした。");
		}
		clearInterval(imgTimerID);
		showPage(url);
	}
}

function showPage(url) {
	w = newPic.width;
	h = newPic.height;

	sw	=screen.width/2;
	sh	=screen.height/2;

	if( w > sw ){
		h=h*sw/w;
		w=w*sw/w;
	}
	if( h > sh ){
		w=w*sh/h;
		h=h*sh/h;
	}

	win_w =w;
	win_h =h;

	var x	=(screen.width-w)/2;
	var y	=(screen.height-h)/2;


	newWin.resizeTo(win_w,win_h);
}