///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//   プログラム名: 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プリントカウント機能追加対応                                       //
///////////////////////////////////////////////////////////////////////////////
function Printer2(){
	this.id					=	"oPrinter2";
	this.LevelIdx			=	0;
	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;
	this.dprInitial();
}


function dprInitial(){
}


function sdprOneSidePrint(arg_Side,arg_Level){
	var	iPageNo							=	oBook.cobGetCurrPage();
	var	iRemainder						=	0;

//---<<< 両面拡大の場合 >>>---//

	if(giDouble							==	0){
//---<<< 左頁印刷ボタン >>>---//
		if(arg_Side						==	"Left"){
//---<<< 左頁めくりの場合 >>>---//
			if(giLeafDirect				==	-1){
				if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo+0.5);
					}catch(e){}
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iPageNo+0.5);
					}catch(e){}
				}
				this.dprDoPrintRight(iPageNo,arg_Level);
			}else{
//---<<< 右頁めくりの場合 >>>---//
				if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo-0.5);
					}catch(e){}
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iPageNo-0.5);
					}catch(e){}
				}
				this.dprDoPrintLeft(iPageNo,arg_Level);
			}
		}else{
//---<<< 右頁印刷ボタン >>>---//
//---<<< 左頁めくりの場合 >>>---//
			if(giLeafDirect				==	-1){
				if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo-0.5);
					}catch(e){}
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iPageNo-0.5);
					}catch(e){}
				}
				this.dprDoPrintLeft(iPageNo,arg_Level);
			}else{
//---<<< 右頁めくりの場合 >>>---//
				if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo+0.5);
					}catch(e){}
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iPageNo+0.5);
					}catch(e){}
				}
				this.dprDoPrintRight(iPageNo,arg_Level);
			}
		}
	}else{
//---<<< 片面拡大の場合 >>>---//
		if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< 左頁印刷ボタン >>>---//
			if(arg_Side					==	"Left"){
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo+0.5);
					}catch(e){}

					this.dprDoPrintRight(iPageNo,arg_Level);
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo-0.5);
					}catch(e){}

//---<<< 右頁めくりの場合 >>>---//
					this.dprDoPrintLeft(iPageNo,arg_Level);
				}
			}else{
//---<<< 右頁印刷ボタン >>>---//
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo-0.5);
					}catch(e){}

					this.dprDoPrintLeft(iPageNo,arg_Level);
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printPageCRM(iPageNo+0.5);
					}catch(e){}

//---<<< 右頁めくりの場合 >>>---//
					this.dprDoPrintRight(iPageNo,arg_Level);
				}
			}
//標準終わり
		}else{
			iRemainder					=	iPageNo		%	2;

//---<<< 左頁印刷ボタン >>>---//
			if(arg_Side					==	"Left"){
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
//---<<< 拡大面のページ番号・右頁拡大の場合 >>>---//
					if(iRemainder		==	0){
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo+1);
						}catch(e){}

						this.dprDoPrintRight(iPageNo+0.5,arg_Level);
					}else{
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo);
						}catch(e){}

						this.dprDoPrintRight(iPageNo,arg_Level);
					}
				}else{
//---<<< 右頁めくりの場合 >>>---//
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
					if(iRemainder		==	0){
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo);
						}catch(e){}

						this.dprDoPrintLeft(iPageNo,arg_Level);
					}else{
//---<<< 拡大面のページ番号・右頁拡大の場合 >>>---//
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo-1);
						}catch(e){}

						this.dprDoPrintLeft(iPageNo-0.5,arg_Level);
					}
				}
			}else{
//---<<< 右頁印刷ボタン >>>---//
//---<<< 左頁めくりの場合 >>>---//
				if(giLeafDirect			==	-1){
//---<<< 拡大面のページ番号・右頁拡大の場合 >>>---//
					if(iRemainder		==	0){
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo);
						}catch(e){}

						this.dprDoPrintLeft(iPageNo,arg_Level);
					}else{
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo-1);
						}catch(e){}

						this.dprDoPrintLeft(iPageNo-0.5,arg_Level);
					}
				}else{
//---<<< 右頁めくりの場合 >>>---//
//---<<< 拡大面のページ番号・左頁拡大の場合 >>>---//
					if(iRemainder		==	0){
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo+1);
						}catch(e){}

						this.dprDoPrintRight(iPageNo+0.5,arg_Level);
					}else{
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iPageNo);
						}catch(e){}

						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(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
				try{
					if(printCrmResultValue == true)	printPageCRM(iCurrPage);
				}catch(e){}
			}else{
				if(giDouble	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage);
					}catch(e){}
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage);
					}catch(e){}

					if(BothPage){
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage - 1);
						}catch(e){}
					}else{
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage + 1);
						}catch(e){}
					}
				}
			}
			
			if(BothPage){
				iCurrPage
				=	iCurrPage	-	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}else{
				iCurrPage
				=	iCurrPage	+	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}
		}else{
			if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
				try{
					if(printCrmResultValue == true)	printPageCRM(iCurrPage);
				}catch(e){}
			}else{
				if(giDouble	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage);
					}catch(e){}
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage);
					}catch(e){}

					if(BothPage){
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage - 1);
						}catch(e){}
					}else{
//---<<< カウント処理 >>>---//
						try{
							if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage + 1);
						}catch(e){}
					}
				}
			}

			if(BothPage){
				iCurrPage
				=	iCurrPage	+	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}else{
				iCurrPage
				=	iCurrPage	-	(giLeafDirect * .5);
				this.GoPrint(iCurrPage);
			}
		}
	}else{
//---<<< カウント処理 >>>---//
		try{
			if(printCrmResultValue == true)	printPageCRM(iCurrPage);
		}catch(e){}

		this.GoPrint(iCurrPage);
	}
}


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(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
			try{
				if(printCrmResultValue == true)	printPageCRM(iCurrPage);
			}catch(e){}
		}else{
//---<<< カウント処理 >>>---//
			try{
				if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage);
			}catch(e){}
		}

		if(iCurrPage==Math.floor(iCurrPage)){
			this.GoPrint(iCurrPage);
		}else{
			this.GoPrint(Math.floor(iCurrPage));
			this.GoPrint(Math.ceil(iCurrPage));
		}
	}else{
		if(iCurrPage !=Math.ceil(iCurrPage)){
			this.BothPrint	=	true;
		}
//---<<< カウント処理 >>>---//
//---<<< 両面カウント >>>---//
		try{
			if(printCrmResultValue == true)	printPageCRM(iCurrPage);
		}catch(e){}

		this.GoPrint(iCurrPage);
	}
}


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);
	}else{
		this.GoPrint(Math.floor(iCurrPage));
	}
}


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);
	}else{
		this.GoPrint(Math.ceil(iCurrPage));
	}
}


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){
			if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
				try{
					if(printCrmResultValue == true)	printPageCRM(iCurrPage);
				}catch(e){}

			}else{
//---<<< カウント処理 >>>---//
				try{
					if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage);
				}catch(e){}
			}

			this.GoPrint(Math.floor(iCurrPage));
			this.GoPrint(Math.ceil(iCurrPage));
		}else{
			if(oBook.cobGetCurrLevelIdx()	==	0){
//---<<< カウント処理 >>>---//
				try{
					if(printCrmResultValue == true)	printPageCRM(iCurrPage);
				}catch(e){}

				this.GoPrint(Math.floor(iCurrPage));
				this.GoPrint(Math.ceil(iCurrPage));
			}else{
				iRemainder		=	iCurrPage		%	2;
				if(iRemainder	==	0){
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage+0.5);
					}catch(e){}

					this.GoPrint(Math.floor(iCurrPage+0.5));
					this.GoPrint(Math.ceil(iCurrPage+0.5));
				}else{
//---<<< カウント処理 >>>---//
					try{
						if(printCrmResultValue == true)	printZoomPageCRM(iCurrPage-0.5);
					}catch(e){}

					this.GoPrint(Math.floor(iCurrPage-0.5));
					this.GoPrint(Math.ceil(iCurrPage-0.5));
				}
			}
		}
	}else{
		if(iCurrPage !=Math.ceil(iCurrPage)){
			this.BothPrint	=	true;
		}
//---<<< カウント処理 >>>---//
		try{
			if(printCrmResultValue == true)	printPageCRM(iCurrPage);
		}catch(e){}

		this.GoPrint(iCurrPage);
	}
}


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"														+
		" <td vAlign=\"middle\" align=\"center\">\n"					+
		" <table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">";

	BaseHtmlRes_02				=	"";

//---<<< 印刷用HTMLフッター編集 >>>---//
	BaseHtmlRes_03				=	" </table>\n"						+
									" </body>\n"						+
									" </html>";
	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);

			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";
		}else{
//---<<< 最小レベル以外の場合（拡大時・任意の拡大レベル指定時） >>>---//
			BaseHtmlRes_02
			=	BaseHtmlRes_02											+
				"<tr><td><table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">\n";

			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";
		}
	}else{
//---<<< 片面印刷の場合 >>>---//
		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";
			}
		}
		BaseHtmlRes_02		+=	"</tr>\n";
	}
	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;
	}
}
