///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//   プログラム名: sDeco_Printer.js                                          //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
//   FileName    : Deco_Printer.js                                           //
//   Language    : JavaScript                                                //
//   MakeDate    : YYYY.MM.DD(Digitomi / Sevennet.,Inc)                      //
///////////////////////////////////////////////////////////////////////////////
//   改定履歴                                                                //
///////////////////////////////////////////////////////////////////////////////
//   2007.01.11                                                              //
//   片面印刷不具合対応                                                      //
//   (sdprOneSidePrint,sdprBothSidePrint追加)                                //
//   (dprDoPrintDouble片面拡大時の不具合修正)                                //
///////////////////////////////////////////////////////////////////////////////
//   2007.05.17                                                              //
//   新CRMプリントカウント機能追加対応                                       //
///////////////////////////////////////////////////////////////////////////////
//   2010.05.20                                                              //
//   新CRMプリントカウント組み込み修正                                       //
//   変数定義漏れ不具合対応                                                  //
///////////////////////////////////////////////////////////////////////////////
//   2010.05.31                                                              //
//   一括印刷機能対応                                                        //
//   印刷用HTML編集不具合対応                                                //
///////////////////////////////////////////////////////////////////////////////

function Printer2(){
	this.id					=	"oPrinter2";
	this.LevelIdx			=	0;

//---<<< 2010/05/20 Add Start >>>---//
	this.PrintSize			=	"";
	this.BothPrint			=	"";
//---<<< 2010/05/20 Add End   >>>---//

	this.PreparePrint		=	PreparePrint;
	this.GoPrint			=	GoPrint;
	this.GetPrintScale		=	GetPrintScale;
	this.MessAlert			=	MessAlert;
	this.dprDoPrint			=	dprDoPrint;
	this.dprDoPrintLeft		=	dprDoPrintLeft;
	this.dprDoPrintRight	=	dprDoPrintRight;
	this.dprDoPrintDouble	=	dprDoPrintDouble;
	this.sdprOneSidePrint	=	sdprOneSidePrint;
	this.sdprBothSidePrint	=	sdprBothSidePrint;
	this.dprInitial			=	dprInitial;
//---<<< 2010/05/31 Add Start >>>---//
	this.sLumpPrint						=	sLumpPrint;
	this.sGoLumpPrint					=	sGoLumpPrint;
	this.sPrepareLumpPrint				=	sPrepareLumpPrint;
	this.sBaseHtmlRes01Edit				=	sBaseHtmlRes01Edit;
	this.sBaseHtmlRes02Both0EditMain	=	sBaseHtmlRes02Both0EditMain;
	this.sBaseHtmlRes02Both0Edit		=	sBaseHtmlRes02Both0Edit;
	this.sBaseHtmlRes02Both1EditMain	=	sBaseHtmlRes02Both1EditMain;
	this.sBaseHtmlRes02Both1Edit		=	sBaseHtmlRes02Both1Edit;
	this.sBaseHtmlRes02OneSideEditMain	=	sBaseHtmlRes02OneSideEditMain;
	this.sBaseHtmlRes02OneSideEdit		=	sBaseHtmlRes02OneSideEdit;
	this.sBaseHtmlRes03Edit				=	sBaseHtmlRes03Edit;
//---<<< 2010/05/31 Add End   >>>---//
	this.dprInitial();
}


function dprInitial(){
}


//---<<< 2010/05/31 Add Start >>>---//
//////////////////////////////
//                          //
//   <<< 一括印刷処理 >>>   //
//                          //
//////////////////////////////
function sLumpPrint(paPage,pLevel,pBothPrint){
	this.PrintSize		=	new Array(720,900);
	this.LevelIdx		=	pLevel;
	this.BothPrint		=	pBothPrint;

	this.sGoLumpPrint(paPage);

//---<<< PrintCRM >>>---//
	if( this.LevelIdx	>	0 ){
		try{
			if(printCrmResultValue == true){
				for( i=0; i < paPage.length; i++ ){
					printZoomPageCRM(paPage[i]);
				}
			}
		}catch(e){}
	}else{
		try{
			if(printCrmResultValue == true){
				for( i=0; i < paPage.length; i++ ){
					printPageCRM(paPage[i]);
				}
			}
		}catch(e){}
	}

}
//---<<< 2010/05/31 Add End   >>>---//


function sdprOneSidePrint(arg_Side,arg_Level){
	var	iPageNo							=	oBook.cobGetCurrPage();
	var	iRemainder						=	0;

//---<<< 両面拡大の場合 >>>---//
	if(giDouble							==	0){
//---<<< 左頁印刷ボタン >>>---//
		if(arg_Side						==	"Left"){
//---<<< 左頁めくりの場合 >>>---//
			if(giLeafDirect				==	-1){
				this.dprDoPrintRight(iPageNo,arg_Level);
			}else{
//---<<< 右頁めくりの場合 >>>---//
				this.dprDoPrintLeft(iPageNo,arg_Level);
			}
		}else{
//---<<< 右頁印刷ボタン >>>---//
//---<<< 左頁めくりの場合 >>>---//
			if(giLeafDirect				==	-1){
				this.dprDoPrintLeft(iPageNo,arg_Level);
			}else{
//---<<< 右頁めくりの場合 >>>---//
				this.dprDoPrintRight(iPageNo,arg_Level);
			}
		}
	}else{
//---<<< 片面拡大の場合 >>>---//
		if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< 左頁印刷ボタン >>>---//
			if(arg_Side					==	"Left"){
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
					this.dprDoPrintRight(iPageNo,arg_Level);
				}else{
//---<<< 右頁めくりの場合 >>>---//
					this.dprDoPrintLeft(iPageNo,arg_Level);
				}
			}else{
//---<<< 右頁印刷ボタン >>>---//
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
					this.dprDoPrintLeft(iPageNo,arg_Level);
				}else{
//---<<< 右頁めくりの場合 >>>---//
					this.dprDoPrintRight(iPageNo,arg_Level);
				}
			}
		}else{
			iRemainder					=	iPageNo		%	2;

//---<<< 左頁印刷ボタン >>>---//
			if(arg_Side					==	"Left"){
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
//---<<< 拡大面のページ番号・右頁拡大の場合 >>>---//
					if(iRemainder		==	0){
						this.dprDoPrintRight(iPageNo+0.5,arg_Level);
					}else{
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
						this.dprDoPrintRight(iPageNo,arg_Level);
					}
				}else{
//---<<< 右頁めくりの場合 >>>---//
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
					if(iRemainder		==	0){
						this.dprDoPrintLeft(iPageNo,arg_Level);
					}else{
//---<<< 拡大面のページ番号・右頁拡大の場合 >>>---//
						this.dprDoPrintLeft(iPageNo-0.5,arg_Level);
					}
				}
			}else{
//---<<< 右頁印刷ボタン >>>---//
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
//---<<< 拡大面のページ番号・右頁拡大の場合 >>>---//
					if(iRemainder		==	0){
						this.dprDoPrintLeft(iPageNo,arg_Level);
					}else{
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
						this.dprDoPrintLeft(iPageNo-0.5,arg_Level);
					}
				}else{
//---<<< 右頁めくりの場合 >>>---//
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
					if(iRemainder		==	0){
						this.dprDoPrintRight(iPageNo+0.5,arg_Level);
					}else{
						this.dprDoPrintRight(iPageNo,arg_Level);
					}
				}
			}
		}
	}
}


function sdprBothSidePrint(arg_Page,arg_Level){
	var	iCurrPage		=	arg_Page;
	this.PrintSize		=	new Array(720,900);
	this.LevelIdx		=	arg_Level;
	this.BothPrint		=	true;
	var	BothPage		=	iCurrPage	%	2;

	if(this.LevelIdx > 0){
		if(giLeafDirect==1){
			if(BothPage){
				iCurrPage
				=	iCurrPage	-	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}else{
				iCurrPage
				=	iCurrPage	+	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}
		}else{
			if(BothPage){
				iCurrPage
				=	iCurrPage	+	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}else{
				iCurrPage
				=	iCurrPage	-	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}
		}

//---<<< 2010/05/20 Add Start >>>---//
		try{
			var	iPageNo		=	parseInt(iCurrPage)	+	0.5;
			if(printCrmResultValue == true)
				printZoomPageCRM(iPageNo);
		}catch(e){}
//---<<< 2010/05/20 Add End   >>>---//

	}else{
		this.GoPrint(iCurrPage);

//---<<< 2010/05/20 Add Start >>>---//
		try{
			var	iPageNo		=	iCurrPage;
			if(printCrmResultValue == true)
				printPageCRM(iPageNo);
		}catch(e){}
//---<<< 2010/05/20 Add End   >>>---//


	}

}


function dprDoPrint(arg_Page,arg_Level){
	var	iCurrPage			=	arg_Page;
	this.LevelIdx			=	arg_Level;
	this.PrintSize			=	new Array(720,900);
	this.BothPrint			=	false;

	if(this.LevelIdx > 0){
		if(iCurrPage==Math.floor(iCurrPage)){
			this.GoPrint(iCurrPage);
			var	iPageNo		=	Math.floor(iCurrPage);//追加
		}else{
			var	iPageNo		=	iCurrPage;//追加
			this.GoPrint(Math.floor(iCurrPage));
			this.GoPrint(Math.ceil(iCurrPage));
		}

//---<<< 2010/05/20 Add Start >>>---//
		try{
			if(printCrmResultValue == true)
				printZoomPageCRM(iPageNo);
		}catch(e){}
//---<<< 2010/05/20 Add End   >>>---//

	}else{
		if(iCurrPage !=Math.ceil(iCurrPage)){
			this.BothPrint	=	true;
		}
		this.GoPrint(iCurrPage);

//---<<< 2010/05/20 Add Start >>>---//
		try{
			var	iPageNo		=	iCurrPage;
			if(printCrmResultValue == true)
				printPageCRM(iPageNo);
		}catch(e){}
//---<<< 2010/05/20 Add End   >>>---//

	}
}


function dprDoPrintLeft(arg_Page,arg_Level){
	var	iCurrPage		=	arg_Page;
	this.LevelIdx		=	arg_Level;
	this.PrintSize		=	new Array(720,900);
	this.BothPrint		=	false;

	if(iCurrPage==Math.floor(iCurrPage)){
		this.GoPrint(iCurrPage);
		var	iPageNo		=	iCurrPage;//追加
	}else{
		this.GoPrint(Math.floor(iCurrPage));
		var	iPageNo		=	Math.floor(iCurrPage);//追加
	}


//---<<< 2010/05/20 Add Start >>>---//
	if(this.LevelIdx > 0){
		try{
			if(printCrmResultValue == true)
				printZoomPageCRM(iPageNo);
		}catch(e){}
	}else{
		try{
			if(printCrmResultValue == true)
				printPageCRM(iPageNo);
		}catch(e){}
	}
//---<<< 2010/05/20 Add End   >>>---//

}


function dprDoPrintRight(arg_Page,arg_Level){
	var	iCurrPage		=	arg_Page;
	this.LevelIdx		=	arg_Level;
	this.PrintSize		=	new Array(720,900);
	this.BothPrint		=	false;

	if(iCurrPage==Math.ceil(iCurrPage)){
		this.GoPrint(iCurrPage);
		var	iPageNo		=	iCurrPage;//追加
	}else{
		this.GoPrint(Math.ceil(iCurrPage));
		var	iPageNo		=	Math.ceil(iCurrPage);	//追加
	}

//---<<< 2010/05/20 Add Start >>>---//
	if(this.LevelIdx > 0){
		try{
			if(printCrmResultValue == true)
				printZoomPageCRM(iPageNo);
		}catch(e){}
	}else{
		try{
			if(printCrmResultValue == true)
				printPageCRM(iPageNo);
		}catch(e){}
	}
//---<<< 2010/05/20 Add End   >>>---//

}


function dprDoPrintDouble(arg_Page,arg_Level){
	var	iCurrPage			=	arg_Page;
	this.LevelIdx			=	arg_Level;
	this.PrintSize			=	new Array(720,900);
	this.BothPrint			=	false;
	var	iRemainder			=	0;

	if(this.LevelIdx > 0){
		if(giDouble			==	0){
			this.GoPrint(Math.floor(iCurrPage));
			this.GoPrint(Math.ceil(iCurrPage));
			var	iPageNo		=	iCurrPage;//追加
		}else{
			if(oBook.cobGetCurrLevelIdx()	==	0){
				this.GoPrint(Math.floor(iCurrPage));
				this.GoPrint(Math.ceil(iCurrPage));
				var	iPageNo		=	iCurrPage;//追加
			}else{
				iRemainder		=	iCurrPage		%	2;
				if(iRemainder	==	0){
					this.GoPrint(Math.floor(iCurrPage+0.5));
					this.GoPrint(Math.ceil(iCurrPage+0.5));
					var	iPageNo		=	iCurrPage	+	0.5;//追加
				}else{
					this.GoPrint(Math.floor(iCurrPage-0.5));
					this.GoPrint(Math.ceil(iCurrPage-0.5));
					var	iPageNo		=	iCurrPage	-	0.5;//追加
				}
			}
		}

//---<<< 2010/05/20 Add Start >>>---//
		try{
			if(printCrmResultValue == true)
				printZoomPageCRM(iPageNo);
		}catch(e){}
//---<<< 2010/05/20 Add End   >>>---//

	}else{
		if(iCurrPage !=Math.ceil(iCurrPage)){
			this.BothPrint	=	true;
		}
		this.GoPrint(iCurrPage);

//---<<< 2010/05/20 Add Start >>>---//
		try{
			var	iPageNo		=	iCurrPage;
			if(printCrmResultValue == true)
				printPageCRM(iPageNo);
		}catch(e){}
//---<<< 2010/05/20 Add End   >>>---//

	}

}


function GoPrint(arg_Page){
	var	PrintHtmlCode;
	PrintHtmlCode			=	this.PreparePrint(arg_Page);
	if(this.PrintSize[0] > this.PrintSize[1]){
		this.PrintSize[0]	+=	29;
		this.PrintSize[1]	+=	10;
	}else{
		this.PrintSize[0]	+=	10;
		this.PrintSize[1]	+=	29;
	}

	PrnWnd
	=	window.open("about:blank",
					"PrnWnd"+Math.ceil(arg_Page),
					"channelmode=no,directories=no,fullscreen=no,status=no,titlebar=no,toolbar=no,resizable=no,scrollbar=no,menubar=no,left=0 top=0 width="+this.PrintSize[0]+",height="+this.PrintSize[1]);

	PrnWnd.document.write(PrintHtmlCode);
	PrnWnd.location.reload();
	this.PrintSize			=	new Array(720,900);
}


function MessAlert(){
	var	sResult				=	"";
	if(this.PrintSize[0] > this.PrintSize[1]){
		sResult
		=	"alert(\""										+
			GetRes("PrintConfig",gaRes_Deco)				+
			"\");";
	}
	return sResult;
}


function PreparePrint(arg_Page){
	var	BaseHtmlRes_01;
	var	BaseHtmlRes_02;
	var	BaseHtmlRes_03;
	var	viewHeight;
	var	viewWidth;
	var	PrintScale				=	0;

	PrintScale					=	this.GetPrintScale(this.LevelIdx);

//---<<< 見開き印刷の場合 >>>---//
	if(this.BothPrint){
		viewWidth
		=	Math.ceil((oBookInfo.aLevelInfo[this.LevelIdx][0] * 2)* PrintScale);
		viewHeight
		=	Math.ceil((oBookInfo.aLevelInfo[this.LevelIdx][1])* PrintScale);
	}else{
//---<<< 片面印刷の場合 >>>---//
		viewWidth
		=	Math.ceil(oBookInfo.aLevelInfo[this.LevelIdx][0] * PrintScale);
		viewHeight
		=	Math.ceil(oBookInfo.aLevelInfo[this.LevelIdx][1] * PrintScale);
	}

//---<<< 印刷用HTMLヘッダー編集 >>>---//
	BaseHtmlRes_01
	=	" <html>\n"														+
		" <head>\n"														+
		" <meta http-equiv=\"imagetoolbar\" content=\"no\">\n"			+
		" <title>"														+
		"Print [ "														+
		document.title													+
		" : "															+
		(arg_Page+1)													+
		" Page ]"														+
		" </title>\n"													+
		" <script language=\"javascript\">\n"							+
		" function DoPrint(){\n"										+
		" setTimeout(\"window.print()\",10);\n"							+
		" setTimeout(\"window.close()\",10);\n"							+
		" "																+
		this.MessAlert()												+
		"\n"															+
		"}\n"															+
		" </script>\n"													+
		" </head>\n"													+
		" <body leftmargin=\"0\" rightmargin=\"0\" topmargin=\"0\" bottommargin=\"0\" oncontextmenu=\"return false\" onselectstart=\"return false\" onload=\"DoPrint()\">\n"															+
		" <table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=\"0\" cellSpacing=\"0\">\n"													+
		" <tr>\n"														+
//---<<< 2010/05/31 Mod Start >>>---//
//		" <td vAlign=\"middle\" align=\"center\">\n"					+
//		" <table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">";
		" <td vAlign=\"middle\" align=\"center\">\n";
//---<<< 2010/05/31 Mod End   >>>---//

	BaseHtmlRes_02				=	"";

//---<<< 印刷用HTMLフッター編集 >>>---//
//---<<< 2010/05/31 Mod Start >>>---//
	BaseHtmlRes_03
	=	"</td>"															+
		"\n"															+
		"</tr>"															+
		"\n"															+
		" </table>"														+
		"\n"															+
		" </body>"														+
		"\n"													+
		" </html>";
//---<<< 2010/05/31 Mod End   >>>---//

	var	ImgBaseUrl				=	"";
	var	PrintWidth				=	viewWidth;
	var	PrintHeight				=	viewHeight;
	var	PrintWidth2				=	viewWidth;
	var	PrintHeight2			=	viewHeight;

//---<<< 見開き印刷の場合 >>>---//
	if(this.BothPrint){
//---<<< 最小レベルの場合 >>>---//
		if(this.LevelIdx		==	0){
			var	sTileImgUrl
				=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page-(0.5 * giLeafDirect)),0,0);

//---<<< 2010/05/31 Add Start >>>---//
			BaseHtmlRes_02
			+=	"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
				"\n"														+
				"<tr>"														+
				"\n";
//---<<< 2010/05/31 Add End   >>>---//

			BaseHtmlRes_02
			+=	"<td><img src=\""										+
				sTileImgUrl												+
				"\" width=\""											+
				(viewWidth/2)											+
				"\" height=\""											+
				PrintHeight												+
				"\" ></td> "											+
				"\n";

			var	sTileImgUrl
				=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page+(0.5 * giLeafDirect)),0,0);
			BaseHtmlRes_02
			+=	"<td><img src=\""										+
				sTileImgUrl												+
				"\" width=\""											+
				(viewWidth/2)											+
				"\" height=\""											+
				PrintHeight												+
				"\" ></td> "											+
				"\n";

//---<<< 2010/05/31 Add Start >>>---//
			BaseHtmlRes_02
			+=	"</tr>"													+
				"\n"													+
				"</table>"												+
				"\n";
//---<<< 2010/05/31 Add End   >>>---//

		}else{
//---<<< 最小レベル以外の場合（拡大時・任意の拡大レベル指定時） >>>---//
//---<<< 2010/05/31 Add Start >>>---//
			BaseHtmlRes_02
			+=	"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
				"\n";
//---<<< 2010/05/31 Add End   >>>---//

//---<<< 2010/05/31 Mod Start >>>---//
//			BaseHtmlRes_02
//			=	BaseHtmlRes_02											+
//				"<tr><td><table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">\n";
			BaseHtmlRes_02
			+=	"<tr>"														+
				"\n"														+
				"<td>"														+
				"\n"														+
				"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
				"\n";
//---<<< 2010/05/31 Mod End   >>>---//

			for(yIdx=0;yIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][5];yIdx++){
				BaseHtmlRes_02
				=	BaseHtmlRes_02										+
					"<tr>\n";
				PrintWidth	=	viewWidth	/	2;

				if(yIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){
					PrintHeight
					=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* PrintScale);
				}

				for(xIdx=0;xIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx++){
					if(giLeafDirect==1){
						var	sTileImgUrl
							=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page),yIdx,xIdx);
					}else{
						var	sTileImgUrl
							=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page+1),yIdx,xIdx);
					}

					if(xIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){
						PrintWidth
						=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* PrintScale);
					}

					BaseHtmlRes_02
					+=	"<td style=\"border:0 solid red\"><img src=\""	+
						sTileImgUrl										+
						"\" width=\""									+
						PrintWidth										+
						"\" height=\""									+
						PrintHeight										+
						"\" ></td> "									+
						"\n";
				}
				BaseHtmlRes_02		+=	"</tr>\n";
			}

			BaseHtmlRes_02
			+=	"</table></td><td><table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">\n";

			for(yIdx2=0;yIdx2< oBook.oBookInfo.aLevelInfo[this.LevelIdx][5];yIdx2++){
				BaseHtmlRes_02
				=	BaseHtmlRes_02										+
					"<tr>\n";
				PrintWidth2			=	viewWidth	/	2;

				if(yIdx2==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){
					PrintHeight2
					=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* PrintScale);
				}

				for(xIdx2=0;xIdx2< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx2++){
					if(giLeafDirect==1){
						var	sTileImgUrl2
							=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page+1),yIdx2,xIdx2);
					}else{
						var	sTileImgUrl2
							=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page),yIdx2,xIdx2);
					}

					if(xIdx2==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){
						PrintWidth2
						=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* PrintScale);
					}

					BaseHtmlRes_02
					+=	"<td style=\"border:0 solid red\"><img src=\""	+
						sTileImgUrl2									+
						"\" width=\""									+
						PrintWidth2										+
						"\" height=\""									+
						PrintHeight2									+
						"\" ></td> "									+
						"\n";
				}

				BaseHtmlRes_02		+=	"</tr>\n";
			}
			BaseHtmlRes_02	+=	"</table></td></tr>\n";

//---<<< 2010/05/31 Add Start >>>---//
			BaseHtmlRes_02
			+=		"</table>"					+
					"\n";
//---<<< 2010/05/31 Add Start >>>---//

		}
	}else{
//---<<< 片面印刷の場合 >>>---//
//---<<< 2010/05/31 Add Start >>>---//
		BaseHtmlRes_02
		+=	"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
			"\n";
//---<<< 2010/05/31 Add End   >>>---//

		for(yIdx=0;yIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][5];yIdx++){
			BaseHtmlRes_02	=	BaseHtmlRes_02							+
								"<tr>\n";
			PrintWidth		=	viewWidth;

			if(yIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){
				PrintHeight
				=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* PrintScale);
			}

			for(xIdx=0;xIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx++){
				var	sTileImgUrl
					=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page),yIdx,xIdx);

				if(xIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){
					PrintWidth
					=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* PrintScale);
				}

				BaseHtmlRes_02
				+=	"<td><img src=\""									+
					sTileImgUrl											+
					"\" width=\""										+
					PrintWidth											+
					"\" height=\""										+
					PrintHeight											+
					"\" ></td>\n";
			}

//---<<< 2010/05/31 Add Start >>>---//
			BaseHtmlRes_02		+=	"</tr>\n";
//---<<< 2010/05/31 Add Start >>>---//

		}
//---<<< 2010/05/31 Mod Start >>>---//
//		BaseHtmlRes_02		+=	"</tr>\n";
//---<<< 2010/05/31 Mod End >>>---//

//---<<< 2010/05/31 Add Start >>>---//
		BaseHtmlRes_02
		+=		"</table>"					+
				"\n";
//---<<< 2010/05/31 Add Start >>>---//
	}
	return(BaseHtmlRes_01+BaseHtmlRes_02+BaseHtmlRes_03);
}


function GetPrintScale(arg_Level){
	if(arg_Level==0){
		var	BookSize
			=	new	Array(oBook.oBookInfo.aLevelInfo[arg_Level][0],
							oBook.oBookInfo.aLevelInfo[arg_Level][1]);
	}else{
		var	BookSize
			=	new	Array(oBook.oBookInfo.aLevelInfo[arg_Level][2],
							oBook.oBookInfo.aLevelInfo[arg_Level][3]);
	}

	var	PrintScale			=	new Array();
	var	Scaletype			=	-1;

	if(this.BothPrint){
		BookSize[0]			=	BookSize[0]	*	2;
	}

	if(BookSize[0] > BookSize[1]){
		var	tmp				=	this.PrintSize[0];
		this.PrintSize[0]	=	this.PrintSize[1];
		this.PrintSize[1]	=	tmp;
	}

	PrintScale[0]			=	this.PrintSize[0] / BookSize[0];
	PrintScale[1]			=	this.PrintSize[1] / BookSize[1];

	if((BookSize[0] >=this.PrintSize[0])&&(BookSize[1] >=this.PrintSize[1])){
		if(PrintScale[0] < PrintScale[1]){
			return PrintScale[0];
		}else{
			return PrintScale[1];
		}
	}else if((BookSize[0] >=this.PrintSize[0])&&(BookSize[1] < this.PrintSize[1])){
		return PrintScale[0];
	}else if((BookSize[0] < this.PrintSize[0])&&(BookSize[1] >=this.PrintSize[1])){
		return PrintScale[1];
	}else{
		return 1;
	}
}


//---<<< 2010/05/31 Add Start >>>---//
//////////////////////////////
//                          //
//   <<< 一括印刷機能 >>>   //
//                          //
//////////////////////////////
function sGoLumpPrint(paPage){
	var	PrintHtmlCode;

	PrintHtmlCode			=	this.sPrepareLumpPrint(paPage);

	if(this.PrintSize[0] > this.PrintSize[1]){
		this.PrintSize[0]	+=	29;
		this.PrintSize[1]	+=	10;
	}else{
		this.PrintSize[0]	+=	10;
		this.PrintSize[1]	+=	29;
	}

	var	sWinOpt
		=	"channelmode=no, "					+
			"location=yes, "					+
			"directories=yes, "					+
			"fullscreen=no, "					+
			"status=yes, "						+
			"titlebar=yes, "					+
			"toolbar=yes, "						+
			"resizable=yes, "					+
			"scrollbars=yes, "					+
			"menubar=yes, "						+
			"left=0, "							+
			"top=0, "							+
			"width="							+
			this.PrintSize[0]					+
			", height="							+
			this.PrintSize[1];

	var	PrnWnd
	=	window.open("",
					"EBookLumpPrnWnd",
					sWinOpt);

	PrnWnd.document.write(PrintHtmlCode);
	PrnWnd.document.close();
	PrnWnd.location.reload();
	this.PrintSize			=	new Array(720,900);
}


////////////////////////////////////
//                                //
//   <<< 一括印刷用HTML編集 >>>   //
//                                //
////////////////////////////////////
function sPrepareLumpPrint(paPage){
	var	BaseHtmlRes_01			=	"";
	var	BaseHtmlRes_02			=	"";
	var	BaseHtmlRes_03			=	"";
	var	viewHeight				=	"";
	var	viewWidth				=	"";
	var	PrintScale				=	0;

	PrintScale					=	this.GetPrintScale(this.LevelIdx);

//---<<< 見開き印刷の場合 >>>---//
	if(this.BothPrint){
		viewWidth
		=	Math.ceil((oBookInfo.aLevelInfo[this.LevelIdx][0] * 2)* PrintScale);
		viewHeight
		=	Math.ceil((oBookInfo.aLevelInfo[this.LevelIdx][1])* PrintScale);
	}else{
//---<<< 片面印刷の場合 >>>---//
		viewWidth
		=	Math.ceil(oBookInfo.aLevelInfo[this.LevelIdx][0] * PrintScale);
		viewHeight
		=	Math.ceil(oBookInfo.aLevelInfo[this.LevelIdx][1] * PrintScale);
	}

//---<<< 印刷用HTMLヘッダー編集 >>>---//
	BaseHtmlRes_01				=	this.sBaseHtmlRes01Edit();

//---<<< 印刷用HTMLフッター編集 >>>---//
	BaseHtmlRes_03				=	this.sBaseHtmlRes03Edit();

//---<<< 印刷用HTMLボディ編集 >>>---//
//---<<< 見開き印刷の場合 >>>---//
	if(this.BothPrint){
		if(this.LevelIdx		==	0){
//---<<< 最小レベルの場合 >>>---//
			BaseHtmlRes_02
			=	this.sBaseHtmlRes02Both0EditMain(paPage,viewWidth,viewHeight);

		}else{
//---<<< 最小レベル以外の場合（拡大時・任意の拡大レベル指定時） >>>---//
			BaseHtmlRes_02
			=	this.sBaseHtmlRes02Both1EditMain(paPage,viewWidth,viewHeight,PrintScale);

		}
	}else{
//---<<< 片面印刷の場合 >>>---//
			BaseHtmlRes_02
			=	this.sBaseHtmlRes02OneSideEditMain(paPage,viewWidth,viewHeight,PrintScale);

	}

	return(BaseHtmlRes_01+BaseHtmlRes_02+BaseHtmlRes_03);
}


//////////////////////////////////
//                              //
//   <<< HTML ヘッダ Edit >>>   //
//                              //
//////////////////////////////////
function sBaseHtmlRes01Edit(){

	var	sHTML
	=	" <html>\n"														+
		" <head>\n"														+
		" <meta http-equiv=\"imagetoolbar\" content=\"no\">\n"			+
		" <title>"														+
		"Print [ "														+
		document.title													+
		" : "															+
		" ]"															+
		" </title>\n"													+
		"<style type=\"text/css\">"										+
		"\n"															+
		"<!--"															+
		"\n"															+
		".PageBr { page-break-before: always; }"						+
		"\n"															+
		"-->"															+
		"\n"															+
		"</style>"														+
		"\n"															+
		" <script language=\"javascript\">\n"							+
		" function DoPrint(){\n"										+
		" setTimeout(\"window.print()\",10);\n"							+
		" setTimeout(\"window.close()\",10);\n"							+
		" "																+
		this.MessAlert()												+
		"\n"															+
		"}\n"															+
		" </script>\n"													+
		" </head>\n"													+
		" <body "														+
		" leftmargin=\"0\" "											+
		" rightmargin=\"0\" "											+
		" topmargin=\"0\" "												+
		" bottommargin=\"0\" "											+
		" oncontextmenu=\"return false\" "								+
		" onselectstart=\"return false\" "								+
		" onload=\"DoPrint()\">\n";

	return	sHTML;

}

////////////////////////////////
//                            //
//---<<< 両面最小拡大時 >>>---//
//                            //
////////////////////////////////
function sBaseHtmlRes02Both0EditMain(paPage,pPrintWidth,pPrintHeight){

	var	sHTML				=	"";

	for( i=0; i < paPage.length; i++ ){
		if( i	>	0){
			sHTML
			+=	"<div class=\"PageBr\">"			+
				"</div>"							+
				"\n";
		}

		sHTML
		+=	this.sBaseHtmlRes02Both0Edit(paPage[i],pPrintWidth,pPrintHeight);
	}

	return	sHTML;
}

////////////////////////////////////
//                                //
//   <<< 両面最小拡大時編集 >>>   //
//                                //
////////////////////////////////////
function sBaseHtmlRes02Both0Edit(pPage,pPrintWidth,pPrintHeight){

	var	sHTML
		=	"<table "													+
			" border=\"0\" "											+
			" width=\"100%\" "											+
			" height=\"100%\" "											+
			" cellpadding=\"0\" "										+
			" cellSpacing=\"0\">\n"										+
			"<tr>\n"													+
			"<td vAlign=\"middle\" align=\"center\">\n"					+
			"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
			"\n"														+
			"<tr>"														+
			"\n";

	var	sTileImgUrl
		=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(pPage-(0.5 * giLeafDirect)),0,0);

	sHTML
	+=	"<td>"									+
		"<img src=\""							+
		sTileImgUrl								+
		"\" width=\""							+
		(pPrintWidth / 2)						+
		"\" height=\""							+
		pPrintHeight							+
		"\" >"									+
		"</td> "								+
		"\n";

	var	sTileImgUrl
		=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(pPage+(0.5 * giLeafDirect)),0,0);

	sHTML
	+=	"<td>"									+
		"<img src=\""							+
		sTileImgUrl								+
		"\" width=\""							+
		(pPrintWidth / 2)						+
		"\" height=\""							+
		pPrintHeight							+
		"\" >"									+
		"</td> "								+
		"\n";

	sHTML
	+=	"</tr>"									+
		"\n"									+
		"</table>"								+
		"\n"									+
		"</td>"									+
		"\n"									+
		"</tr>"									+
		"\n"									+
		"</table>"								+
		"\n";

	return	sHTML;
}


////////////////////////////
//                        //
//---<<< 両面拡大時 >>>---//
//                        //
////////////////////////////
function sBaseHtmlRes02Both1EditMain(paPage,pPrintWidth,pPrintHeight,pPrintScale){

	var	sHTML				=	"";

	for( i=0; i < paPage.length; i++ ){
		if( i	>	0){
			sHTML
			+=	"<div class=\"PageBr\">"			+
				"</div>"							+
				"\n";
		}

		sHTML
		+=	this.sBaseHtmlRes02Both1Edit(paPage[i],pPrintWidth,pPrintHeight,pPrintScale);
	}

	return	sHTML;
}


////////////////////////////////
//                            //
//   <<< 両面拡大時編集 >>>   //
//                            //
////////////////////////////////
function sBaseHtmlRes02Both1Edit(pPage,pPrintWidth,pPrintHeight,pPrintScale){

	var	sHTML				=	"";
	var	PrintWidth			=	pPrintWidth;
	var	PrintHeight			=	pPrintHeight;
	var	PrintWidth2			=	pPrintWidth;
	var	PrintHeight2		=	pPrintHeight;

	sHTML
	=	"<table "														+
		" border=\"0\" "												+
		" width=\"100%\" "												+
		" height=\"100%\" "												+
		" cellpadding=\"0\" "											+
		" cellSpacing=\"0\">"											+
		"\n"															+
		"<tr>"															+
		"\n"															+
		"<td vAlign=\"middle\" align=\"center\">"						+
		"\n"															+
		"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"		+
		"\n"															+
		"<tr>"															+
		"\n"															+
		"<td>"															+
		"\n"															+
		"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"		+
		"\n";


	for( yIdx=0; yIdx < oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]; yIdx++ ){
		sHTML		+=	"<tr>\n";

		PrintWidth	=	pPrintWidth		/	2;

		if(yIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){
			PrintHeight
			=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* pPrintScale);
		}

		for(xIdx=0;xIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx++){
			if(giLeafDirect==1){
				var	sTileImgUrl
					=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(pPage),yIdx,xIdx);
			}else{
				var	sTileImgUrl
					=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(pPage+1),yIdx,xIdx);
			}

			if(xIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){
				PrintWidth
				=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* pPrintScale);
			}

			sHTML
			+=	"<td style=\"border:0 solid red\">"				+
				"<img src=\""									+
				sTileImgUrl										+
				"\" width=\""									+
				PrintWidth										+
				"\" height=\""									+
				PrintHeight										+
				"\" >"											+
				"</td> "										+
				"\n";
		}
		sHTML		+=	"</tr>\n";
	}

	sHTML
	+=	"</table>"													+
		"\n"														+
		"</td>"														+
		"\n"														+
		"<td>"														+
		"\n"														+
		"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
		"\n";

	for(yIdx2=0;yIdx2< oBook.oBookInfo.aLevelInfo[this.LevelIdx][5];yIdx2++){
		sHTML			+=	"<tr>\n";

		PrintWidth2		=	pPrintWidth	/	2;

		if(yIdx2==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){
			PrintHeight2
			=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* pPrintScale);
		}

		for(xIdx2=0;xIdx2< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx2++){
			if(giLeafDirect==1){
				var	sTileImgUrl2
					=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(pPage+1),yIdx2,xIdx2);
			}else{
				var	sTileImgUrl2
					=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(pPage),yIdx2,xIdx2);
			}

			if(xIdx2==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){
				PrintWidth2
				=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* pPrintScale);
			}

			sHTML
			+=	"<td style=\"border:0 solid red\">"				+
				"<img src=\""									+
				sTileImgUrl2									+
				"\" width=\""									+
				PrintWidth2										+
				"\" height=\""									+
				PrintHeight2									+
				"\" >"											+
				"</td> "										+
				"\n";
		}

		sHTML			+=	"</tr>\n";

	}

	sHTML
	+=	"</table>"				+
		"\n"					+
		"</td>"					+
		"\n"					+
		"</tr>"					+
		"\n"					+
		"</table>"				+
		"\n"					+
		"</td>"					+
		"\n"					+
		"</tr>"					+
		"\n"					+
		"</table>"				+
		"\n";

	return	sHTML;

}


////////////////////////
//                    //
//---<<< 片面時 >>>---//
//                    //
////////////////////////
function sBaseHtmlRes02OneSideEditMain(paPage,pPrintWidth,pPrintHeight,pPrintScale){

	var	sHTML				=	"";

	for( i=0; i < paPage.length; i++ ){
		if( i	>	0){
			sHTML
			+=	"<div class=\"PageBr\">"			+
				"</div>"							+
				"\n";
		}

		sHTML
		+=	this.sBaseHtmlRes02OneSideEdit(paPage[i],pPrintWidth,pPrintHeight,pPrintScale);
	}

	return	sHTML;
}


////////////////////////
//                    //
//---<<< 片面時 >>>---//
//                    //
////////////////////////
function sBaseHtmlRes02OneSideEdit(paPage,pPrintWidth,pPrintHeight,pPrintScale){

	var	sHTML				=	"";
	var	PrintWidth			=	pPrintWidth;
	var	PrintHeight			=	pPrintHeight;

	sHTML
	+=	"<table "													+
		" border=\"0\" "											+
		" width=\"100%\" "											+
		" height=\"100%\" "											+
		" cellpadding=\"0\" "										+
		" cellSpacing=\"0\">"										+
		"\n"														+
		"<tr>"														+
		"\n"														+
		"<td vAlign=\"middle\" align=\"center\">"					+
		"\n"														+
		"<table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">"	+
		"\n";

	for( yIdx=0; yIdx < oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]; yIdx++ ){
		sHTML
		+=	"<tr>"													+
			"\n";

		PrintWidth		=	pPrintWidth;

		if(yIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){
			PrintHeight
			=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* pPrintScale);
		}

		for(xIdx=0;xIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx++){
			var	sTileImgUrl
				=	oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(paPage),yIdx,xIdx);

			if(xIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){
				PrintWidth
				=	parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* pPrintScale);
			}

			sHTML
			+=	"<td>"								+
				"<img src=\""						+
				sTileImgUrl							+
				"\" width=\""						+
				PrintWidth							+
				"\" height=\""						+
				PrintHeight							+
				"\" >"								+
				"</td>\n";
		}

		sHTML			+=	"</tr>\n";

	}

	sHTML
	+=	"</table>"					+
		"\n"						+
		"</td>"						+
		"\n"						+
		"</tr>"						+
		"\n"						+
		"</table>"					+
		"\n";

	return	sHTML;
}


//////////////////////////////////
//                              //
//   <<< html フッタ Edit >>>   //
//                              //
//////////////////////////////////
function sBaseHtmlRes03Edit(){

	var	sHTML
		=	"</body>\n"													+
			"</html>";

	return	sHTML;

}

//---<<< 2010/05/31 Add End   >>>---//
