//////////////////////////////////////////////////////
//                                                  //
//   <<< EBook / FlashEBook Switch >>>              //
//                                                  //
//////////////////////////////////////////////////////
// ProgramName :                                    //
// Language    : JavaScript                         //
// Make Date   : 2006.05.30                         //
//////////////////////////////////////////////////////
// ‰ü’è—š—ð                                         //
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
function sfuncEBookSwitchInit(){
	this.funcEBookSwitch		=	funcEBookSwitch;
	this.funcParamCheck			=	funcParamCheck;
	this.funcEBookOpen			=	funcEBookOpen;
	this.funcFlashEBookOpen		=	funcFlashEBookOpen;
	this.funcPDFOpen			=	funcPDFOpen;
	this.funcAboutPageOpen		=	funcAboutPageOpen;

	this.sAboutPageURL
	=	"http://ebook.webcatalog.jp/skin/deco/7net/errorhtml/formultiebook.html";
	this.sEBookAboutPageURL
	=	"http://ebook.webcatalog.jp/skin/deco/7net/errorhtml/fortrueebook.html";
}

//////////////////////////////////////////////////////
// Paramater   : 0.Open = 0(EBook)                  //
//                        1(EBook,FlashEBook)       //
//                        2(EBook,PDF)              //
//                        3(EBook,FlashEBook,PDF)   //
//               1.PDFUrl(For PDF)                  //
//               2.BookCode                         //
//               3.CoopID                           //
//               4.ShadeType(For FlashEBook)        //
//               5.ViewerName(For FlashEBook)       //
//               6.OpenPageNo                       //
//               7.StartPageNo                      //
//               8.EndPageNo                        //
//////////////////////////////////////////////////////
function funcEBookSwitch(){
	var	fCheck				=	"";
	var	fOS					=	"";
	var	fBrowser			=	"";

	fCheck					=	this.funcParamCheck(arguments);

	if	(fCheck				==	"0"){
		fOS					=	soComLib.funcGetOs();
		fBrowser			=	soComLib.funcGetBrowser();

		switch(fOS){
//---<<< Other OS >>>---//
		case	"0"	:
//---<<< For PDF >>>---//
						if	((arguments[0]		==	"2")
							||
							(arguments[0]		==	"3")){
							this.funcPDFOpen(arguments[1]);
						}else{
//---<<< For SpecWindow >>>---//
							if	(arguments[0]	==	"0"){
								this.funcAboutPageOpen(this.sEBookAboutPageURL,
														430,
														350);
							}else{
								this.funcAboutPageOpen(this.sAboutPageURL,
														430,
														620);
							}
						}
						break;
//---<<< Windows OS >>>---//
		case	"1"	:
//---<<< For InternetExplorer >>>---//
						if	(fBrowser	==	"1"){
							this.funcEBookOpen(arguments);
						}else{
							switch(arguments[0]){
							case	"0"	:
											this.funcAboutPageOpen(this.sEBookAboutPageURL,430,350);
											break;
							case	"1"	:
											if	(fBrowser	==	"2"){
												this.funcFlashEBookOpen(arguments);
											}else{
												this.funcAboutPageOpen(this.sAboutPageURL,430,620);
											}
											break;
							case	"2"	:
											this.funcPDFOpen(arguments[1]);
											break;
							case	"3"	:
											if	(fBrowser	==	"2"){
												this.funcFlashEBookOpen(arguments);
											}else{
												this.funcPDFOpen(arguments[1]);
											}
											break;
							}
						}
						break;
//---<<< MacOSX OS >>>---//
		case	"2"	:
						switch(arguments[0]){
						case	"0"	:
										this.funcAboutPageOpen(this.sEBookAboutPageURL,430,350);
										break;
						case	"1"	:
										if	((fBrowser	==	"2")
											||
											(fBrowser	==	"3")){
											this.funcFlashEBookOpen(arguments);
										}else{
											this.funcAboutPageOpen(this.sAboutPageURL,430,620);
										}
										break;
						case	"2"	:
										this.funcPDFOpen(arguments[1]);
										break;
						case	"3"	:
										if	((fBrowser	==	"2")
											||
											(fBrowser	==	"3")){
											this.funcFlashEBookOpen(arguments);
										}else{
											this.funcPDFOpen(arguments[1]);
										}
										break;
						}
		}
	}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")){
		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	=	"8";
							}
						}
						break;
		}
	}

	return fCheck;
}


function funcEBookOpen(aParam){
	if	(aParam[6]		!=	null){
		if	(aParam[7]	!=	null){
			OpenEBook.OpenBook(aParam[2],
								aParam[3],
								aParam[6],
								aParam[7],
								aParam[8]);
		}else{
			OpenEBook.OpenBook(aParam[2],
								aParam[3],
								aParam[6]);
		}
	}else{
			OpenEBook.OpenBook(aParam[2],aParam[3]);
	}

}


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,iWinWidth,iWinHeight){
	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);
}

soOpenEBookObj		=	new sfuncEBookSwitchInit();
