var eNewBook;

function eBookOpener() {
	this.winLimitWidth 	= 1024;
	this.winLimitHeight = 670;
	this.winWidth       = 0;
	this.winHeight      = 0;
	this.winLeft		= 0;
	this.winTop			= 0;
	this.winString		= null;
	this.Port           = null ; 
	this.Host       	= null;
	this.Service		= null;
	this.eBookUrl       = null;
	this.winStyle		= null;
	this.giWinType		= null;
	this.menuBar		=28;
	
	this.SetLaunchHTML  = SetLaunchHTML;
	this.OpenBook       = OpenBook;
	this.GetBorderSize  = GetBorderSize;
 	this.IsWinXP        = IsWinXP;
 	this.IsWinXPSP2		= IsWinXPSP2;
 	this.IsWin2k3		= IsWin2k3;
 	this.GetWinStyle	= GetWinStyle;
}

function SetLaunchHTML(arg_URL) {  //  open window in HTML
	// flash intro 3`YkJh}u/`Yp}3hqI)h	h}buTI)qfdh1q/`Yhxbhq /)hYEEkq/Vh}^kbqI)Yk	qEC I)hYhq1q/)Q9fffu/`b^hbhq[3`hhfqvqI)Ycff8q{3Vb1k	pC3)hqEhfqIVhYvJfq.
	arg_URL += "&wid="+this.winWidth+"&hei="+this.winHeight;
	var OpenHTML  = "<html>"
		+ "<body onload=\"oLaunch.click()\">"
		+ "<a id=\"oLaunch\" style=\"visibility:hidden\" href=\"" + this.eBookUrl  + arg_URL + "\">OpenEBook</a>"
		+ "</body></html>" ;

	return OpenHTML;
}

 function GetWinStyle() {  
 	this.winWidth   =  screen.width  ;
	this.winHeight  =  screen.height;
	if (screen.width  != screen.availWidth ) {this.winWidth  = screen.width  - 57 } // TaskBar Width
	if (screen.height != screen.availHeight) {this.winHeight = screen.height - 27 } // TaskBar Height

    this.winStyle    = "top=" + this.winTop + ", left=" + this.winLeft + ", width=" + this.winWidth + ", height=" + this.winHeight + ", directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no";
 }

function OpenBook() {
 	var aBorderInfo = this.GetBorderSize();
	
	try {
		var startLeft = 0;
		var startTop = 0;
		
	//	Set Screen Information
//giWindowType = 1 : FullSize
//giWindowType = 2 : Full App Size
//giWindowType = 3 : 1024 * 728
//giWindowType = 4 : 1280 * 1024

 	 	this.winWidth   =  screen.width;
 		this.winHeight  =  screen.height;
 		if (screen.width  != screen.availWidth ) { this.winWidth  = screen.width  - 57 } // TaskBar Width
 		if (screen.height != screen.availHeight) { this.winHeight = screen.height - 27 } // TaskBar Height		
		switch (parseInt(this.giWinType)) {
			case 1:
				this.winString = "fullscreen";
				break;
			case 2:
				this.winString = "fullscreen, scrollbars=no";
				break;
			case 3:
 	 			this.winWidth  = 1024;
 				this.winHeight = 768;
				startLeft = parseInt((screen.availWidth - (this.winWidth + 8)) / 2);
				startTop = parseInt((screen.availHeight - (this.winHeight + 50)) / 2);
 				
				this.winString = "top="+startTop+",left="+startLeft+",width="+this.winWidth+",height="+parseInt(this.winHeight)+",scrollbars=no";
				break;
			case 4:
 	 			this.winWidth   =  1280;
 				this.winHeight  =  1024;			
				startLeft = parseInt((screen.availWidth - (this.winWidth + 8)) / 2);
				startTop = parseInt((screen.availHeight - (this.winHeight + 50)) / 2);

				this.winString = "top="+startTop+",left="+startLeft+",width="+this.winWidth+",height="+parseInt(this.winHeight)+",scrollbars=no";
				break;
		}

		this.eBookUrl	= this.Host + ":" + this.Port + "/" + this.Service + "/ebook.asp?";
		if(typeof(eNewBook) == "undefined") {
			eNewBook = window.open("about:blank", "Yu_Jun_Kyu", this.winString);
		}

		with(eNewBook) {
			document.write(this.SetLaunchHTML(arguments[0]));
			document.close();
		}		
		
	} catch(exeption) {
		eNewBook.close();
		location.reload();
	}
} // End of Function

function GetBorderSize () {
	var aBorderInfo = new Array();
	
	aBorderInfo[0] = (this.IsWinXP()) ? 6  :  5;
	aBorderInfo[1] = (this.IsWinXP()) ? 32 : 24;

	return aBorderInfo;
}

function IsWinXP() {
	if (navigator.userAgent.indexOf("Windows NT 5.1") > 1 ) {return true;} 
	return false; // WinMe, Win9x, Win2k, Win2k  
}

function IsWinXPSP2() {
	if ( navigator.userAgent.indexOf("SV1") > 1 ) {return true;}
	return false;
}

function IsWin2k3(){
	if(navigator.userAgent.indexOf("Windows NT 5.2")> 1){return true;}
	return false;
}

var oBook = new eBookOpener();


