////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   This computer program is protected by copyright law and international treaties.                                                      //
//   Unauthorized reproduction or distribution of the program, or any portion of it, may result in severe civil and criminal penalties,   //
//   and will be prosecuted to the maximum extent possible under law.                                                                     //
//   Copyright(c) Digitomi Corp. All Right Reserved.                                                                                      //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   Last Update 2004_07_27 19:58:09 by tews                                                                                              //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function Printer2(){this.id="oPrinter2";this.LevelIdx=0;this.PreparePrint=PreparePrint;this.GoPrint=GoPrint;this.GetPrintScale=GetPrintScale;this.MessAlert=MessAlert;this.dprDoPrint=dprDoPrint;this.dprInitial=dprInitial;this.dprInitial();}function dprInitial(){}
 function dprDoPrint(arg_Page,arg_Level){
   var iCurrPage=arg_Page;
   this.LevelIdx=arg_Level;
   this.PrintSize=new Array(640,900);
   this.BothPrint=false;
   if(this.LevelIdx > 0){
     if(iCurrPage==Math.floor(iCurrPage)){
       var iPageNo = Math.floor(iCurrPage); //Ãß°¡
       this.GoPrint(iCurrPage);
     }
     else{
       var iPageNo = iCurrPage;  //Ãß°¡
       this.GoPrint(Math.floor(iCurrPage));
       this.GoPrint(Math.ceil(iCurrPage));
     }

      /////////// ÀÌºÎºÐ »ðÀÔ ////////////
      try{
       if(printCrmResultValue == true) 
       printZoomPageCRM(iPageNo);
      }catch(e){}
      //////////////////////////////////

   }
   else{
     if(iCurrPage !=Math.ceil(iCurrPage)){
       this.BothPrint=true;
     }
     this.GoPrint(iCurrPage);
    ///////// ÀÌºÎºÐ »ðÀÔ ////////////
    try{
     var iPageNo = iCurrPage;
     if(printCrmResultValue == true) printPageCRM(iPageNo);
    }catch(e){}
    ////////////////////////////////
   }
 }
 
 function GoPrint(arg_Page){
	 var PrintHtmlCode;PrintHtmlCode=this.PreparePrint(arg_Page);
	 if(this.PrintSize[0] > this.PrintSize[1]){
		 this.PrintSize[0]+=29;
		 this.PrintSize[1]+=10;
	 }else{
		 this.PrintSize[0]+=10;
		 this.PrintSize[1]+=29;
	 }
	 PrnWnd=window.open("about:blank","PrnWnd"+Math.ceil(arg_Page),"channelmode=no,directories=no,fullscreen=no,status=no,titlebar=no,toolbar=no,resizable=no,scrollbar=no,menubar=no,left=0 top=0 width="+this.PrintSize[0]+",height="+this.PrintSize[1]);
	 PrnWnd.document.write(PrintHtmlCode);
	 PrnWnd.location.reload();}
 function MessAlert(){
	 var sResult="";
	 if(this.PrintSize[0] > this.PrintSize[1]){
		 sResult="alert(\""+GetRes("PrintConfig",gaRes_Deco)+"\");";
	 }
	 return sResult;
 }
 
 function PreparePrint(arg_Page){
	 var BaseHtmlRes_01;
	 var BaseHtmlRes_02;
	 var BaseHtmlRes_03;var viewHeight;var viewWidth;var PrintScale=0;PrintScale=this.GetPrintScale(this.LevelIdx);if(this.BothPrint){viewWidth=Math.ceil((oBookInfo.aLevelInfo[this.LevelIdx][0] * 2)* PrintScale);viewHeight=Math.ceil((oBookInfo.aLevelInfo[this.LevelIdx][1])* PrintScale);}else{viewWidth=Math.ceil(oBookInfo.aLevelInfo[this.LevelIdx][0] * PrintScale);viewHeight=Math.ceil(oBookInfo.aLevelInfo[this.LevelIdx][1] * PrintScale);}BaseHtmlRes_01=" <html>\n"+" <head>\n"+" <meta http-equiv=\"imagetoolbar\" content=\"no\">\n"+" <title>"+"Print [ "+document.title+" : "+(arg_Page+1)+" Page ]"+" </title>\n"+" <script language=\"javascript\">\n"+" function DoPrint(){\n"+" setTimeout(\"window.print()\",10);\n"+" setTimeout(\"window.close()\",10);\n"+" "+this.MessAlert()+"\n"+"}\n"+" </script>\n"+" </head>\n"+" <body leftmargin=\"0\" rightmargin=\"0\" topmargin=\"0\" bottommargin=\"0\" oncontextmenu=\"return false\" onselectstart=\"return false\" onload=\"DoPrint()\">\n"+" <table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=\"0\" cellSpacing=\"0\">\n"+" <tr>\n"+" <td vAlign=\"middle\" align=\"center\">\n"+" <table border=\"0\" cellpadding=\"0\" cellSpacing=\"0\">";BaseHtmlRes_02="";BaseHtmlRes_03=" </table>\n"+" </body>\n"+" </html>";var ImgBaseUrl="";var PrintWidth=viewWidth;var PrintHeight=viewHeight;if(this.BothPrint){var sTileImgUrl=oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page-(0.5 * giLeafDirect)),0,0);BaseHtmlRes_02+="<td><img src=\""+sTileImgUrl+"\" width=\""+(viewWidth/2)+"\" height=\""+PrintHeight+"\" ></td> "+"\n";var sTileImgUrl=oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page+(0.5 * giLeafDirect)),0,0);BaseHtmlRes_02+="<td><img src=\""+sTileImgUrl+"\" width=\""+(viewWidth/2)+"\" height=\""+PrintHeight+"\" ></td> "+"\n";}else{for(yIdx=0;yIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][5];yIdx++){BaseHtmlRes_02=BaseHtmlRes_02+"<tr>\n";PrintWidth=viewWidth;if(yIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)){PrintHeight=parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][3]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][1] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][5]-1)))* PrintScale);}for(xIdx=0;xIdx< oBook.oBookInfo.aLevelInfo[this.LevelIdx][4];xIdx++){var sTileImgUrl=oDecoder2.cdeGetTileName(this.LevelIdx,parseInt(arg_Page),yIdx,xIdx);if(xIdx==parseInt(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)){PrintWidth=parseInt((oBook.oBookInfo.aLevelInfo[this.LevelIdx][2]-(oBook.oBookInfo.aLevelInfo[this.LevelIdx][0] *(oBook.oBookInfo.aLevelInfo[this.LevelIdx][4]-1)))* PrintScale);}BaseHtmlRes_02+="<td><img src=\""+sTileImgUrl+"\" width=\""+PrintWidth+"\" height=\""+PrintHeight+"\" ></td>\n";}}BaseHtmlRes_02+="</tr>\n";}return(BaseHtmlRes_01+BaseHtmlRes_02+BaseHtmlRes_03);}function GetPrintScale(arg_Level){if(arg_Level==0){var BookSize=new Array(oBook.oBookInfo.aLevelInfo[arg_Level][0],oBook.oBookInfo.aLevelInfo[arg_Level][1]);}else{var BookSize=new Array(oBook.oBookInfo.aLevelInfo[arg_Level][2],oBook.oBookInfo.aLevelInfo[arg_Level][3]);}var PrintScale=new Array();var Scaletype=-1;if(this.BothPrint){BookSize[0]=BookSize[0] * 2;}if(BookSize[0] > BookSize[1]){var tmp=this.PrintSize[0];this.PrintSize[0]=this.PrintSize[1];this.PrintSize[1]=tmp;}PrintScale[0]=this.PrintSize[0] / BookSize[0];PrintScale[1]=this.PrintSize[1] / BookSize[1];if((BookSize[0] >=this.PrintSize[0])&&(BookSize[1] >=this.PrintSize[1])){if(PrintScale[0] < PrintScale[1]){return PrintScale[0];}else{return PrintScale[1];}}else if((BookSize[0] >=this.PrintSize[0])&&(BookSize[1] < this.PrintSize[1])){return PrintScale[0];}else if((BookSize[0] < this.PrintSize[0])&&(BookSize[1] >=this.PrintSize[1])){return PrintScale[1];}else{return 1;}}

