/////////////////////////////////////////////////////
//
//  Since 1998 Copyright(c)
//  Humandream, Inc.
//  All rights reserved
//  file name : dBook.js
//  version : 3.5 g1207  (made by Humandream, Inc.)
//
/////////////////////////////////////////////////////

var bInitFinished = false;	// the variable called by applet when the applet load finishing.
var bLoaded = false;		// the variable called by html document when the html document load finishing.

bInitFinished = false;
bOnLoaded = false;

function DigitalBookUnload()
{ 
    try
    {
    	document.dBook.handle_addCRMData( getCRMData() );
    }
    catch (e)
    {
        try
        {
            document.dBook.handle_setURL( getMailingParam() );      // for old version viewer
        }
        catch (e2) {}
    }

    try
    {
       	document.dBook.handle_unload();
    }
    catch (e3)  {}
    // Please append 'onUnload=DigitalBookUnload()' at BODY open tag.
    // Please check that 'Port' number is 80 or not.
}

function doKey(e)
{
	whichASC = event.keyCode;

	if (whichASC == 13){
		HD_inputGotoPage();
	}
}

function getCookie(name)
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie )
		{
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

//***********************************************************************************************
// page Customize
var gPageOffset = 0;

function _getRealPageNo(nPage)
{    
   return gPageOffset + nPage;
}

//This function is depricated please use HD_setSkinPageOffset()
function setCustomizeInt(offset)
{
	gPageOffset = offset;
}

function HD_setSkinPageOffset(offset)
{
	gPageOffset = offset;
}

function HD_getSkinPageOffset()
{
	return gPageOffset;
}

function _printOffset(tStr)
{
	var strValue = "";

	if(tStr == "0"){
		strValue = tStr; 
	}
	else{
		var intValue = parseInt(tStr) + gPageOffset;
		strValue = intValue.toString();
	}
	return strValue;
}

//Check dbook.jar's page view mode
function HD_isDoublePage() {
	return document.dBook.handle_isDoublePage();
}

//get current left page no. applicable only if dobule page view mode
function HD_getLeftPage() {
	return document.dBook.handle_getLeftSlidePage();
}

//get current right page no. applicable only if dobule page view mode
function HD_getRightPage() {
	return document.dBook.handle_getRightSlidePage();
}

//get current page no. applicable only if single page view mode
function HD_getCurrentPage() {
	return document.dBook.handle_getCurSlidePage();     // for single-page DBook.
}

function HD_getSlideTotal() {
	return document.dBook.handle_getSlideTotal();
}

function HD_getSlidePage() 
{	
	if (!bInitFinished)
		return;
	
	if (!bOnLoaded)
		return;

	var LPage = HD_getLeftPage();
	var RPage = HD_getRightPage();
	var SinglePage = HD_getCurrentPage();     // for single-page DBook.
	var slideTot = HD_getSlideTotal();
	
	/** customize page Number****/ 

	LPage = LPage - gPageOffset;
	RPage = RPage - gPageOffset;
	slideTot = slideTot - gPageOffset;

	if (LPage < 0)	{	LPage = 0;	}
	if (RPage < 0)	{	RPage = 0;	}
	/** to here ****************/

	try{
		if (cur_page != null)	
		{
			if ( HD_isDoublePage() )
			{
				cur_page.innerText = LPage + "-" +RPage + " / " + slideTot;
				
				if(RPage < LPage){
					document.pageSlideBar.setCurrPos(slideTot, RPage); // hdSlide.htm
				}else{
					document.pageSlideBar.setCurrPos(slideTot, LPage); // hdSlide.htm
				}
			}
			else
			{
			    cur_page.innerText = SinglePage + " / " + slideTot;    // for single-page DBook.
			    
			    document.pageSlideBar.setCurrPos(slideTot, SinglePage);
			}
		}
	}catch(e){}
}

function HD_setPageNum() 
{
	// call by applet when the applet load finishing.
	bInitFinished = true;

	HD_getSlidePage();
	
	try{
		your_treatSlidePage();
	}catch(e){}
}

function HD_inputGotoPage() 
{		// goto some page
	var slideTot = document.dBook.handle_getSlideTotal();
	nPage = _getRealPageNo(parseInt(page_num.value));

	if(nPage <= slideTot && nPage > 0 )
		document.dBook.handle_inputGotoPage(nPage);
	page_num.value="";
}

function HD_gotoPage(nPage) 
{		// goto some page
	var slideTot = document.dBook.handle_getSlideTotal();

	if(nPage <= slideTot && nPage > 0 )
		document.dBook.handle_inputGotoPage(nPage);
}

function openReplace(win_url) 
{ 
    var screen_width = 1024 - 10; 
    var screen_height = 768 - 30; 
    strFeatures = "left=0,top=0,width=" + screen_width + ",height=" + screen_height + ","; 
    strFeatures += "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes"; 
    
    windowname=window.open( win_url, "NoticeJavaVM", strFeatures ); 
    windowname.focus(); 
    return; 
} 


function HD_pressCloseUp() {		
	document.dBook.handle_pressCloseUp();
}
function HD_pressZoom() {			
	document.dBook.handle_pressZoom();
}
function HD_pressLeftZoom() {		
	document.dBook.handle_pressZoomPage(document.dBook.handle_getLeftSlidePage());
}
function HD_pressRightZoom() {			
	document.dBook.handle_pressZoomPage(document.dBook.handle_getRightSlidePage());
}
function HD_pressPause() {			
	document.dBook.handle_pressPause();
}

function getOs(){
	var isMac = false;
	var m_arrUserAgent = window.navigator.userAgent.split(" ");
	var OSVersion = m_arrUserAgent[4] + m_arrUserAgent[5] + m_arrUserAgent[6];
	if ( OSVersion.indexOf( "Mac" ) == 0){
		isMac = true;
	}else{
		isMac = false;
	}
	return isMac;
}
function HD_pressNextPage() {		
	var flag = getOs()
	if(flag)
		document.dBook.handle_pressNextPage_mac();  
	else
		document.dBook.handle_pressNextPage();
}
function HD_pressPreviousPage() {	
	var flag = getOs()
	if(flag)	
		document.dBook.handle_pressPreviousPage_mac();
	else
		document.dBook.handle_pressPreviousPage();
}
function HD_gotoFirstPage() {		
	document.dBook.handle_gotoFirstPage();
}
function HD_gotoEndPage() {			
	document.dBook.handle_gotoEndPage();
}

function HD_pressBackwardRotate() {	// auto sliding (backward)
	document.dBook.handle_pressBackwardRotate();
}
function HD_pressForwardRotate() {	// auto sliding (forward)
	document.dBook.handle_pressForwardRotate();
}
function HD_pressSpeedUp() {		// turn speed up when sliding
	document.dBook.handle_pressSpeedUp();
}
function HD_pressSpeedDown() {		// turn speed down when sliding
	document.dBook.handle_pressSpeedDown();
}
////////////////////////////////////////////////////////////////////////////////

function HD_openBrWindow(theURL,winName,features) 
{
	winName = theURL.replace(/[^a-zA-Z0-9]+/g,''); 
		
	if (features == "")
	{
		features = "toolbar=yes,width=800,height=600,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
	}

  HD_popup = window.open(theURL,winName,features);
  
  if (HD_popup != null)
  {
	  HD_popup.focus();
	}
}

var printTarget = ""

function HD_setPrintTarget(tempTarget) {
	printTarget = tempTarget
}

/*	---> Use Print Control.............2006.01.05
function printPage(direction) 
{
	if (!document.dBook)
	{
		alert("There is not exist ZIPOT  DigitalBook");
		return;
	}

	if (!document.PrintCtrl)		// ??? ??? ?? Print ?? ??. PrintCtrl? ?? <Object> ??? ?? ? //
	{
		installPrintCtrl();
	}
	else 
	{
		try
		{
			document.PrintCtrl.isRegistered();
		}
		catch (e1) 
		{ 
			installPrintCtrl();

			return;					// nothing install//
		}
	}
			

	var strPrintArg = "";
	var bExistMediUrl = false;

	if ( direction == "" )      direction = 2;      // 2 == double page
	var strMediaURL = document.dBook.handle_getMediaURL();
	var page;
	
	if (strMediaURL != "")
	{
	
		if (document.dBook.handle_isDoublePage())
		{
			var	lpage = document.dBook.handle_getLeftSlidePage() - 1;
			var rpage = document.dBook.handle_getRightSlidePage() - 1;
			
			// var page;
				
			if (direction == 0)
				page = 	lpage;
			else if (direction == 1)
				page = 	rpage;
			else
				page = 	lpage + "-" + rpage;	
		}
		else
		{
			// var page = document.dBook.handle_getCurSlidePage() - 1;
			page = document.dBook.handle_getCurSlidePage() - 1;
		}
		
		strPrintArg = "-p 2 \"" + strMediaURL + "\" -1 " + page;
		
		bExistMediUrl = true;
	}
	else
	{
		var validity;
		
		var strPrintImages;
		
		if (document.dBook.handle_isDoublePage())
		{
			if (direction == 0)
				validity = document.dBook.handle_getLeftPrintName();
			else if (direction == 1)
				validity = document.dBook.handle_getRightPrintName();
			else  // if (direction == 2)
				validity = document.dBook.handle_getLeftPrintName();
		}
		else  // if (!document.dBook.handle_isDoublePage())
		{
			validity = document.dBook.handle_getCurPrintName();
		}

		var nIndexPrefix = printTarget.indexOf("__3dmall__") + "__3dmall__".length;
		var strUrlPrefix = printTarget.substr(0, nIndexPrefix);

		var strMinPage = 0;
		var strMaxPage = parseInt( document.dBook.handle_getSlideTotal() ) -1;

		var strStartPage = "";
		var strEndPage = "";
		if (direction == 0)
		{
			strStartPage = parseInt( document.dBook.handle_getLeftSlidePage() ) -1;
			strEndPage = strStartPage;
		}
		else if (direction == 1)
		{
			strStartPage = parseInt( document.dBook.handle_getRightSlidePage() ) -1;
			strEndPage = strStartPage;
		}
		else  // if (direction == 2)
		{
			strStartPage = parseInt( document.dBook.handle_getLeftSlidePage() ) -1;
			strEndPage = parseInt( document.dBook.handle_getRightSlidePage() ) -1;
		}

		var strZoomLevel = document.dBook.handle_getTotalZoomStep();

		if (direction == 2)		// double page print 
		{
			strPrintArg = "-p 21 \"" + strUrlPrefix + "\"";
		}
		else // if (direction != 2)		// one page print 
		{
			strPrintArg = "-p 11 \"" + strUrlPrefix + "\"";
		}
		strPrintArg += " " + strMinPage + "-" + strMaxPage;
		strPrintArg += " " + strStartPage + "-" + strEndPage;
		strPrintArg += " " + strZoomLevel

		bExistMediUrl = false;
	}

	try
	{
		strPrintArg = "-title \"Zipot Print\" " + strPrintArg;

		if (bExistMediUrl)
		{
			PrintCtrl.PrintHDM2(strPrintArg);
		}
		else
		{
			PrintCtrl.PrintImage(strPrintArg);
		}
	}
	catch (e3)
	{

	}
}

function printPage_high(direction) 
{
	printPage(direction) 
}

function installPrintCtrl()
{
	var tempCurrentUrl = ""+document.location.href;
	tempCurrentUrl = tempCurrentUrl.substring(0,5);
	tempCurrentUrl = tempCurrentUrl.toUpperCase();

	if (tempCurrentUrl.indexOf("HTTP") > -1)	// case on-line 
	{
       	var htmlPrintTag = "";
		htmlPrintTag += '<OBJECT ID="PrintCtrl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:6D3E22C5-8087-41DE-A898-6B5E44677DAA" ';
		htmlPrintTag += ' CODEBASE="http://www.humandream.com/dbook/release/HDMediaPrint.cab#version=2,1,0,31" ';
		htmlPrintTag += ' STANDBY="Please Wait...."> ';
		htmlPrintTag += '</OBJECT> ';
		document.dBook.insertAdjacentHTML("afterEnd",htmlPrintTag);
	}
	else			// case off-line 
	{
       	var htmlPrintTag = "";
		htmlPrintTag += '<OBJECT ID="PrintCtrl" WIDTH=0 HEIGHT=0 CLASSID="CLSID:6D3E22C5-8087-41DE-A898-6B5E44677DAA" ';
		htmlPrintTag += ' CODEBASE="appendix/Package/HDPrint/HDMediaPrint.cab#version=2,1,0,31" ';
		htmlPrintTag += ' STANDBY="Please Wait...."> ';
		htmlPrintTag += '</OBJECT> ';
		document.dBook.insertAdjacentHTML("afterEnd",htmlPrintTag);
	}
}

function printPage0(direction) {
	var tempFile=""
	var tempWindow = ""
	var validity

	if (direction != 2) {		
		if (direction == 0)
			validity = document.dBook.handle_getLeftPrintName()
		else
			validity = document.dBook.handle_getRightPrintName()

		printWindow=window.open(tempFile,tempWindow,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=0, top=0, width=700,height=600');
		printWindow.document.writeln("<HTML>")
		printWindow.document.writeln("<head>")
		printWindow.document.writeln("<scr"+"ipt lang" + "uage=jav"+"ascript>")
		printWindow.document.writeln("    funct" + "ion printPage() {")
		
		printWindow.document.writeln("    window.print()")
				
		printWindow.document.writeln("		setTimeout('window.close()', 1000);")
		printWindow.document.writeln("    } ")
		printWindow.document.writeln("</scr"+"ipt>")
		printWindow.document.writeln("</head>")
		printWindow.document.writeln("<BODY>")

		printWindow.document.writeln("<center>")
		printWindow.document.writeln("<table border='0' cellspacing='0' cellpadding='0' topmargin='0' marginwidth='0' marginheight='0'>")
		printWindow.document.writeln("<tr>")

		if (validity > 0) {
			printWindow.document.writeln("<td><img src=\"" + printTarget + "0.jpg\" width=325 height=485></td>")
			printWindow.document.writeln("<td><img src=\"" + printTarget + "1.jpg\" width=325 height=485></td>")
			printWindow.document.writeln("</tr><tr>")
			printWindow.document.writeln("<td><img src=\"" + printTarget + "2.jpg\" width=325 height=485></td>")
			printWindow.document.writeln("<td><img src=\"" + printTarget + "3.jpg\" width=325 height=485></td>")
		}
		else {
			printWindow.document.writeln("<td><img src=\"" + printTarget + ".jpg\" width=650 height=970></td>")
		}

		printWindow.document.writeln("</tr>")
		printWindow.document.writeln("</table>")
		printWindow.document.writeln("</center>")

		printWindow.document.writeln("</BODY>")
		printWindow.document.writeln("</HTML>")
		printWindow.location.reload();

//		printWindow.print()
		printWindow.setTimeout("printPage()", 1000);
		printWindow.setTimeout("window.close()",1000);
	}
	else { //  (direction == 2) {		
		validity = document.dBook.handle_getLeftPrintName()
		var leftPage = printTarget;
		validity = document.dBook.handle_getRightPrintName()
		var RightPage = printTarget;

		printWindow=window.open(tempFile,tempWindow,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, left=0, top=0, width=910,height=700');
		printWindow.document.writeln("<HTML>")
		printWindow.document.writeln("<head>")

		printWindow.document.writeln("<scr"+"ipt lang" + "uage=jav"+"ascript>")
		printWindow.document.writeln("		var msg = 'Set the page orientaion of the printer to the landscape.'")
		printWindow.document.writeln("    funct" + "ion printPage() {")
		
		printWindow.document.writeln("    window.print()")
		
		printWindow.document.writeln("				setTimeout('alert(msg)', 1500)")
		printWindow.document.writeln("				setTimeout('window.close()', 2000);")
		printWindow.document.writeln("    } ")
		printWindow.document.writeln("</scr"+"ipt>")

		printWindow.document.writeln("</head>")
		printWindow.document.writeln("<BODY>")

		printWindow.document.writeln("<center>")
		printWindow.document.writeln("<table border='0' cellspacing='0' cellpadding='0' topmargin='0' marginwidth='0' marginheight='0'>")
		printWindow.document.writeln("<tr>")

		if (validity > 0) {
			printWindow.document.writeln("<td><img src=\"" + leftPage + "0.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("<td><img src=\"" + leftPage + "1.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("<td><img src=\"" + RightPage + "0.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("<td><img src=\"" + RightPage + "1.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("</tr><tr>")
			printWindow.document.writeln("<td><img src=\"" + leftPage + "2.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("<td><img src=\"" + leftPage + "3.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("<td><img src=\"" + RightPage + "2.jpg\" width=225 height=322></td>")
			printWindow.document.writeln("<td><img src=\"" + RightPage + "3.jpg\" width=225 height=322></td>")
		}
		else {
			printWindow.document.writeln("<td><img src=\"" + leftPage + ".jpg\" width=450 height=645></td>")
			printWindow.document.writeln("<td><img src=\"" + RightPage + ".jpg\" width=450 height=645></td>")
		}

		printWindow.document.writeln("</tr>")
		printWindow.document.writeln("</table>")
		printWindow.document.writeln("</center>")

		printWindow.document.writeln("</BODY>")
		printWindow.document.writeln("</HTML>")
		printWindow.location.reload();

		printWindow.setTimeout("printPage()", 1000);
	}
}

---> Use Print Control.............2006.01.05
*/

//function HD_startApplet() {
//	interval_id = window.setInterval("HD_setPageNum()", intervalTime);
//}

/// -------------------------------- Print
/***
function _change(val) {
	if( val != "" ) {
		printPage(val)
	}
}
***/
function _blur(obj,num){
	obj.options[ num ].selected = true;
}

function downSelect(obj, num) {
	if( obj.options[ num ] != null && obj.options[ num ].text=="PRINTING" ) {
		obj.options[ num ].text = "NONE PRINTING";
	}
	else if( obj.options[ num ].text == "NONE PRINTING" ) {
		obj.options[ num ].text = "NONE PRINTING"
	}
}
// -------------------------------------------


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

////////////////////////////////////////////////////////////////////////////////

//***********************************************************************************************
// ActiveX 
function HD_OCX_changePage()
{
	try {
		your_changePage();
	}
	catch (e_ocx_01)
	{}
}

function HD_OCX_endRotate()
{
	try {
		your_endRotate();
	}
	catch (e_ocx_02)
	{}
}

function HD_OCX_notFlipPrev()
{
	try {
		your_notFlipPrev();
	}
	catch (e_ocx_03)
	{}
}

function HD_OCX_notFlipNext()
{
	try {
		your_notFlipNext();
	}
	catch (e_ocx_03)
	{}
}
//***********************************************************************************************
// Start Range Print Function
//var cur_page;
var SourcePathFlag=0;
function GetFileFullPath(){
	var docupath = document.location.href;
	var mediapath = docupath.substring(0,5);

	if (mediapath == "file:" || mediapath == "FILE") {
		docupath = location.pathname;
		splitString = docupath.split("\\");
		
		if(splitString.length > 1) {
			mediapath = splitString[0].substring(1, 2);
			mediapath = mediapath + ":";		
			for (i = 1; i < (splitString.length-1);i++)
				mediapath = mediapath + "/" + splitString[i];	
		} else {
			splitString = docupath.split("/");
			mediapath = splitString[1];		
			for (i = 2; i < (splitString.length-1);i++) {
				if(splitString[i].length > 0)
					mediapath = mediapath + "/" + splitString[i];
			}
		}			
		mediapath = mediapath + "/";		
		SourcePathFlag=0;
	}
	else {
		splitString = docupath.split("/");
		mediapath = "";
		SourcePathFlag=1;
		for (i=2;i<(splitString.length-1);i++) mediapath+=splitString[i] + "/"
	}
	return mediapath
}

//******************************************************************************************
function printPageRange(startPage, endPage) 
{
	// Renewal Page
	startPage = parseInt(startPage, 10) -1;
	endPage = parseInt(endPage, 10) -1;

	// dckim 20051207 start ***************************************
	if(isNaN(startPage))
	{
		if ( document.dBook.handle_isDoublePage() )
		{
			startPage = document.dBook.handle_getLeftSlidePage() - 1;
			endPage = startPage + 1;
		}
		else
		{
			startPage = document.dBook.handle_getCurSlidePage() - 1;
			endPage = startPage;
		}
	}
	// dckim 20051207 end ***************************************
	
	var startPageTemp = 0;
	var endPageTemp = document.dBook.handle_getSlideTotal() -1;
	if (startPage < startPageTemp)
	  startPage = startPageTemp;
	if (endPage > endPageTemp)
	  endPage = endPageTemp;
	if (startPage > endPage)
	  return;
	  
	var tempFile= "";
	var tempWindow = "";
	
	var urlBase = document.dBook.BaseHref;
	var urlCodeBade = document.dBook.codeBase;
	var imageFilePathBase=GetFileFullPath();

	if(SourcePathFlag==1) imageFilePathBase = "http://" + imageFilePathBase
	var strImageNamePref = document.dBook.image_name;

	//Check this point
	strImageNamePref = document.dBook.handle_getImageName();

	var baseWidth = 650;
	var baseHeight = 970;
		
	var zoomLevel=1;
	var imageWidth=baseWidth; 
	var imageHeight=baseHeight;
	
	var printWidth; 
	var printHeight;
	
	try
	{
		zoomLevel = parseInt(document.dBook.handle_getTotalZoomStep());
		imageWidth = parseInt(document.dBook.handle_getPageWidth());
		imageHeight= parseInt(document.dBook.handle_getPageHeight());
	} catch(e) { zoomLevel=1; imageWidth=baseWidth; imageHeight=baseHeight;}
	
	// dckim 20051207 start ***************************************
	// If all zoom level=0 image print.....
	// Then only zoomLevel=1 
	// dckim 20051207 end ***************************************
	
	var tempRatio;
	tempRatio = imageWidth/imageHeight;
	baseRatio = baseWidth/baseHeight;
	
	var printWidth; 
	var printHeight;
	var vertMargin;
	
	if(baseRatio > tempRatio )
	{
		printHeight = baseHeight;
		printWidth = printHeight * tempRatio; 
	}
	else
	{
		printWidth = baseWidth;
		printHeight = printWidth / tempRatio; 
	}
	vertMargin = baseHeight - printHeight;

	// dckim 20051207 start ***************************************
	if(zoomLevel == 1)
	{
		printWidth = printWidth/2;
		printHeight = printHeight/2; 
	}
	else
	{
		if(zoomLevel > 1)
		{
			printWidth = printWidth/4;
			printHeight = printHeight/4; 
		}
	}
	// dckim 20051207 end ***************************************
		
	var strSize = "width=" + parseInt(printWidth) + " height=" + parseInt(printHeight);
	
	var imageFilePath = imageFilePathBase + urlCodeBade + "/"+ strImageNamePref;
	imageFilePath = unescape(imageFilePath);

    printWindow=window.open(tempFile,tempWindow,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=0, top=0, width=700,height=600');

	printWindow.document.writeln("<HTML>");
	printWindow.document.writeln("<head>");
	printWindow.document.writeln("<scr"+"ipt lang" + "uage=jav"+"ascript>");
	printWindow.document.writeln("    funct" + "ion printPage() {");
	
	printWindow.document.writeln("    window.print()");
			
	printWindow.document.writeln("		setTimeout('window.close()', 1000);");
	printWindow.document.writeln("    } ");
	printWindow.document.writeln("</scr"+"ipt>");
	printWindow.document.writeln("</head>");
	printWindow.document.writeln("<BODY onLoad = \"Javascript:printPage();\">");

	printWindow.document.writeln("<center>");
	
	
	// dckim 20051207 start ***************************************
	var nPage;
	for(nPage=startPage; nPage<=endPage; nPage++){
		if(zoomLevel == 0)
		{
			printWindow.document.writeln("<table border='0' cellspacing='0' cellpadding='0' topmargin='0' marginwidth='0' marginheight='0' page-break-inside='avoid' page-break-after='always'>");
			printWindow.document.writeln("<tr>");
			printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + ".jpg\" "+strSize+"></td>");
			printWindow.document.writeln("</tr>");
			printWindow.document.writeln("</table>");
		}
		else
		{
			if(zoomLevel == 1)
			{
				printWindow.document.writeln("<table border='0' cellspacing='0' cellpadding='0' topmargin='0' marginwidth='0' marginheight='0' page-break-inside='avoid' page-break-after='always'>");
					printWindow.document.writeln("<tr><tr>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__2by2__0.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__2by2__1.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("</tr>");
				
					printWindow.document.writeln("<tr>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__2by2__2.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__2by2__3.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("</tr></tr>");
				printWindow.document.writeln("</table>");
			}
			else
			{
				printWindow.document.writeln("<table border='0' cellspacing='0' cellpadding='0' topmargin='0' marginwidth='0' marginheight='0' page-break-inside='avoid' page-break-after='always'>");
					printWindow.document.writeln("<tr><tr>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__0.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__1.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__2.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__3.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("</tr>");
				
					printWindow.document.writeln("<tr>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__4.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__5.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__6.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__7.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("</tr>");
					
					printWindow.document.writeln("<tr>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__8.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__9.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__10.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__11.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("</tr>");
					
					printWindow.document.writeln("<tr>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__12.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__13.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__14.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("<td><img src=\"" + imageFilePath + nPage + "__4by4__15.jpg\" " + strSize + "></td>");
					printWindow.document.writeln("</tr></tr>");
				printWindow.document.writeln("</table>");
			}
		}
		// Print Margin
		if(vertMargin > 10) {
			printWindow.document.writeln("<td><img src=appendix/printMargin.JPG " + "width=" + parseInt(baseWidth) + " height=" + parseInt(vertMargin) + "></td>");
		}	
	}
	// dckim 20051207 end ***************************************
	
	
	printWindow.document.writeln("</center>");

	printWindow.document.writeln("</BODY>");
	printWindow.document.writeln("</HTML>");
	printWindow.location.reload();

	//printWindow.setTimeout("printPage()", 1000);
	//printWindow.setTimeout("window.close()",1000);
}

//***********************************************************************************************

function parseNPrint(strPrintPages)
{
	try
	{
		var strDelimeter;
		if (strPrintPages.indexOf("-") > 0)
			strDelimeter = "-";
		else 
			strDelimeter = "~";
		
		var arrPages = strPrintPages.split(strDelimeter);
	
		if (arrPages.length == 1)
		{
			// 20061012 yjs begin
			
			if(gPageOffset > 0){
				var editPages = "";
				editPages = _printOffset(arrPages);
				printPageRange( editPages, editPages); 
			}else{
			// 20061012 yjs end
				printPageRange( arrPages[0], arrPages[0]);
			}
			
		}
		else if (arrPages.length == 2)
		{
			var slideTot = document.dBook.handle_getSlideTotal();
			if(arrPages[0] > slideTot) arrPages[0] = slideTot;
			if(arrPages[1] > slideTot) arrPages[1] = slideTot;
			
			if(arrPages[0] < 1) arrPages[0] = 1;
			if(arrPages[1] < 1) arrPages[1] = 1;
			
			startPage = parseInt(arrPages[0], 10) -1;
			endPage = parseInt(arrPages[1], 10) -1;
			if(startPage > endPage)
			{
				var temp = arrPages[0];
				arrPages[0] = arrPages[1];
				arrPages[1] = temp;
			}

			// dckim 20051207 start ***************************************
			if((endPage - startPage) > 9) 
			{
				alert(MSG_PRINT_001);
				return;
			}
			else 
			{
				// 20061012 yjs begin
				if(gPageOffset > 0){
					var editPage1 = _printOffset(arrPages[0]);
					var editPage2 = _printOffset(arrPages[1]);
					printPageRange(editPage1, editPage2);
				}else{
				// 20061012 yjs end
					printPageRange(arrPages[0], arrPages[1]);
				}
			}

		}
		else
		{
			alret("Fail to print");
		}
	} catch(e) {}
}

//***********************************************************************************************
function pagePrint()
{
	// For check HDM format... This is possible only 3Dmall format...
	 var strMediaURL = document.dBook.handle_getMediaURL();
	 
	 // If HDM format
	 if (strMediaURL != "")
	 {
		 alert (MSG_PRINT_002);		 
	 }
	
	// If not HDM format
	else
	{
		parseNPrint(selectPrint.value);
		selectPrint.value = "";
	}
}
//***********************************************************************************************
function doKey_search(e){
	whichASC = event.keyCode;
	if (whichASC == 13){
		SearchResults.DoSearch();
	}
}

function clearRange()
{
 	selectPrint.value = "";
}
//End Range Print Function
//***********************************************************************************************
