var EBOOK_JS_VERSION="2.0.0.9";
var e_isIEBrowser=true;
if(window.navigator.userAgent.toLowerCase().indexOf("msie ")>=0) e_isIEBrowser=true;
else e_isIEBrowser=false;
var e_isSafari=false;
if(window.navigator.userAgent.toLowerCase().indexOf("safari")>=0) e_isSafari=true;
var e_absHref="";
var e_absURL="";
var e_docBaseURL="";
var e_fitZoomLevel=0;
var e_viewRatio=1;
var e_initComplete=false;
var e_initLinkComplete=false;
var e_isLinkEditMode=false;
var e_coverPageFix=0;
var e_screenColorDepth=32;
var e_arrRequestVar;
var e_arrEvent=new Array();
var e_isUnload=false;
var e_arrAppendFrame=new Array();
var e_oReadBin;
var e_localPath="";
var e_bReadBinUse=false;
var e_bRemovedDefEventListner=false;
var e_RClick;

function ebook_setLoadingImg(evt){
	try{
		if(!e_initComplete){
			if(ebook_loading.style.visibility=="hidden"){
				var rect
				try{ rect=ebook_getElementRect(td_arrange); }
				catch(ae){setTimeout("ebook_setLoadingImg()","2");}
				if(rect.w<10){
					setTimeout("ebook_setLoadingImg()","2");
					return;
				}
				ebook_loading.style.visibility = "visible";
				var img_rect = ebook_getElementRect(ebook_loading);
				ebook_loading.style.left = rect.x + (rect.w-img_rect.w)/2;
				ebook_loading.style.top = rect.y + (rect.h-img_rect.h)/2;
			}
		}else ebook_loading.style.display="none";
	}catch(e){}
}
function ebook_writeLoadingImage(){
	if(e_isIEBrowser) document.write('<img id="ebook_loading" name="ebook_loading" src="'+e_iconDirectory+'/load_album.gif" border="0" GALLERYIMG="no" style="position:absolute;left:0px;top:0px;visibility:hidden;" onselect="javascript:return false;" onload="javascript:ebook_setLoadingImg(event);">');
}
ebook_writeLoadingImage();
function ebook_request(name,value){
	this.name=name.toLowerCase();
	this.value=value;
}
function ebook_getRequestVar(name){
	var ret="";
	var sName = name.toLowerCase();
	for(var i=0;i<e_arrRequestVar.length;i++){
		if(sName=="startpage"){
			if( e_arrRequestVar[i].name=="startpage" ||  e_arrRequestVar[i].name=="page"){
				ret = e_arrRequestVar[i].value;
				break;
			}else if(e_arrRequestVar[i].name=="rpage"){
				try{
					ret=parseInt(e_arrRequestVar[i].value)+ebook_getPageFix();
					break;
				}catch(e){break;}
			}
		}else if( e_arrRequestVar[i].name==sName){
			ret = e_arrRequestVar[i].value;
			break;
		}
	}
	return ret;
}
function ebook_initRequestVar(){
	e_arrRequestVar=new Array();
	var strHref=document.location.href;
	if(strHref.lastIndexOf("?")>0){
		strHref = strHref.substring( strHref.lastIndexOf("?")+1 );
		var arr_1 = strHref.split("&");
		for(var i=0; i<arr_1.length;i++){
			var arr_2 = arr_1[i].split("=");
			if(arr_2.length==2){
				var oParam = new ebook_request(arr_2[0], arr_2[1]);
				e_arrRequestVar.push(oParam);
			}
		}
	}
}
ebook_initRequestVar();
function ebook_event(name,func){
	this.name=name.toLowerCase();
	this.func=func;
}
function ebook_getEvtLsnrIdx(name,func){
	for(var i=0; i<e_arrEvent.length;i++){
		var oEvt = e_arrEvent[i];
		if(oEvt.name==name.toLowerCase() && oEvt.func==func) return i;
	}
	return -1;
}
function ebook_addEventListener(name,func){
	if(ebook_getEvtLsnrIdx(name,func)<0){
		var oEvent = new ebook_event(name,func);
		e_arrEvent.push(oEvent);
	}
}
function ebook_removeEventListener(name,func){
	var idx=ebook_getEvtLsnrIdx(name,func);
	if(idx>=0){
		var arrPre = e_arrEvent.slice(0, idx);
		var arrNext = e_arrEvent.slice(idx+1,e_arrEvent.length);
		e_arrEvent = arrPre.concat(arrNext);
	}
}
function ebook_dispatchEvent(){
	var args = ebook_dispatchEvent.arguments;
	var name = args[0].toLowerCase();
	for(var i=0; i<e_arrEvent.length;i++){
		var oEvt = e_arrEvent[i];
		if(oEvt.name==name){
			var command = oEvt.func + "(";
			for(var j=1;j<args.length;j++){
				command += "'" + args[j] + "'"
				if(j<args.length-1) command += ",";
			}
			command += ")";
			try{eval(command);}catch(e){};
		}
	}
}
function ebook_rect(){
	this.x=0;
	this.y=0;
	this.w=0;
	this.h=0;
}
function ebook_point(){
	this.x=0;
	this.y=0;
}
function ebook_getElementRect(obj){
	var ret = new ebook_rect();
	try{
		if(e_isIEBrowser){
			var rect = obj.getBoundingClientRect();
			ret.x=rect.left-2;
			ret.y=rect.top-2;
			ret.w=rect.right-rect.left;
			ret.h=rect.bottom-rect.top;
		}else{
			ret.x=obj.offsetLeft;
			ret.y=obj.offsetTop;
			var parent = obj.offsetParent;
			while(parent!=null){
				ret.x = ret.x + parent.offsetLeft;
				ret.y = ret.y + parent.offsetTop;
				parent=parent.offsetParent;
			}
			ret.w = obj.offsetWidth;
			ret.h = obj.offsetHeight;
		}
	}catch(e){}
	return ret;
}
function ebook_calcZoomRect(zoomLevel){
	var ret = new ebook_rect();
	var ratio = Math.pow(2,e_maxZoomLevel)/Math.pow(2,zoomLevel);
	var width = Math.floor(e_canvasWidth/ratio);
	var height = Math.floor(e_canvasHeight/ratio);
	if(e_isDoublePage && !e_isOneImgTwoPage){
		if(e_isVerticalTurn) height=2*height;
		else width = 2*width;
	}
	
	ret.w=width;
	ret.h=height;
	return ret;
}
var ebook_mouseDownButton=0;
function ebook_eventObj(evt, isIE){
	var relatedID="";
	if(isIE){
		this.srcElement=evt.srcElement;
		this.x = evt.offsetX + evt.srcElement.offsetLeft;
		this.y = evt.offsetY + evt.srcElement.offsetTop;
		this.button = evt.button;
		if(evt.type=="mouseover") relatedID = evt.fromElement.id;
		else if(evt.type=="mouseout") relatedID = evt.toElement.id;
	}else{
		this.srcElement=evt.target;
		this.x = evt.layerX + evt.target.offsetLeft;
		this.y = evt.layerY + evt.target.offsetTop;
		if(e_isSafari) this.button = evt.button;
		else if(evt.type=="mousedown" || evt.type=="mousemove" || evt.type=="mouseup" || evt.type=="click"){
			if( evt.type=="mousemove" ) this.button=ebook_mouseDownButton;
			else if(evt.button==0) this.button=1;
			else if(evt.button==1) this.button=4;
			else this.button=evt.button;
			
			if(evt.type=="mousedown") ebook_mouseDownButton=this.button;
			else if( evt.type=="mouseup" && ebook_mouseDownButton>0){
				this.button=ebook_mouseDownButton;
				ebook_mouseDownButton=0
			}
		}else this.button = 0;
		if(evt.type=="mouseover" || evt.type=="mouseout") relatedID = evt.relatedTarget.id;
	}
	
	this.bFire = true;
	if( evt.type=="click" && relatedID.indexOf("link_obj_")==0) 
		this.bFire = false;
	else if( (evt.type=="mouseover" || evt.type=="mouseout") && relatedID.indexOf("link_obj_")==0 )
		this.bFire = false;

	this.ctrlKey = evt.ctrlKey;
	this.altKey = evt.altKey;
	this.shiftKey = evt.shiftKey;
}
function ebook_mouseUp(evt){
	if(!ebook_bCommandDliver() || e_bRemovedDefEventListner) return;
	try{
		var oEvt = new ebook_eventObj(evt, e_isIEBrowser);
		if(oEvt.button==1 && link_checkIsLinkClick() ) return;
		if(oEvt.bFire) dBook.ext_mouseUp(oEvt.x,oEvt.y,oEvt.button,oEvt.ctrlKey,oEvt.altKey,oEvt.shiftKey);
	}catch(e){}
}
function ebook_mouseDown(evt){
	if(!ebook_bCommandDliver() || e_bRemovedDefEventListner) return false;
	try{
		var oEvt = new ebook_eventObj(evt, e_isIEBrowser);
		if(oEvt.bFire) dBook.ext_mouseDown(oEvt.x,oEvt.y,oEvt.button,oEvt.ctrlKey,oEvt.altKey,oEvt.shiftKey);
		if (evt.preventDefault) {
			evt.preventDefault();
		}else {
			evt.cancelBubble=true;
			return false;
		}
	}catch(e){return false;}
}
function ebook_mouseMove(evt){
	if(!ebook_bCommandDliver() || e_bRemovedDefEventListner) return;
	try{
		var oEvt = new ebook_eventObj(evt, e_isIEBrowser);
		if(oEvt.bFire) dBook.ext_mouseMove(oEvt.x,oEvt.y,oEvt.button,oEvt.ctrlKey,oEvt.altKey,oEvt.shiftKey);
		if (evt.preventDefault) {
			evt.preventDefault();
		}else {
			evt.cancelBubble = true;
			return false;
		}
	}catch(e){}
}
function ebook_mouseOver(evt){
	if(!ebook_bCommandDliver() || e_bRemovedDefEventListner) return;
	try{
		var oEvt = new ebook_eventObj(evt, e_isIEBrowser);
		if(oEvt.bFire){
			dBook.ext_mouseOver(oEvt.x,oEvt.y,oEvt.button,oEvt.ctrlKey,oEvt.altKey,oEvt.shiftKey);
			link_mouseOverDBook();
			ebook_dispatchEvent("mouseOver", oEvt.x, oEvt.y, oEvt.button);
		}
	}catch(e){}
}
function ebook_mouseOut(evt){
	if(!ebook_bCommandDliver() || e_bRemovedDefEventListner) return;
	try{
		var oEvt = new ebook_eventObj(evt, e_isIEBrowser);
		if(oEvt.bFire){
			dBook.ext_mouseOut(oEvt.x,oEvt.y,oEvt.button,oEvt.ctrlKey,oEvt.altKey,oEvt.shiftKey);
			link_mouseOutDBook();
			ebook_dispatchEvent("mouseOut", oEvt.x, oEvt.y, oEvt.button);
		}
	}catch(e){}
}
function ebook_click(evt){
	if(!ebook_bCommandDliver() || e_bRemovedDefEventListner) return;
	try{ if(dBook.handle_isRunAutoFlip()==1) ebook_stopAutoFlip(); }catch(e){}
	try{
		link_click();
		var oEvt = new ebook_eventObj(evt, e_isIEBrowser);
		if(oEvt.bFire) dBook.ext_mouseClick(oEvt.x,oEvt.y,oEvt.button,oEvt.ctrlKey,oEvt.altKey,oEvt.shiftKey);
	}catch(e){}
}
function ebook_mouseWheel(evt){
	if(!ebook_bCommandDliver()) return;
	if(e_bSupportMouseWheel){
		var zoomLevel = ebook_getCurrZoomStep();
		if(zoomLevel==e_fitZoomLevel){
			if(evt.wheelDelta>0){
				if(e_isOldTurn) ebook_pressRightPage();
				else ebook_pressLeftPage();
			}else if(evt.wheelDelta<0){
				if(e_isOldTurn) ebook_pressLeftPage();
				else ebook_pressRightPage();
			}
		}else{
			ebook_pressScroll(0,-1*parseInt(evt.wheelDelta/5));
		}
	}
	try{
		evt.cancelBubble=true;
		evt.returnValue=false;
	}catch(e){}
}
function ebook_bCommandDliver(){
	if(e_initComplete && !e_isUnload) return true;
	else return false
}
var e_printInitEnd=false;
var e_isPrintMode=false;
function ebook_pressPrint(){
	if(e_initComplete){
		if(e_printInitEnd) setTimeout("ebook_printLoadPage()", 50);
		else{
			var sHtml="";
			if(e_isIEBrowser){
				sHtml+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="dBookPrint" name="dBookPrint"  width="100%" height="100%" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" border="0" onselect="javascript:return false;">';
				sHtml+= '<param name="movie" value="appendix/PagePrint.swf" />';
				sHtml+= '<param name="quality" value="high" />';
				sHtml+= '<param name="wmode" value="opaque" />';
				sHtml+= '<param name="bgcolor" value="#ffffff" />';
				sHtml+= '<param name="allowScriptAccess" value="sameDomain" />';
				sHtml+= '<param name="allowFullScreen" value="true" />';
				sHtml+= '</object>';
			}else{
				sHtml+='<embed src="appendix/PagePrint.swf" quality="high" wmode="opaque" bgcolor="#ffffff" width="100%" height="100%" id="dBookPrint" name="dBookPrint" align="middle" type="application/x-shockwave-flash" allowScriptAccess="sameDomain" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" onselect="javascript:return false;"/>';
			}
			div_print.innerHTML = sHtml;
		}
		ebook_addEventListener("endFlip", "ebook_printLoadPage");
		var rect = ebook_getElementRect(tbl_viewArea);
		
		var width=800, height=600, ratio;
		if( width>rect.w || height>rect.h){
			if( width/rect.w>=height/rect.h){
				height = height*rect.w/width;
				width = rect.w;
			}else{
				width = width*rect.h/height;
				height = rect.h;				
			}
		}
		div_print.style.width=width;
		div_print.style.height=height;
		div_print.style.left = rect.x + (rect.w-width)/2;
		div_print.style.top = rect.y + (rect.h-height)/2;
		e_isPrintMode = true;
	}
}
function ebook_printInitEnd(){
	e_printInitEnd=true;
	setTimeout("ebook_printLoadPage()", 50);
}
function ebook_printLoadPage(){
	if(e_isPrintMode){
		var page;
		if(e_isDoublePage && e_isOldTurn) page =ebook_getRightSlidePage();
		else page = ebook_getLeftSlidePage();
		dBookPrint.print_loadPage(page);
	}
}
function ebook_printCancel(){
	e_isPrintMode = false;
	div_print.style.top=0;
	div_print.style.left=0;
	div_print.style.width=0;
	div_print.style.height=0;
	ebook_removeEventListener("endFlip", "ebook_printLoadPage");
}
function ebook_gotoPage(page){
	var toPage = parseInt(page);
	if(!isNaN(toPage)){
		toPage = toPage - ebook_getPageFix();
		dBook.handle_inputGotoPage(toPage);
	}
}
function ebook_pressAutoFlip(ipt){
	var delay = parseInt(ipt.value);
	if(isNaN(delay) || delay<=0.1 ) delay = 0.1;
	
	dBook.handle_pressAutoFlip(delay*1000,1);

	ipt.value="";
}
function ebook_stopAutoFlip(){
	dBook.handle_stopAutoFlip();
}
function ebook_setLinkEdit(){ 
	try{
		try{link_hide();}catch(ae){}
		if(e_isLinkEditMode){
			e_isLinkEditMode = false;
			if(ebook_bCommandDliver()) dBook.handle_editLink(false);
			ebook_cover.style.visibility="hidden";
		}else{
			e_isLinkEditMode = true;
			if(ebook_bCommandDliver()) dBook.handle_editLink(true);
			ebook_cover.style.visibility="visible";
		}
	}catch(e){} 
}
function ebook_pressFullScreen(){ try{if(ebook_bCommandDliver()) dBook.handle_pressFullScreen();}catch(e){} }
function ebook_pressPause(){ try{if(ebook_bCommandDliver()) dBook.handle_pressPause();}catch(e){} }
function ebook_closeUp(){ 
	if(e_isLinkEditMode) return;
	try{if(ebook_bCommandDliver() && !e_bRemovedDefEventListner) dBook.handle_pressCloseUp();}catch(e){} 
}
function ebook_pressLeftZoom(){
	var zLevel = ebook_getCurrZoomStep();
	var vRect = ebook_getCurZoomRect();
	var zRect = ebook_calcZoomRect(zLevel)
	var bndState = dBook.handle_getBoundState();
	if(bndState=="right"){
		if(zLevel==e_fitZoomLevel) return;
		else ebook_pressLeftPage();
	}
	if( zLevel==e_maxZoomLevel)
		ebook_pressScroll(-zRect.w,-zRect.h);
	else
		ebook_pressZoom(1,0,-zRect.h);
}
function ebook_pressRightZoom(){
	var zLevel = ebook_getCurrZoomStep();
	var vRect = ebook_getCurZoomRect();
	var zRect = ebook_calcZoomRect(zLevel)
	var bndState = dBook.handle_getBoundState();
	if(bndState=="left"){
		if(zLevel==e_fitZoomLevel) return;
		else ebook_pressRightPage();
	}
	if( zLevel==e_maxZoomLevel)
		ebook_pressScroll(zRect.w,-zRect.h);
	else
		ebook_pressZoom(1,zRect.w,-zRect.h);	
}
function ebook_pressZoom(dir,x,y){if(ebook_bCommandDliver())  try{dBook.handle_pressZoom(dir,x,y);}catch(e){}}
function ebook_pressScroll(x,y){if(ebook_bCommandDliver()) try{dBook.handle_pressScroll(x,y);}catch(e){}}
function ebook_pressLeftEndPage(){if(ebook_bCommandDliver())  try{dBook.handle_pressLeftEndPage();}catch(e){} }
function ebook_pressLeftPage(){if(ebook_bCommandDliver())  try{dBook.handle_pressLeftPage();}catch(e){} }
function ebook_pressRightPage(){if(ebook_bCommandDliver())  try{dBook.handle_pressRightPage();}catch(e){} }
function ebook_pressRightEndPage(){if(ebook_bCommandDliver())  try{dBook.handle_pressRightEndPage();}catch(e){} }
function ebook_getPageFix(){return e_pageFix+e_coverPageFix}
function ebook_getConfigVar(val){
	var ret="";
	try{ret=eval(val);}catch(e){}
	return ret;
}
function ebook_getCurZoomRect(){
	var sBound =  dBook.handle_getCurrZoomArea();
	var arrBound = sBound.split(",");
	var ret = new ebook_rect();
	if(arrBound.length==4){
		ret.x=parseInt(arrBound[0]);
		ret.y=parseInt(arrBound[1]);
		ret.w=parseInt(arrBound[2]);
		ret.h=parseInt(arrBound[3]);
	}
	return ret;
}
function ebook_getLeftSlidePage(){return dBook.handle_getLeftSlidePage();}
function ebook_getRightSlidePage(){return dBook.handle_getRightSlidePage();}
function ebook_getSlideTotal(){return dBook.handle_getSlideTotal();}
function ebook_getCurrZoomStep(){ try{ return dBook.handle_getCurrZoomStep();}catch(e){return e_fitZoomLevel;} }
function ebook_cursor(cur){if(viewerDiv.css) viewerDiv.css.cursor=cur; else viewerDiv.style.cursor=cur; }
function ebook_getFitZoomLevel(){
	if(!e_bHavePlayer &&  g_sWork!="editVoice" && e_bFitViewerToWindow && (e_maxZoomLevel-e_ghostZoomLevel)>0){
		var basicRect = ebook_calcZoomRect(e_fitZoomLevel);
		var maxRect = ebook_getMaxViewRect();
		var ratioW = maxRect.w/basicRect.w;
		var ratioH = maxRect.h/basicRect.h;
		var ratio;
		if(ratioW>=ratioH) ratio = ratioH;
		else ratio=ratioW;

		if(ratio>=e_fitRatio) e_fitZoomLevel=1;
		else e_fitZoomLevel=0;
	}else{
		e_fitZoomLevel=0;
	}
	return e_fitZoomLevel;
}
function ebook_getViewBoundRect(){
	var ret;
	if(e_maxBoundWidth==0 || e_maxBoundHeight==0)
		ret=ebook_getElementRect(tbl_viewArea);
	else{
		var ret = new ebook_rect();
		ret.w=e_maxBoundWidth;
		ret.h=e_maxBoundHeight;
	}
	return ret;
}
function ebook_getMaxViewRect(){
	var ret = new ebook_rect();
	var gapW = 2*e_borderThick+e_boundGap+6;
	var gapH = 2*e_borderThick+e_boundGap+6;
	if(e_maxBoundWidth==0 || e_maxBoundHeight==0){
		try{
			var bodyRect = new ebook_rect();
			if(window.innerWidth){
				bodyRect.w=window.innerWidth;
				bodyRect.h=window.innerHeight;				
			}else{
				bodyRect.w=document.body.clientWidth;
				bodyRect.h=document.body.clientHeight;
			}
			var mainRect;
			try{mainRect=ebook_getElementRect(mainTable);}
			catch(ae){mainRect = new ebook_rect();}
			if(mainRect.w==0 || mainRect.h==0){
				mainRect.w = bodyRect.w;
				mainRect.h = bodyRect.h;
			}
			
			var viewRect=ebook_getViewBoundRect();
			try{
				if(e_bViewBorderImg){
					var rect1 = ebook_getElementRect(skin_BorderLeft);
					var rect2 = ebook_getElementRect(skin_BorderRight);
					if(rect1.w<4) rect1.w=14;
					if(rect2.w<4) rect2.w=13;
					gapW = gapW + rect1.w + rect2.w;
					rect1 = ebook_getElementRect(skin_BorderTop);
					rect2 = ebook_getElementRect(skin_BorderBottom);
					gapH = gapH + rect1.h + rect2.h;
				}
			}catch(ae){}
			
			if(mainRect.w>0 && mainRect.h>0 && viewRect.w>0 && viewRect.h>0){
				ret.w = bodyRect.w - (mainRect.w-viewRect.w)-gapW;
				ret.h = bodyRect.h - (mainRect.h-viewRect.h)-gapH;
			}
		}catch(e){}
	}else{
		ret.w = e_maxBoundWidth-gapW;
		ret.h = e_maxBoundHeight-gapH;
	}
	return ret;
}
function ebook_resizeAll(bndState){
	if(e_isUnload || !e_initLinkComplete || !e_initComplete) return;
	ebook_dispatchEvent("resizeStart");
	var zoomLevel = ebook_getCurrZoomStep();
	var basicRect = ebook_calcZoomRect(e_fitZoomLevel);
	var zoomRect = ebook_calcZoomRect(zoomLevel);
	var strPosition="static";
	var ratio=1;
	
	if( e_bFitViewerToWindow || e_bDbookExtend){
		try{
			var viewRect=ebook_getViewBoundRect();
			var maxRect = ebook_getMaxViewRect();

			if(maxRect.w>0 && maxRect.h>0 && viewRect.w>0 && viewRect.h>0){
				if(zoomLevel==e_fitZoomLevel){
					if(e_bFitViewerToWindow){
						var ratioW = maxRect.w/basicRect.w;
						var ratioH = maxRect.h/basicRect.h;
						if(ratioW>=ratioH) ratio = ratioH;
						else ratio=ratioW;
						
						var nW = Math.floor(basicRect.w*ratio);
						var nH = Math.floor(basicRect.h*ratio);
						if(e_isDoublePage){
							if(e_isVerticalTurn){
								if( (nH%2)==1 )  nH=nH-1;
								ratio = nH/basicRect.h;
							}else{
								if( (nW%2)==1 )  nW=nW-1;
								ratio = nW/basicRect.w;		
							}
						}
						
						basicRect.w = Math.round(basicRect.w*ratio);
						basicRect.h = Math.round(basicRect.h*ratio);
					}
				}else{
					if(e_bDbookExtend){
						if(zoomRect.w>maxRect.w || zoomRect.h>maxRect.h){
							if(e_isIEBrowser){
								if(maxRect.w>=zoomRect.w){
									basicRect.w = zoomRect.w;
									basicRect.x = viewRect.x+Math.floor( (viewRect.w-zoomRect.w)/2 );
								}else{
									basicRect.w = viewRect.w-2*(e_borderThick+1);
									basicRect.x = viewRect.x+1;
								}
								if(maxRect.h>=zoomRect.h){
									basicRect.h = zoomRect.h;
									basicRect.y = viewRect.y+Math.floor( (viewRect.h-zoomRect.h)/2 );
								}else{
									basicRect.h = viewRect.h-2*(e_borderThick+1);
									basicRect.y = viewRect.y+1;
								}
								if(e_maxBoundWidth==0 || e_maxBoundHeight==0) strPosition="absolute";
							}else{
								if(maxRect.w>=zoomRect.w) basicRect.w = zoomRect.w;
								else basicRect.w=maxRect.w;
								if(maxRect.h>=zoomRect.h) basicRect.h = zoomRect.h;
								else basicRect.h = maxRect.h;
							}
						}else{
							basicRect.w = zoomRect.w;
							basicRect.h = zoomRect.h;
						}
					}else if(e_bFitViewerToWindow){
						basicRect.w = dBook.style.width;
						basicRect.h = dBook.style.height;
					}
				}
			}
		}catch(ae){}
	}
	
	if(ratio==1) dBook.handle_resize(basicRect.w, basicRect.h);
	else dBook.handle_resize(basicRect.w, basicRect.h, ratio);
	
	if(typeof(bndState)!="string") bndState = dBook.handle_getBoundState();
	var posX=0;
	var bndW=basicRect.w;
	if(bndState!="all"){
		if( zoomLevel==e_fitZoomLevel ){
			bndW=Math.floor(bndW/2);
			if(bndState=="right") posX=bndW;
		}else{
			bndW=Math.floor(zoomRect.w/2);
			if(bndW>basicRect.w) bndW=basicRect.w;
		}
	}
	
	if( (zoomLevel==e_fitZoomLevel || strPosition=="static") && e_bCoverSlide && !e_bCenterView){
		var gapW;
		if(e_bViewBorderImg){
			var rect1 = ebook_getElementRect(skin_BorderLeft);
			var rect2 = ebook_getElementRect(skin_BorderRight);
			gapW = rect1.w + rect2.w;
		}else
			gapW=2*e_borderThick;
		
		td_arrange.style.width=basicRect.w+gapW;
	}else
		td_arrange.style.width=0;

	ebook_setBoarder(bndState, zoomLevel, strPosition);

	ebook_dBookResize(-1*posX,0,bndW,basicRect.h);
	
	ebook_cover.style.width = basicRect.w;
	ebook_cover.style.height = basicRect.h;
	ebook_linkDiv.style.left=-1*posX;
	ebook_linkDiv.style.top=-1*basicRect.h;
	if(e_isIEBrowser && (!e_bViewBorderImg || (e_bDbookExtend && zoomLevel>e_fitZoomLevel) ) ){
		viewerDiv.style.width=bndW+2*e_borderThick;
		viewerDiv.style.height=basicRect.h+2*e_borderThick;
	}else{
		viewerDiv.style.width=bndW;
		viewerDiv.style.height=basicRect.h
	}
	if(strPosition=="static"){
		viewerDiv.style.position=strPosition;
		viewerDiv.style.left=0;
		viewerDiv.style.top=0;
	}else{
		viewerDiv.style.position=strPosition;
		if(bndW==basicRect.w) viewerDiv.style.left=basicRect.x;
		else viewerDiv.style.left = basicRect.x + (basicRect.w-bndW)/2;
		
		viewerDiv.style.top=basicRect.y;
	}
	e_viewRatio = ratio;
	setTimeout("try{link_resize();}catch(e){}",20);
	ebook_dispatchEvent("resizeAll");
}
function ebook_dBookResize(x,y,w,h){
	dBook.style.width = w ;
	dBook.style.height = h ;
	dBook.style.left = 0;
	dBook.style.top = 0;
	dBook.handle_move(x,0);
}
function event_mouseDown(mx, my, button){
	ebook_dispatchEvent("mouseDown", mx, my, button);
}
function event_mouseUp(mx, my, button){
	ebook_dispatchEvent("mouseUp", mx, my, button);
}
function event_mouseMove(mx, my, button){
	ebook_dispatchEvent("mouseMove", mx, my, button);
}
function event_startAutoFlip(){
	ebook_dispatchEvent("startAutoFlip");
}
function event_endAutoFlip(){
	ebook_dispatchEvent("endAutoFlip");
}
function event_mouseLinkOver(linkid){
	setTimeout("try{link_mouseOver("+linkid+");}catch(e){}",1);
}
function event_mouseLinkOut(linkid){
	setTimeout("try{link_mouseOut("+linkid+");}catch(e){}",1);
}
function event_linkPlayState(type, linkid){
	setTimeout("try{link_playStateHandler('"+type+"',"+linkid+");}catch(e){}",10);
}
function event_scroll(){
	setTimeout("try{link_resize();}catch(e){}",0);
	ebook_dispatchEvent("scroll");
}
function event_endInitLink(){
	e_initLinkComplete = true;
	ebook_resizeAll();
	if(e_initComplete) setTimeout("try{link_reload("+e_initLinkComplete+");}catch(e){}",1);
	ebook_dispatchEvent("endInitLink");
}
function event_turnResize(scale,preBndStr,curBndStr, isFirstSlide){
	isFirstSlide=eval(isFirstSlide);
	scale=eval(scale);
	
	if(!isFirstSlide && preBndStr!="all" && curBndStr=="all" && scale==0)
		ebook_setBoarder(curBndStr, e_fitZoomLevel);
	else if(isFirstSlide && preBndStr=="all" && curBndStr!="all" && scale==1)
		ebook_setBoarder(curBndStr, e_fitZoomLevel);
	else if(preBndStr!="all" && curBndStr!="all"){
		if(!isFirstSlide && scale==1) ebook_setBoarder(curBndStr, e_fitZoomLevel);
		else if(isFirstSlide && scale==1) td_arrange.align="center";
	}
	
	var rect = ebook_calcZoomRect(e_fitZoomLevel);
	var posW, bndW, bndH;
	
	bndH = Math.floor(rect.h * e_viewRatio);
	if(preBndStr!="all" && curBndStr!="all"){
		rect.w = Math.floor(rect.w * e_viewRatio/2);	
		bndW = Math.floor(rect.w* scale);
		if(curBndStr=="right"){
			if(isFirstSlide) posW = -1*(rect.w-bndW);
			else posW =-1*(rect.w);
		}else{
			if(isFirstSlide) posW =-1*(rect.w);
			else posW= -1*(rect.w-bndW);
		}
	}else{
		rect.w = Math.floor(rect.w * e_viewRatio);
		bndW = Math.floor(rect.w* (0.5 + scale/2));
		
		if(curBndStr=="right" || preBndStr=="right") posW =-1*(rect.w-bndW);
		else posW=0;
	}
	ebook_dBookResize(posW,0,bndW,bndH);
	ebook_linkDiv.style.left = posW;
	if(e_isIEBrowser && !e_bViewBorderImg) viewerDiv.style.width = bndW+2*e_borderThick;
	else viewerDiv.style.width = bndW;
	
	ebook_dispatchEvent("turnResize", scale,preBndStr,curBndStr, isFirstSlide);
}
function ebook_setBoarder(curBndStr, zLevel, strPosition){
	if( typeof(strPosition)=="undefined" ) strPosition=viewerDiv.style.position
	if( (zLevel==e_fitZoomLevel || !e_bDbookExtend) ){
		if( curBndStr=="left" ){
			td_arrange.align="left";
		}else if(curBndStr=="right"){
			td_arrange.align="right";
		}
	}
	
	if(e_bViewBorderImg){
		if(zLevel==e_fitZoomLevel || !e_bDbookExtend){
			viewerDiv.style.border = "0px solid "+e_borderColor;
			skin_BorderTop.style.visibility="visible";
			skin_BorderBottom.style.visibility="visible";
			if( curBndStr=="left" ){
				tbl_BorderRight.style.visibility="hidden";
				skin_BorderTop_Right.style.visibility="hidden";
				skin_BorderBottom_Right.style.visibility="hidden";
				tbl_BorderLeft.style.visibility="visible";
				skin_BorderTop_Left.style.visibility="visible";
				skin_BorderBottom_Left.style.visibility="visible";
				skin_BorderRight.style.borderLeft=e_borderThick+"px solid "+e_borderColor;
				skin_BorderLeft.style.borderRight="0px solid "+e_borderColor;
			}else if(curBndStr=="right"){
				tbl_BorderLeft.style.visibility="hidden";
				skin_BorderTop_Left.style.visibility="hidden";
				skin_BorderBottom_Left.style.visibility="hidden";
				tbl_BorderRight.style.visibility="visible";
				skin_BorderTop_Right.style.visibility="visible";
				skin_BorderBottom_Right.style.visibility="visible";
				skin_BorderLeft.style.borderRight=e_borderThick+"px solid "+e_borderColor;
				skin_BorderRight.style.borderLeft="0px solid "+e_borderColor;
			}else{
				tbl_BorderRight.style.visibility="visible";
				skin_BorderTop_Right.style.visibility="visible";
				skin_BorderBottom_Right.style.visibility="visible";
				tbl_BorderLeft.style.visibility="visible";
				skin_BorderTop_Left.style.visibility="visible";
				skin_BorderBottom_Left.style.visibility="visible";
				skin_BorderRight.style.borderLeft="0px solid "+e_borderColor;
				skin_BorderLeft.style.borderRight="0px solid "+e_borderColor;
			}
		}else if(strPosition=="absolute") viewerDiv.style.border = e_borderThick+"px solid "+e_borderColor;
	}else
		viewerDiv.style.border = e_borderThick+"px solid "+e_borderColor;
}
function event_startFlip(){
	if(!ebook_bCommandDliver()) return;
	try{link_hide();}catch(e){}
	
	ebook_dispatchEvent("startFlip");
}
function event_endFlip(){
	if(!ebook_bCommandDliver()) return;
	if(e_initLinkComplete) setTimeout("try{link_display();}catch(e){}",1);
	ebook_dispatchEvent("endFlip");
}
function event_initEnd(){
	if(!e_initComplete){
		try{
			var rpage=parseInt(ebook_getRequestVar("rpage"));
			if(rpage>0){
				var arr=ebook_getRequestVar("coords").split(";");
				if(arr.length==4){
					setTimeout("try{ebook_setHighright("+rpage+","+arr[0]+","+arr[1]+","+arr[2]+","+arr[3]+");}catch(ae){}",500);
				}
			}
		}catch(e){}
	}
	e_initComplete=true;
	try{
		if(e_isIEBrowser){
			ebook_loading.style.display="none";
			ebook_loading.detachEvent("onload", ebook_setLoadingImg);
			var element = ebook_loading.removeNode(true);
			element.outerHTML="";
			element=null;
		}
	}catch(e){}
	event_endFlip();
	try{
		if(top.e_strFullScreen=="init"){
			ebook_showFrame("frame_fullscreen","appendix/fullscreen.htm",true, true);
			try{frame_fullscreen.init();}catch(e){}
		}
	}catch(e){}
	ebook_resizeAll();
	ebook_dispatchEvent("initEnd");
	
	try{
		var flip=parseInt(ebook_getRequestVar("flip"));
		if(flip>0) setTimeout("dBook.handle_pressAutoFlip("+flip+",1);",1000);
	}catch(e){}
}
function event_zoomOccure(inOrOut, bndState){
	ebook_resizeAll(bndState);
//	if(e_isIEBrowser) setTimeout("ebook_cover.fireEvent('onmousemove');",10);
	ebook_dispatchEvent("zoomOccure", inOrOut, bndState);
}
function ebook_init(){
	e_screenColorDepth=window.screen.colorDepth;
	if( typeof(e_arrAppendFrame)=="undefined") e_arrAppendFrame=new Array();
	if( typeof(e_bFitViewerToWindow)=="undefined" ) e_bFitViewerToWindow=false;
	if( typeof(e_bDbookExtend)=="undefined" ) e_bDbookExtend=false;
	if( typeof(e_bZoomOnePage)=="undefined" ) e_bZoomOnePage=false;
	if( typeof(e_bCoverSlide)=="undefined" ) e_bCoverSlide=false;
	if( typeof(e_bCenterView)=="undefined" ) e_bCenterView=false;
	if( typeof(e_pageFix)=="undefined" ) e_pageFix=0;
	if( typeof(e_cursorType)=="undefined" ) e_cursorType="default";
	if( typeof(e_strFullScreen)=="undefined" ) e_strFullScreen="n";
	if( typeof(e_borderThick)=="undefined" ) e_borderThick=1;
	if( typeof(e_borderColor)=="undefined" ) e_borderColor="#eeeeee";
	if( typeof(e_bSupportMouseWheel)=="undefined" ) e_bSupportMouseWheel=false;
	if( typeof(e_maxBoundWidth)=="undefined" ) e_maxBoundWidth=0;
	if( typeof(e_maxBoundHeight)=="undefined" ) e_maxBoundHeight=0;
	if( typeof(e_boundGap)=="undefined" ) e_boundGap=0;
	if( typeof(e_ghostZoomLevel)=="undefined") e_ghostZoomLevel=0;
	if( typeof(e_bViewBorderImg)=="undefined") e_bViewBorderImg=true;
	if( typeof(e_fitRatio)=="undefined") e_fitRatio=1.6;
	if( typeof(e_bUseAntiAlias)=="undefined") e_bUseAntiAlias=true;
	if( typeof(e_bMouseBtnChg)=="undefined") e_bMouseBtnChg=false;
	if( typeof(e_bLinkTargetOne)=="undefined") e_bLinkTargetOne=false;
	if( typeof(e_timeOutSec)=="undefined" ) e_timeOutSec=8;
	if( typeof(e_bHavePlayer)=="undefined" ) e_bHavePlayer=false;
	if( typeof(e_bAutoPlayer)=="undefined" ) e_bAutoPlayer=false;
	if( typeof(g_sWork)=="undefined" ) g_sWork="";
	
	try{
		if(e_strFullScreen!="x" && (top.e_strFullScreen=="y" || top.e_strFullScreen=="init") ){
			window.moveTo(0,0);
			window.resizeTo(screen.availWidth, screen.availHeight);
		}
	}catch(e){}
	if(e_readURL.indexOf("/")!=0) e_readURL = "appendix/http/readBin."+e_readURL;
	if(e_isVerticalTurn) e_bViewBorderImg=false;
	if(e_ghostZoomLevel>1) e_ghostZoomLevel=1;
	if(e_ghostZoomLevel==1){
		e_maxZoomLevel=e_maxZoomLevel+e_ghostZoomLevel;
		e_canvasWidth=2*e_canvasWidth;
		e_canvasHeight=2*e_canvasHeight;
	}
	if(e_bFitViewerToWindow) e_bDbookExtend=true;

	if( !e_isDoublePage || e_isVerticalTurn){
		e_bCoverSlide = false;
		e_bZoomOnePage=false;
	}else if(e_bCoverSlide)
		e_coverPageFix=-1;

	var strHost, strAbsURL;
	var nStart,nEnd;
	var strHref=document.location.href;
	var oBaseColl = document.getElementsByTagName('BASE');
	var strBase=(oBaseColl && oBaseColl.length) ? oBaseColl[0].href : "";
	strHost=document.location.host;
	if(strBase!=""){
		if(strHost.length>0 && strBase.indexOf(strHost)>=0) strHref=strBase;
		else{ alert("BASE Error"); return false;}
	}
	
	if(e_absURL.length==0){
		nEnd = strHref.lastIndexOf("/");
		if(strHref.indexOf("http://")==0 || strHref.indexOf("https://")==0){
			nStart = strHref.indexOf("/", strHref.indexOf(strHost)+2);
			e_absURL = strHref.substring( nStart, nEnd+1);
		}else{
			strHref = strHref.replace("\\", "/");
			nEnd = strHref.lastIndexOf("/");
			if(strHref.indexOf("file://")==0)
				e_absURL = strHref.substring( 0, nEnd+1);
		}
		e_absHref = strHref.substring( 0, nEnd+1);
	}else{
		e_absHref=e_absURL;
	}
	if( typeof(e_indexFileName)=="undefined") e_docBaseURL=document.location.href;
	else e_docBaseURL=e_absHref+e_indexFileName;
	
	if( typeof(e_copyrightInfoURL)!="undefined") e_linkFile=e_copyrightInfoURL;
	return true;
}
function ebook_getObjectHtml(){
	var ret;
	if(ebook_init()){
		var rect = ebook_calcZoomRect(e_fitZoomLevel);
		if(e_bFitViewerToWindow){
			var maxRect =new ebook_rect();
			if(window.innerWidth){
				maxRect.w=window.innerWidth-120;
				maxRect.h=window.innerHeight-120;				
			}else{
				maxRect.w=document.body.clientWidth-120;
				maxRect.h=document.body.clientHeight-120;
			}			
			if(rect.w>maxRect.w || rect.h>maxRect.h){
				if( (rect.w/maxRect.w)>=(rect.h/maxRect.h) ){
					rect.h = rect.h*maxRect.w/rect.w;
					rect.w = maxRect.w;
				}else{
					rect.w = rect.w*maxRect.h/rect.h;
					rect.h = maxRect.h;					
				}
			}
		}
		var bndW = rect.w;
		var posX=0;
		var spage = parseInt( ebook_getRequestVar("startpage") );
		if( (isNaN(spage) || spage<=1) && e_bCoverSlide){
			bndW = Math.floor(bndW/2);
			if(!e_isOldTurn) posX = -1*bndW;
		}

		ret='<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" style="-khtml-user-select:none;-khtml-user-drag:none;-moz-user-focus:ignore;-moz-user-input:disabled;-moz-user-select:no;">';
		ret+='<tr>';
		ret+='<td id="td_thumbNavi" name="td_thumbNavi" width="0" style="display:none"></td>'
		ret+='<td width="100%"><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0"  id="tbl_viewArea" name="tbl_viewArea" style="z-index:0;" onselectstart="javascript:return false;" onselect="javascript:return false;">';
		ret+='<tr>';
		ret+='<td align="center" valign="middle"><table border="0" cellspacing="0" cellpadding="0">';
		ret+='<tr><td id="td_arrange" name="td_arrange" align="center">';
		if(e_bViewBorderImg){
			ret+='<table border="0" cellspacing="0" cellpadding="0" width="10" height="10" id="tbl_border" name="tbl_border">';
			ret+='<tr id="skin_BorderTop" name="skin_BorderTop" style="visibility:hidden">';
			ret+='<td height="49%" align="right" valign="bottom" id="skin_BorderTop_Left" name="skin_BorderTop_Left" style="visibility:hidden"><img src="'+e_iconDirectory+'/border_left_top.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td>';
			ret+='<td valign="bottom"  background="'+e_iconDirectory+'/border_top_bg.gif"><img src="'+e_iconDirectory+'/blank.gif" height="1"></td>';
			ret+='<td align="left" valign="bottom" id="skin_BorderTop_Right" name="skin_BorderTop_Right" style="visibility:hidden"><img src="'+e_iconDirectory+'/border_right_top.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td>';
			ret+='</tr>';
			ret+='<tr>';
			ret+='<td width="49%" align="right" id="skin_BorderLeft" name="skin_BorderLeft" style="border-right:1px solid #999999"><table border="0" cellspacing="0" cellpadding="0" height="100%" style="visibility:hidden" id="tbl_BorderLeft" name="tbl_BorderLeft">';
			ret+='<tr><td><img src="'+e_iconDirectory+'/border_left_top_sub.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td></tr>';
			ret+='<tr><td height="100%" background="'+e_iconDirectory+'/border_left_bg.gif"></td></tr>';
			ret+='<tr><td><img src="'+e_iconDirectory+'/border_left_bottom_sub.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td></tr>';
			ret+='</table></td>';
			ret+='<td width="2%" align="center" valign="middle">';
		}
		ret+='<div id="viewerDiv" name="viewerDiv" style="width:'+bndW+';height:'+rect.h+';overflow:hidden;z-index:0;border:0px solid '+e_borderColor+';-khtml-user-select:none;-khtml-user-drag:none;-moz-user-focus:ignore;-moz-user-input:disabled;-moz-user-select:none;"  oncontextmenu="javascript:return false;" ondrag="javascript:return false;" onselect="javascript:return false;">'
		if(e_isIEBrowser){
			ret+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="dBook"  width="'+bndW+'" height="'+rect.h+'" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" border="0" onselect="javascript:return false;" style="position:relative;left:0px;top:0px;" onerror="javascript:ebook_loadErrorHandler(event);" oncontextmenu="javascript:return false;">';
			ret += '<param name="movie" value="appendix/eBook.swf" />';
			ret += '<param name="quality" value="high" />';
			ret += '<param name="wmode" value="opaque" />';
			ret += '<param name="bgcolor" value="#ffffff" />';
			ret += '<param name="allowScriptAccess" value="sameDomain" />';
			ret += '<param name="allowFullScreen" value="true" />';
			ret += '</object>';
		}else{
			ret+='<embed src="appendix/eBook.swf" quality="high" wmode="opaque" bgcolor="#ffffff" width="'+bndW+'" height="'+rect.h+'" name="dBook" align="middle" type="application/x-shockwave-flash" allowScriptAccess="sameDomain" allowFullScreen="true" pluginspage="http://www.macromedia.com/go/getflashplayer" style="position:relative;left:0px;top:0px;z-index:0;"/>';
		}
		ret += '<div id="ebook_linkDiv" name="ebook_linkDiv" align="left" style="position:relative;left:'+posX+'px;top:'+(-1*rect.h)+'px;overflow:visible;" onselect="javascript:return false;">';
		ret += '<img id="ebook_cover" name="ebook_cover" src="'+e_iconDirectory+'/blank.gif" border="0" GALLERYIMG="no" style="visibility:hidden;position:absolute;left:0px;top:0px;width:'+rect.w+'px;height:'+rect.h+'px;z-index:1000;-khtml-user-select:none;-khtml-user-drag:none;-moz-user-focus:ignore;-moz-user-input:disabled;-moz-user-select:none;" onselect="javascript:return false;">';
		ret += '<div id="ebook_htmlTip"  name="ebook_htmlTip" onmouseover="javascript:link_tipOver(event);" onmouseout="javascript:link_tipOut(event);"  onresize="javascript:link_tipResize(event);" style="position:absolute;top:0px;left:0px;display:none;z-index:3000;-khtml-user-drag:none;"></div>';
		ret += '</div>';
		ret += '</div>';
		ret += '<div id="div_print" name="div_print" style="left:0px;top:0px;width:0px;height:0px;position:absolute;z-index:1001;"></div>';
		if(e_bViewBorderImg){
			ret+='</td>';
			ret+='<td width="49%" align="left" id="skin_BorderRight" name="skin_BorderRight" style="border-left:1px solid #999999"><table border="0" cellspacing="0" cellpadding="0" height="100%" id="tbl_BorderRight" name="tbl_BorderRight" style="visibility:hidden">';
			ret+='<tr><td width="1" height="1"><img src="'+e_iconDirectory+'/border_right_top_sub.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td></tr>';
			ret+='<tr><td width="1" height="100%" background="'+e_iconDirectory+'/border_right_bg.gif"></td></tr>';
			ret+='<tr><td width="1" height="1"><img src="'+e_iconDirectory+'/border_right_bottom_sub.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td></tr>';
			ret+='</table></td>';
			ret+='</tr>';
			ret+='<tr id="skin_BorderBottom" name="skin_BorderBottom" style="visibility:hidden">';
			ret+='<td width="1" height="1" height="49%" align="right" valign="top" id="skin_BorderBottom_Left" name="skin_BorderBottom_Left" style="visibility:hidden"><img src="'+e_iconDirectory+'/border_left_bottom.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td>';
			ret+='<td width="1" height="100%" valign="top" background="'+e_iconDirectory+'/border_bottom_bg.gif"><img src="'+e_iconDirectory+'/blank.gif" height="1"></td>';
			ret+='<td width="1" height="1" height="49%" valign="top" align="left" id="skin_BorderBottom_Right" name="skin_BorderBottom_Right" style="visibility:hidden"><img src="'+e_iconDirectory+'/border_right_bottom.gif" style="position:absolute;visibility:hidden;top:0px;left:0px;" onload="javascript:ebook_borderImgLoaded(this);"></td>';
			ret+='</tr>';
			ret+='</table>';
		}
		ret+='</td></tr>';
		ret+='</table></td>';
		ret+='</tr>';
		ret+='</table></td>';
		ret+='</tr>';
		ret+='</table>';
	}

	return ret;
}
function ebook_borderImgLoaded(img, bSet){
	if(e_isIEBrowser || bSet){
		img.style.position="static";
		img.style.visibility="inherit";
	}else{
		setTimeout(ebook_borderImgLoaded, 100, img, true);
	}
}
function ebook_checkCommunication(bChk){
	if(e_initComplete) return;
	if(bChk) try{var chk=dBook.handle_checkCommunication();}catch(e){document.location.replace(e_absURL+"appendix/guide.htm");}
	else setTimeout("ebook_checkCommunication(true)", e_timeOutSec*1000);
}
function ebook_loadErrorHandler(evt){
	ebook_loading.style.display="none";
	var rect = ebook_calcZoomRect(e_fitZoomLevel);
	viewerDiv.style.width = rect.w;
	viewerDiv.style.height = rect.h;
	dBook.style.left=0;
//	ebook_cover.style.display="none";
}
function ebook_write(){
	var sReq=ebook_getRequestVar("zoombox");
	if(sReq=="n") e_zoomBox="no";
	sReq=ebook_getRequestVar("iconview");
	if(sReq=="n") e_iconView="no";
	sReq=ebook_getRequestVar("centerview");
	if(sReq=="n") e_bCenterView=false;
	sReq=ebook_getRequestVar("pagelabel");
	if(sReq=="n") e_pageLabel="";
	sReq=ebook_getRequestVar("extend");
	if(sReq=="n") e_bDbookExtend=false;
	sReq=ebook_getRequestVar("fit");
	if(sReq=="n") e_bFitViewerToWindow=false;
	sReq=ebook_getRequestVar("fscreen");
	if(sReq=="n" || sReq=="y" || sReq=="init" || sReq=="x") e_strFullScreen=sReq;
	sReq=ebook_getRequestVar("zoomone");
	if(sReq=="y") e_bZoomOnePage=true;
	else if(sReq=="n") e_bZoomOnePage=false;
	sReq=ebook_getRequestVar("border");
	if(sReq=="y") e_bViewBorderImg=true;
	else if(sReq=="n") e_bViewBorderImg=false;
	sReq=ebook_getRequestVar("dpage");
	if(sReq=="y") e_isDoublePage=true;
	else if(sReq=="n") e_isDoublePage=false;
	sReq=ebook_getRequestVar("oturn");
	if(sReq=="y") e_isOldTurn=true;
	else if(sReq=="n") e_isOldTurn=false;	
	sReq=ebook_getRequestVar("vturn");
	if(sReq=="y") e_isVerticalTurn=true;
	else if(sReq=="n") e_isVerticalTurn=false;
	sReq=ebook_getRequestVar("onetwo");
	if(sReq=="y") e_isOneImgTwoPage=true;
	else if(sReq=="n") e_isOneImgTwoPage=false;
	sReq=ebook_getRequestVar("cover");
	if(sReq=="y") e_bCoverSlide=true;
	else if(sReq=="n") e_bCoverSlide=false;
	sReq=ebook_getRequestVar("antialias");
	if(sReq=="y") e_bUseAntiAlias=true;
	else if(sReq=="n") e_bUseAntiAlias=false;	
	
	var html = ebook_getObjectHtml();
	if(e_isIEBrowser && e_infoSize>6000 && e_absURL.indexOf("file://")==0){
		try{
			e_oReadBin = new ActiveXObject( "AlbummaniaKDMparser.Parser" );
			if( e_absURL.indexOf("file:///")==0 ) e_localPath = e_absURL.substring( "file:///".length );
			else e_localPath = "//" + e_absURL.substring( "file://".length );
			var re = new RegExp("/","g");
			e_localPath=e_localPath.replace(re, "\\");
			e_localPath = unescape( e_localPath );
			e_bReadBinUse=true;
		}catch(e){
			document.write('<object classid="clsid:B21E0736-C2DD-4F68-A174-54801A7C5D77" width="100%" height="300" codebase="'+e_absURL+'appendix/AlbummaniaKDMparser.cab"></object>');
			setTimeout("ebook_reload(0);", 2000);
			return;
		}
	}
	document.write(html);
	ebook_addDefEventListner();
	e_RClick={
		init: function (){
			this.FlashObjectID = "dBook";
			this.FlashContainerID = "viewerDiv";
			this.Cache = this.FlashObjectID;
			if(window.addEventListener){
				window.addEventListener("mousedown", this.onGeckoMouseDown(), true);
				window.addEventListener("mouseup", this.onGeckoMouseUp(), false);
				window.addEventListener("mouseover", this.onGeckoMouseOver(), false);
				window.addEventListener("mouseout", this.onGeckoMouseOut(), false);
			}else{
				document.getElementById(this.FlashContainerID).onmouseup=e_RClick.onIEMouseUp;
				document.oncontextmenu = function(){ 
					if(window.event.srcElement.id == e_RClick.FlashObjectID) { return false; } else { e_RClick.Cache = "nan"; }
				}
				document.getElementById(this.FlashContainerID).onmousedown=e_RClick.onIEMouseDown;
				document.getElementById(this.FlashContainerID).onmouseover=e_RClick.onIEMouseOver;
				document.getElementById(this.FlashContainerID).onmouseout=e_RClick.onIEMouseOut;
			}
		},
		killEvents: function(eventObject){
			if(eventObject){
				if (eventObject.stopPropagation) eventObject.stopPropagation();
				if (eventObject.preventDefault) eventObject.preventDefault();
				if (eventObject.preventCapture) eventObject.preventCapture();
				if (eventObject.preventBubble) eventObject.preventBubble();
			}
		},
		onGeckoMouseDown: function(ev){
			return function(ev){
				if (ev.button>1){
					e_RClick.killEvents(ev);
					if(ev.target.name == e_RClick.FlashObjectID) {
						e_RClick.call(true, ev.layerX, ev.layerY);
					}
					e_RClick.Cache = ev.target.name;
				}
			}
		},
		onGeckoMouseUp: function(ev){
			return function(ev){
				if (ev.button>1){
					if(ev.target.name== e_RClick.FlashObjectID) {
						e_RClick.call(false, ev.layerX, ev.layerY);
					}
				}
			}
		},
		onGeckoMouseOver: function(ev){
			return function(ev){
				if(ev.target.name== e_RClick.FlashObjectID) {
					ebook_mouseOver(ev);
				}
			}
		},
		onGeckoMouseOut: function(ev){
			return function(ev){
				if(ev.target.name== e_RClick.FlashObjectID) {
					ebook_mouseOut(ev);
				}
			}
		},
		onIEMouseDown: function(){
			if (event.button>1){
				if(window.event.srcElement.id == e_RClick.FlashObjectID){
					e_RClick.call(true, event.offsetX, event.offsetY); 
				}
				document.getElementById(e_RClick.FlashContainerID).setCapture();
				if(window.event.srcElement.id)
					e_RClick.Cache = window.event.srcElement.id;
			}
		},
		onIEMouseUp: function(){
			document.getElementById(e_RClick.FlashContainerID).releaseCapture();
			if (event.button>1){
				if(window.event.srcElement.id == e_RClick.FlashObjectID){
					e_RClick.call(false, event.offsetX, event.offsetY); 
				}
			}
		},
		onIEMouseOver: function(){
			if(window.event.srcElement.id == e_RClick.FlashObjectID){
				ebook_mouseOver(event);
			}
		},
		onIEMouseOut: function(){
			if(window.event.srcElement.id == e_RClick.FlashObjectID){
				ebook_mouseOut(event);
			}
		},
		call: function(isDown, mx, my) {
			document.dBook.ext_mouseRight(isDown, mx,my);
		}
	}
	e_RClick.init();
	setTimeout("ebook_checkCommunication(false);", 5000);
}
function ebook_reload(num){
	try{
		e_oReadBin = new ActiveXObject( "AlbummaniaKDMparser.Parser" );
		document.location.reload();
	}catch(e){
		setTimeout("ebook_reload("+(num+1)+");", 2000);
	}
}
function ebook_setTextCapture(){
	var bSet = !dBook.handle_getTextCaptureState();
	if(bSet && g_bXmlLoaded){
		try{
			if(dBook.handle_isSetTextData()){
				dBook.handle_setTextCapture(true);
				return true;
			}else{
				if(dBook.handle_setTextXml(g_xmlData)){
					
					dBook.handle_setTextCapture(true);
					return true;
				}else return false;
			}
			return true;
		}catch(e){return false;}
	}else{
		dBook.handle_setTextCapture(false);
		return false;
	}
}
function ebook_setImgCapture(){
	if(!e_isIEBrowser) return false;
	var bSet = !dBook.handle_getImgCaptureState();
	if(bSet){
		if(typeof(e_oImgBox)=="undefined"){
			var sHtml='<object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">';
			sHtml+='<param name="LPKPath" value="appendix/csxImage.lpk"/>';
			sHtml+='</object>';
			sHtml+='<object id="e_oImgBox" name="e_oImgBox" classid="clsid:62E57FC5-1CCD-11D7-8344-00C1261173F0" CODEBASE="appendix/csxImage.cab#version=2,2,0,0" style="position:absolute;top:0px;left:0px;width:0px;height:0px;">';
			sHtml+="</object>";
			document.body.insertAdjacentHTML("beforeEnd",sHtml);
		}
		if(typeof(e_oImgBox.Visible)!="undefined"){
			document.dBook.handle_setImgCapture(true);
			return true;
		}else{
			return false;
		}
	}else{
		document.dBook.handle_setImgCapture(false);
		return false;
	}
}
function ebook_saveCaptureImg(x,y,width,height){
	try{
		var viewRect=ebook_getElementRect(dBook);
		var bndState = dBook.handle_getBoundState();
		var zoomLevel = ebook_getCurrZoomStep();
		var left = window.screenLeft + viewRect.x + x+2;
		if(bndState=="right" && zoomLevel==e_fitZoomLevel) left=left-viewRect.w;
		var top = window.screenTop + viewRect.y + y+2;
		e_oImgBox.CaptureScreen();
		e_oImgBox.Crop(left, top, left+width-1, top+height-1);
		e_oImgBox.UseSelection=false;
		e_oImgBox.Copy();
		alert(MSG_IMG_CAPTURE);
	}catch(e){}
}
function ebook_readBin(start, end){
	var ret = e_oReadBin.Bin_Dump(e_localPath+e_dataDirectory+"\\" + e_imgFile, start, end-start,  "");
	ret = ret.replace( /\\/g, "\\\\" );
	return  ret;
}
function ebook_deleteBin(path){
	path.replace(/\\/g, "\\\\");
	try{e_oReadBin.Bin_Delete(path);}catch(e){}
}
function ebook_block(evt){window.isblocked=true;}
function ebook_unload(){
	if(e_isIEBrowser && !window.isblocked){
		e_isUnload=true;
		for(var i=0;i<3;i++) try{dBook.handle_unload();}catch(e){}
		document.close();
		for(var i=0;i<5;i++){
			document.recalc();
			document.close();		
		}
	}
	window.isblocked=false;
}
function ebook_addDefEventListner(){
	if(e_isIEBrowser){
		window.attachEvent("onresize", ebook_resizeAll);
		window.attachEvent("onbeforeunload", ebook_unload);
		document.attachEvent("onclick", ebook_block);
		ebook_cover.attachEvent("onclick", ebook_click);
		ebook_cover.attachEvent("onmousemove", ebook_mouseMove);
		ebook_cover.attachEvent("onmouseover", ebook_mouseOver);
		ebook_cover.attachEvent("onmouseout", ebook_mouseOut);
		ebook_cover.attachEvent("onmousedown", ebook_mouseDown);
		ebook_cover.attachEvent("onmouseup", ebook_mouseUp);
		viewerDiv.attachEvent("onmousewheel", ebook_mouseWheel);
		viewerDiv.attachEvent("onscroll",ebook_protectScroll);
	}else{
		window.onresize = ebook_resizeAll;
		ebook_cover.addEventListener("click", ebook_click,false);
		ebook_cover.addEventListener("mousemove", ebook_mouseMove,false);
		ebook_cover.addEventListener("mouseover", ebook_mouseOver,false);
		ebook_cover.addEventListener("mouseout", ebook_mouseOut,false);
		ebook_cover.addEventListener("mousedown", ebook_mouseDown,false);
		ebook_cover.addEventListener("mouseup", ebook_mouseUp,false);
	}
	e_bRemovedDefEventListner=false;
}
function ebook_protectScroll(evt){
	evt.srcElement.scrollTop=0;
	evt.srcElement.scrollLeft=0;
}
function ebook_removeDefEventListner(obj){
	if(e_isIEBrowser){
		window.detachEvent("onresize", ebook_resizeAll);
		window.detachEvent("onbeforeunload", ebook_unload);
		document.detachEvent("onclick", ebook_block);
		ebook_cover.detachEvent("onclick", ebook_click);
		ebook_cover.detachEvent("onmousemove", ebook_mouseMove);
		ebook_cover.detachEvent("onmouseover", ebook_mouseOver);
		ebook_cover.detachEvent("onmouseout", ebook_mouseOut);
		ebook_cover.detachEvent("onmousedown", ebook_mouseDown);
		ebook_cover.detachEvent("onmouseup", ebook_mouseUp);
		viewerDiv.detachEvent("onmousewheel", ebook_mouseWheel);		
	}else{
		ebook_cover.removeEventListener("click", ebook_click,false);
		ebook_cover.removeEventListener("mousemove", ebook_mouseMove,false);
		ebook_cover.removeEventListener("mouseover", ebook_mouseOver,false);
		ebook_cover.removeEventListener("mouseout", ebook_mouseOut,false);
		ebook_cover.removeEventListener("mousedown", ebook_mouseDown,false);
		ebook_cover.removeEventListener("mouseup", ebook_mouseUp,false);
	}
	
	e_bRemovedDefEventListner=true;
}
function ebook_setHighright(page, x1,x2,y1,y2){
	dBook.handle_setFocusArea(false, page, x1,x2,y1,y2, "blink=1&borderThick=3&bgColor=#EEEEEE", true, false);
}
function ebook_showFrame(frameID,url, bTrans, bView){
	var oFrame = document.getElementById(frameID);
	if(oFrame){
		var strSrc = oFrame.src;
		if( strSrc.indexOf(e_absHref)>=0 ) strSrc=strSrc.substring(e_absHref.length, strSrc.length);
		
		if(strSrc==url){
			if(oFrame.style.visibility=="hidden") oFrame.style.visibility="visible";
			else if(!bView) oFrame.style.visibility="hidden";
			
			oFrame.style.display="";
		}else
			oFrame.src=url;
			
		try{oFrame.frm_focus();}catch(e){}
	}else{
		if(e_isIEBrowser){
			var strFrm='<iframe id="'+frameID+'" name="'+frameID+'" src="'+url+'" scrolling="auto" frameborder="0" ';
			if(bTrans) strFrm+='ALLOWTRANSPARENCY="true" ';
			strFrm+='style="position:absolute;top:0px;left:0px;visibility:hidden;filter: Alpha(Opacity=80)"></iframe>';
			document.body.insertAdjacentHTML("beforeEnd",strFrm);
		}else{
			var oElement = document.createElement("iframe");
			oElement.id=frameID;
			oElement.name=frameID;
			oElement.frameBorder=0;
			oElement.scrolling="auto";
			oElement.style.position="absolute";
			oElement.style.left="0px";
			oElement.style.top="0px";
			oElement.style.visibility="hidden";
			oElement.style.backgroundColor="#ffffff";
			try{ if(ebook_isWindowOs()) oElement.style.opacity=0.8; }catch(e){}
			oElement.src = url;
			document.body.appendChild(oElement);
		}
		e_arrAppendFrame.push(frameID);
	}
}
function ebook_getOSType(){
	try{
		var ret = "unknown";
		var uagt = window.navigator.userAgent;
		uagt = uagt.toLowerCase();
		if(uagt.indexOf("win")>=0){
			if(uagt.indexOf("win95")>=0 || uagt.indexOf("windows 95")>=0) ret="Windows 95";
			else if(uagt.indexOf("win98")>=0 || uagt.indexOf("windows 98")>=0) ret="Windows 98";
			else if(uagt.indexOf("win 9x 4.90")>=0) uagt="Windows ME";
			else if(uagt.indexOf("windows nt 5.0")>=0) ret="Windows 2000";
			else if(uagt.indexOf("windows nt 5.1")>=0) ret="Windows XP";
			else if(uagt.indexOf("windows nt 5.2")>=0) ret="Windows 2003";
			else if(uagt.indexOf("windows nt 6.0")>=0) ret="Windows Vista";
			else if(uagt.indexOf("winnt")>=0 || ret.indexOf("windows nt")>=0) ret="Windows NT";
			else ret= window.navigator.platform;
		}else ret= window.navigator.platform;
		return ret;
	}catch(e){ return "unknown"; }
}
function ebook_isWindowOs(){
	try{
		if(window.navigator.platform.toLowerCase().indexOf("win")>=0) return true;
		else return false;
	}catch(e){}
	return false;
}
function ebook_preventEvtBubble(evt){
	try{if(evt.stopPropagation) evt.stopPropagation();}catch(e){}
	try{if(evt.preventDefault) evt.preventDefault();}catch(e){}
	try{if(evt.preventCapture) evt.preventCapture();}catch(e){}
	try{if(evt.preventBubble) evt.preventBubble();}catch(e){}
	try{
		evt.cancelBubble=true;
		evt.returnValue=false;
	}catch(e){}
}
function ebook_alert(str){
	setTimeout("try{alert(unescape('"+escape(str)+"'));}catch(e){}",10);
}
function ebook_debug(str){
	try{
		document.frm.txtarea_debug.value = str + "\r\n" + document.frm.txtarea_debug.value;
	}catch(e){}
}
