/*
	Written by kikuchi@nikkei
	kikuchi@gmail.com
*/

function subwin(sFile, bScroll, nW, nH, nL, nT)	{
	var oWindowSize_left = new position_fix(screen.width, nL, nW);
	var oWindowSize_top = new position_fix(screen.height, nT, nH);
	var bScroll = bScroll?"yes":"no";
	subWin = window.open(sFile,"sub","width="+oWindowSize_left.nSize+",height="+oWindowSize_top.nSize+",dependent=yes,directories=no,fullscreen=no,hotkeys=no,top="+oWindowSize_top.nPosition+",left="+oWindowSize_left.nPosition+",menubar=no,scrollbars="+bScroll+",status=no,titlebar=no,toolbar=no,resizable=yes");
}

function position_fix(nScreen, nPosition, nSize) {
	var Sleng = nSize.length;
	var Sfind = nSize.charAt(Sleng-1);
	var Pleng = nPosition.length;
	var Pfind = nPosition.charAt(Pleng-1);
	var oWindowSize = new Object();

	//デフォルト値設定
	oWindowSize.nSize = 500;
	oWindowSize.nPosition = 0;

	if(Sfind == '%'){
		oWindowSize.nSize = Math.floor(nScreen*nSize.substr(0, Sleng-1)/100);
	} else if(typeof(Math.floor(nSize)) == 'number'){
		oWindowSize.nSize = nSize;
	}

	if(Pfind == '%') {
		nPosition = Math.floor(nPosition.substr(0, Pleng-1));
		oWindowSize.nPosition = (nScreen - oWindowSize.nSize)*nPosition/100;
	} else if(typeof(Math.floor(nPosition)) == 'number'){
		oWindowSize.nPosition = nPosition;
	}
	return oWindowSize;
}
