//////////////////////////////////////////////////////
//                                                  //
//   <<< EBook / FlashEBook Switch >>>              //
//                                                  //
//////////////////////////////////////////////////////
// ProgramName :                                    //
// Language    : JavaScript                         //
// Make Date   : 2006.05.30                         //
//////////////////////////////////////////////////////
// 改定履歴                                         //
//////////////////////////////////////////////////////
// 2009.02.04                                       //
//  Google Chrome(Windows・Mac版) 追加対応          //
//  Safari(Windows版) 追加対応                      //
//  Opera 追加対応                                  //
//  Sleipnir 追加対応                               //
//   funcEBookSwitch() 修正                         //
//////////////////////////////////////////////////////
// 2010.11.19                                       //
//  EBook マルチブラウザ対応                        //
//   funcEBookSwitch() 修正                         //
//   funcEBookOpen() 修正                           //
//////////////////////////////////////////////////////
function sfuncEBookSwitchInit(){
	this.funcEBookSwitch		=	funcEBookSwitch;
	this.funcParamCheck			=	funcParamCheck;
	this.funcEBookOpen			=	funcEBookOpen;
	this.funcFlashEBookOpen		=	funcFlashEBookOpen;
	this.funcPDFOpen			=	funcPDFOpen;
	this.funcAboutPageOpen		=	funcAboutPageOpen;
	this.funcForceclose			=	funcForceclose;
}

//////////////////////////////////////////////////////
// Paramater   : 0.Open = 0(EBook)                  //
//                        1(EBook,FlashEBook)       //
//                        2(EBook,PDF)              //
//                        3(EBook,FlashEBook,PDF)   //
//                        4(FlashEBook)             //
//                        5(PDF)                    //
//               1.PDFUrl(For PDF)                  //
//               2.BookCode                         //
//               3.CoopID                           //
//               4.ShadeType(For FlashEBook)        //
//               5.ViewerName(For FlashEBook)       //
//               6.OpenPageNo                       //
//               7.StartPageNo                      //
//               8.EndPageNo                        //
//               9.WindowClose                      //
//              10.RequiredPageUrl                  //
//              11.RequiredPageHeight               //
//              12.RequiredPageWidth                //
//////////////////////////////////////////////////////
function funcEBookSwitch(){
	var	fCheck			=	"";
	var	fOS				=	"";
	var	fBrowser			=	"";
	var	fWinSizeHeight		=	"";
	var	fWinSizeWidth		=	"";

//---<<< EbookAboutPageUrl Set >>>---//
	this.sAboutPageURL	=	arguments[10];

	fWinSizeHeight	=	arguments[11];
	if	(fWinSizeHeight	==	"0"){
		fWinSizeHeight	=	"620";
	}

	fWinSizeWidth	=	arguments[12];
	if	(fWinSizeWidth	==	"0"){
		fWinSizeWidth	=	"430";
	}

//---<<< Param Check >>>---//
	fCheck				=	this.funcParamCheck(arguments);

	if	(fCheck			==	"0"){
//--<<< 2010.11.19 Add Start >>>---//
		if( parseInt( arguments[2] )	>=	100000 ){
			this.funcEBookOpen( arguments )
		}else{
//--<<< 2010.11.19 Add End   >>>---//

		fOS				=	soComLib.funcGetOs();
		fBrowser		=	soComLib.funcGetBrowser();

		switch(fOS){
//---<<< Other OS >>>---//
		case	"0"	:
//---<<< For PDF >>>---//
						if	((arguments[0]		==	"2")
							||
							(arguments[0]		==	"3")
							||
							(arguments[0]		==	"5")){
							if	(arguments[9]	==	"0"){
								this.funcPDFOpen(arguments[1]);
								this.funcForceclose();
							}
						}else{
//---<<< For SpecWindow >>>---//
							this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
						}
						break;
//---<<< Windows OS >>>---//
		case	"1"	:
//---<<< For InternetExplorer >>>---//
						if	(fBrowser	==	"1"){
							switch(arguments[0]){
							case	"4"	:
											if	(arguments[9]	==	"0"){
												this.funcFlashEBookOpen(arguments);
												this.funcForceclose();
											}
											break;
							case	"5"	:
											if	(arguments[9]	==	"0"){
												this.funcPDFOpen(arguments[1]);
												this.funcForceclose();
											}
											break;
							default	:
											if	(arguments[9]	==	"0"){
												this.funcEBookOpen(arguments);
												this.funcForceclose();
											}
											break;
							}
						}else{
							switch(arguments[0]){
							case	"0"	:
											this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
											break;
							case	"1"	:
											if( fBrowser	==	"2" ){
												if( arguments[9]	==	"0" ){
													this.funcFlashEBookOpen(arguments);
													this.funcForceclose();
												}
											}else if( ( fBrowser	==	"3" )
													||
													  ( fBrowser	==	"4" )
													||
													  ( fBrowser	==	"5" )
													||
													  ( fBrowser	==	"6" ) ){
												if( arguments[9]	==	"0" ){
													this.funcFlashEBookOpen(arguments);
												}
											}else{
												this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
											}
											break;
							case	"2"	:
											if( fBrowser	==	"4" ){
												this.funcPDFOpen(arguments[1]);
											}else{
												if( arguments[9]	==	"0" ){
													this.funcPDFOpen(arguments[1]);
													this.funcForceclose();
												}
											}
											break;
							case	"3"	:
											if( fBrowser	==	"2" ){
												if( arguments[9]	==	"0" ){
													this.funcFlashEBookOpen(arguments);
													this.funcForceclose();
												}
											}else if( ( fBrowser	==	"3" )
													||
													  ( fBrowser	==	"4" )
													||
													  ( fBrowser	==	"5" )
													||
													  ( fBrowser	==	"6" ) ){
												if( arguments[9]	==	"0" ){
													this.funcFlashEBookOpen(arguments);
												}
											}else{
												if( arguments[9]	==	"0" ){
													this.funcPDFOpen(arguments[1]);
													this.funcForceclose();
												}
											}
											break;
							case	"4"	:
											if( fBrowser	==	"2" ){
												if( arguments[9]	==	"0" ){
													this.funcFlashEBookOpen(arguments);
													this.funcForceclose();
												}
											}else if( ( fBrowser	==	"3" )
													||
													  ( fBrowser	==	"4" )
													||
													  ( fBrowser	==	"5" )
													||
													  ( fBrowser	==	"6" ) ){
												if	(arguments[9]	==	"0"){
													this.funcFlashEBookOpen(arguments);
												}
											}else{
												this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
											}
											break;
							case	"5"	:
											if( fBrowser	==	"4" ){
												this.funcPDFOpen(arguments[1]);
											}else{
												if( arguments[9]	==	"0" ){
													this.funcPDFOpen(arguments[1]);
													this.funcForceclose();
												}
											}
											break;
							}
						}
						break;
//---<<< MacOSX OS >>>---//
		case	"2"	:
						switch(arguments[0]){
						case	"0"	:
										this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
										break;
						case	"1"	:
										if	( ( fBrowser	==	"2" )
											||
											  ( fBrowser	==	"3" )
											||
											  ( fBrowser	==	"4" )
											||
											  ( fBrowser	==	"5" ) ){
											if	(arguments[9]	==	"0"){
												this.funcFlashEBookOpen(arguments);
												this.funcForceclose();
											}
										}else{
											this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
										}
										break;
						case	"2"	:
										if	(arguments[9]	==	"0"){
											this.funcPDFOpen(arguments[1]);
											this.funcForceclose();
										}
										break;
						case	"3"	:
										if	( ( fBrowser	==	"2" )
											||
											  ( fBrowser	==	"3" )
											||
											  ( fBrowser	==	"4" )
											||
											  ( fBrowser	==	"5" ) ){
											if	(arguments[9]	==	"0"){
												this.funcFlashEBookOpen(arguments);
												this.funcForceclose();
											}
										}else{
											if	(arguments[9]	==	"0"){
												this.funcPDFOpen(arguments[1]);
												this.funcForceclose();
											}
										}
										break;
						case	"4"	:
										if	( ( fBrowser	==	"2" )
											||
											  ( fBrowser	==	"3" )
											||
											  ( fBrowser	==	"4" )
											||
											  ( fBrowser	==	"5" ) ){
											if	(arguments[9]	==	"0"){
												this.funcFlashEBookOpen(arguments);
												this.funcForceclose();
											}
										}else{
											this.funcAboutPageOpen(this.sAboutPageURL,fWinSizeHeight,fWinSizeWidth);
										}
										break;
						case	"5"	:
										if	(arguments[9]	==	"0"){
											this.funcPDFOpen(arguments[1]);
											this.funcForceclose();
										}
										break;
						}
		}
//---<<< 2010.11.19 Add Start >>>---//
		}
//---<<< 2010.11.19 Add End   >>>---//

	}else{
		alert(fCheck);
	}
//	return fCheck;
}


function funcParamCheck(aParam){
	var fCheck			=	"0";

//---<<< Open Flag Check >>>---//
	if	((aParam[0]		!=	"0")
		&&
		(aParam[0]		!=	"1")
		&&
		(aParam[0]		!=	"2")
		&&
		(aParam[0]		!=	"3")
		&&
		(aParam[0]		!=	"4")
		&&
		(aParam[0]		!=	"5")){
		fCheck			=	"1";
	}

//---<<< Book Code Check >>>---//
	if	(fCheck			==	"0"){
		if	(aParam[2]	==	""){
			fCheck		=	"2";
		}
	}

//---<<< Coop ID Check >>>---//
	if	(fCheck			==	"0"){
		if	(aParam[3]	==	""){
			fCheck		=	"3";
		}
	}

//---<<< Shade Type Check >>>---//
	if	(fCheck					==	"0"){
		if	((aParam[4]			!=	"")
			&&
			(aParam[4]			!=	null)){
			if	((aParam[4]		!=	"0")
				&&
				(aParam[4]		!=	"1")){
				fCheck			=	"4";
			}
		}
	}

//---<<< Open Flag & PDFUrl or ShadeType Check >>>---//
	if	(fCheck				==	"0"){
		switch(aParam[0]){
		case	"0"	:	break;
		case	"1"	:	if	(aParam[4]	==	""){
						fCheck		=	"5";
					}
					break;
		case	"2"	:	if	(aParam[1]	==	""){
						fCheck		=	"6";
					}
					break;
		case	"3"	:	if	(aParam[4]	==	""){
						fCheck		=	"7";
					}else{
						if	(aParam[1]	==	""){
							fCheck	=	"7";
						}
					}
					break;
		case	"4"	:	if	(aParam[4]	==	""){
						fCheck		=	"8";
					}
					break;
		case	"5"	:	if	(aParam[1]	==	""){
						fCheck		=	"9";
					}
					break;
		}
	}
	return fCheck;
}


function funcEBookOpen(aParam){
	if	(aParam[6]		!=	null){
		if	(aParam[7]	!=	null){
//--<<< 2010.11.19 Mod Start >>>---//
			OpenEBook.OpenBook(parseInt( aParam[2] ),
							aParam[3],
							aParam[6],
							aParam[7],
							aParam[8]);
		}else{
			OpenEBook.OpenBook(parseInt( aParam[2] ),
							aParam[3],
							aParam[6]);
		}
	}else{
			OpenEBook.OpenBook(parseInt( aParam[2] ) ,aParam[3]);
//--<<< 2010.11.19 Mod End   >>>---//
	}
}


function funcFlashEBookOpen(aParam){
	if	(aParam[6]		!=	null){
		if	(aParam[7]	!=	null){
			OpenFlashEBook.OpenFBook(aParam[2],
								aParam[3],
								aParam[4],
								aParam[5],
								aParam[6],
								aParam[7],
								aParam[8]);
		}else{
			OpenFlashEBook.OpenFBook(aParam[2],
								aParam[3],
								aParam[4],
								aParam[5],
								aParam[6]);
		}
	}else{
		if	(aParam[5]	!=	null){
			OpenFlashEBook.OpenFBook(aParam[2],
								aParam[3],
								aParam[4],
								aParam[5]);
		}else{
			OpenFlashEBook.OpenFBook(aParam[2],
								aParam[3],
								aParam[4]);
		}
	}
}

function funcPDFOpen(sURL){
	var eBookClient		=	window.open(sURL);
}

function funcAboutPageOpen(sURL,iWinHeight,iWinWidth){
//	var	iWinTop
//	=	(screen.height	-	iWinHeight)	/	2;
//	var	iWinLeft
//	=	(screen.width	-	iWinWidth)	/	2;

//	var	WinOption				=	"top="			+
//								iWinTop			+
//								", screenY="		+
//								iWinTop			+
//								", left="			+
//								iWinLeft			+
//								", screenX="		+
//								iWinLeft			+
//								", width="		+
//								iWinWidth			+
//								", height="		+
//								iWinHeight		+
//								", directories=no"	+
//								", location=no"	+
//								", menubar=no"		+
//								", resizable=no"	+
//								", scrollbars=no"	+
//								", status=no"		+
//								", toolbar=no";
//	var	eBookClient
//	=	window.open(sURL,"",WinOption);

	location.href=sURL;
	window.resizeTo(iWinWidth,iWinHeight);
}

function funcForceclose(){
	var NewWin = window.open("","","width=100,height=100");
	var oWin = eval(NewWin);

	if(navigator.appName=="Netscape"){
		if(oWin && !oWin.closed){
			NewWin.close();

			window.open("","_self");
			window.close();
		}
	}
	else{
		if(document.all&&(navigator.userAgent.match(/MSIE (\d\.\d)/),RegExp.$1)>=5.5){
			if(oWin && !oWin.closed){
				NewWin.close();

				var win = window.open("","_self");
				win.opener=window;
				win.close();
			}
		}
		else{
			if(oWin && !oWin.closed){
				NewWin.close();

				window.open("","_self");
				window.close();
				var timer=setTimeout("busy=false;funcForceclose()",500);
			}
		}
	}
}

soOpenEBookObj		=	new sfuncEBookSwitchInit();

//--<<< 2010.11.19 Add Start >>>---//
bReadyRedirect			=	true;
//--<<< 2010.11.19 Add End   >>>---//



