////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   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 2005_02_21 09:45:09 by tews                                                                                              //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function Decoder2(){this.id="oDecoder2";this.oBookInfo=oBookInfo;this.aLevel=0;this.xTileCount=cdeGetTileCount(this.oBookInfo.aLevelInfo[this.oBookInfo.aLevelInfo.length-1 ][3],this.oBookInfo.aLevelInfo[this.oBookInfo.aLevelInfo.length-1 ][1]);this.yTileCount=cdeGetTileCount(this.oBookInfo.aLevelInfo[this.oBookInfo.aLevelInfo.length-1 ][2],this.oBookInfo.aLevelInfo[this.oBookInfo.aLevelInfo.length-1 ][0]);this.cdeSetEncrytionInfo=cdeSetEncrytionInfo;this.cdeSetEachBookHost=cdeSetEachBookHost;this.cdeGetLevelPath=cdeGetLevelPath;this.cdeGetPathInfo=cdeGetPathInfo;this.cdeGetPrintImg=cdeGetPrintImg;this.cdeGetEncodeName=cdeGetEncodeName;this.cdeGetKey=cdeGetKey;this.cdeSFNE_System=cdeSFNE_System;this.cdeInitial=cdeInitial;this.Char2Num=Char2Num;this.Num2Char=Num2Char;this.FillDigit=FillDigit;this.cdeGetTileName=cdeGetTileName;this.cdeGetThumbNail=cdeGetThumbNail;this.cdeGetImgPath=cdeGetImgPath;this.cdeInitial();}function cdeInitial(){var iIdx=0;for(iIdx=0;iIdx < this.oBookInfo.EachBookInfo.length;iIdx++){this.cdeSetEachBookHost(iIdx);if(this.oBookInfo.EachBookInfo[iIdx][3] !=""){this.cdeSetEncrytionInfo(iIdx);}}}function cdeGetTileName(arg_Level,arg_Page,arg_Tile_Y,arg_Tile_X){var sResultTileName="";var sLevelPath=this.cdeGetLevelPath(arg_Level);var iRebuildBook=this.oBookInfo.EachBookInfo.length;var sCacheBasePath=gsSrv_Cache;var sImgBasePath="";var sTileName="";var iEachBookIdx=0;switch(iRebuildBook){case 1 : iEachBookOnLinePage=arg_Page;break;default : iEachBookIdx=this.oBookInfo.PageInfo[arg_Page][0];iEachBookOnLinePage=this.oBookInfo.PageInfo[arg_Page][2];break;}if(this.oBookInfo.EachBookInfo[iEachBookIdx][3] !=""){sTileName=this.oBookInfo.EachBookInfo[iEachBookIdx][6][iEachBookOnLinePage]+this.oBookInfo.EachBookInfo[iEachBookIdx][7][arg_Tile_Y]+this.oBookInfo.EachBookInfo[iEachBookIdx][8][arg_Tile_X];}else{sTileName=this.FillDigit(iEachBookOnLinePage)+"_"+this.FillDigit(arg_Tile_Y)+"_"+this.FillDigit(arg_Tile_X);}switch(arg_Level){case 0 : sCacheBasePath=sCacheBasePath+gsPort+gsSlash+this.cdeGetPathInfo(iEachBookIdx);sResultTileName=gsProtocol+sCacheBasePath+gsSlash+sLevelPath+gsSlash+sTileName+".jpg";break;default : sImgBasePath=this.oBookInfo.EachBookInfo[iEachBookIdx][0]+gsPort+gsSlash+this.cdeGetPathInfo(iEachBookIdx);sResultTileName=gsProtocol+sImgBasePath+gsSlash+sLevelPath+gsSlash+sTileName+".jpg";break;}return sResultTileName;}function cdeGetPathInfo(arg_EachBookiIdx){var sResultPath="";sResultPath=gsBookBase+gsSlash+this.oBookInfo.EachBookInfo[arg_EachBookiIdx][2][0]+gsSlash+this.oBookInfo.EachBookInfo[arg_EachBookiIdx][2][1]+gsSlash+this.oBookInfo.EachBookInfo[arg_EachBookiIdx][2][2]+gsSlash+this.oBookInfo.EachBookInfo[arg_EachBookiIdx][2][3]+"_"+this.oBookInfo.EachBookInfo[arg_EachBookiIdx][2][4]+"_"+this.oBookInfo.EachBookInfo[arg_EachBookiIdx][2][5];return sResultPath;}function cdeSetEncrytionInfo(arg_iIdx){var iTotalPage=parseInt(this.oBookInfo.EachBookInfo[arg_iIdx][5]);var aFileNameKey=new Array(2);var aYNameKey=new Array(2);var aXNameKey=new Array(2);var aKeys=new Array(6);aKeys[0]=new Array(4);aKeys[1]=new Array(4);aKeys[2]=new Array(4);aKeys[3]=new Array(4);aKeys[4]=new Array(4);aKeys[5]=new Array(4);aKeys=this.cdeGetKey(aKeys,this.oBookInfo.EachBookInfo[arg_iIdx][3]);aFileNameKey[0]=aKeys[0];aFileNameKey[1]=aKeys[1];aYNameKey[0]=aKeys[2];aYNameKey[1]=aKeys[3];aXNameKey[0]=aKeys[4];aXNameKey[1]=aKeys[5];this.oBookInfo.EachBookInfo[arg_iIdx][6]=this.cdeGetEncodeName(aFileNameKey,iTotalPage);this.oBookInfo.EachBookInfo[arg_iIdx][7]=this.cdeGetEncodeName(aXNameKey,this.xTileCount);this.oBookInfo.EachBookInfo[arg_iIdx][8]=this.cdeGetEncodeName(aYNameKey,this.yTileCount);}function FillDigit(arg_sNum){var Result="";if((arg_sNum >-1)&&(arg_sNum < 10)){Result="000"+arg_sNum;}else if((arg_sNum >=10)&&(arg_sNum < 100)){Result="00"+arg_sNum;}else if((arg_sNum >=100)&&(arg_sNum < 1000)){Result="0"+arg_sNum;}else if((arg_sNum >=1000)&&(arg_sNum < 10000)){Result=arg_sNum;}return Result;}function cdeGetKey(arg_aKeys,arg_aKeyWord){for(var i=0;i<arg_aKeys[0].length;i++){arg_aKeys[0][i]=this.Char2Num(arg_aKeyWord.charCodeAt(i+0));arg_aKeys[1][i]=this.Char2Num(arg_aKeyWord.charCodeAt(i+4));arg_aKeys[2][i]=this.Char2Num(arg_aKeyWord.charCodeAt(i+8));arg_aKeys[3][i]=this.Char2Num(arg_aKeyWord.charCodeAt(i+12));arg_aKeys[4][i]=this.Char2Num(arg_aKeyWord.charCodeAt(i+16));arg_aKeys[5][i]=this.Char2Num(arg_aKeyWord.charCodeAt(i+20));}return arg_aKeys;}function Char2Num(arg_ichr){if(arg_ichr < 91){return arg_ichr-65;}else{return arg_ichr-97+26;}}function Num2Char(arg_ichr){if(arg_ichr < 26){arg_ichr+=65;return String.fromCharCode(arg_ichr);}else{arg_ichr=arg_ichr+97-26;return String.fromCharCode(arg_ichr);}}function cdeGetEncodeName(arg_aKeys,arg_TileCount){var aName=new Array();var iIdx=0;for(iIdx=0;iIdx < arg_TileCount;iIdx++){aName[iIdx]=this.cdeSFNE_System(arg_aKeys);}return aName;}function cdeSFNE_System(arg_aKeys){var sEncryptFileName="";var sTmpStr="";var iIdx=0;for(var iIdx=0;iIdx<(arg_aKeys[0].length-1);iIdx++){arg_aKeys[1][iIdx+1]=(arg_aKeys[0][iIdx]+arg_aKeys[1][iIdx])% 52;arg_aKeys[0][iIdx]=arg_aKeys[1][iIdx];sEncryptFileName+=Num2Char(arg_aKeys[0][iIdx]);}arg_aKeys[1][0]=(arg_aKeys[0][arg_aKeys[0].length-1]+arg_aKeys[1][arg_aKeys[1].length-1])% 52;arg_aKeys[0][arg_aKeys[0].length-1]=arg_aKeys[1][arg_aKeys[1].length-1];sEncryptFileName+=Num2Char(arg_aKeys[0][iIdx]);return sEncryptFileName;}function cdeGetThumbNail(arg_Page){var iRebuildBook=this.oBookInfo.EachBookInfo.length;var iEachBookIdx=0;var iEachBookOnLinePage=arg_Page;var sCacheBasePath="";switch(iRebuildBook){case 1 : break;default : iEachBookIdx=this.oBookInfo.PageInfo[arg_Page][0];iEachBookOnLinePage=this.oBookInfo.PageInfo[arg_Page][2];break;}sCacheBasePath=gsSrv_Cache+gsPort+gsSlash+this.cdeGetPathInfo(iEachBookIdx);sThumbNail=gsProtocol+sCacheBasePath+gsSlash+"thumbnails"+gsSlash+this.FillDigit(iEachBookOnLinePage)+".jpg";return sThumbNail;}function cdeGetImgPath(arg_Level,arg_Page){var sResultTileName="";var sLevelPath=this.cdeGetLevelPath(arg_Level);var iRebuildBook=this.oBookInfo.EachBookInfo.length;var sCacheBasePath=gsSrv_Cache;var sImgBasePath="";var sTileName="";var iEachBookIdx=0;switch(iRebuildBook){case 1 : iEachBookOnLinePage=arg_Page;break;default : iEachBookIdx=this.oBookInfo.PageInfo[arg_Page][0];iEachBookOnLinePage=this.oBookInfo.PageInfo[arg_Page][2];break;}switch(arg_Level){case 0 : sCacheBasePath=sCacheBasePath+gsPort+gsSlash+this.cdeGetPathInfo(iEachBookIdx);sResultBasePath=gsProtocol+sCacheBasePath+gsSlash+sLevelPath+gsSlash;break;default : sImgBasePath=this.oBookInfo.EachBookInfo[iEachBookIdx][0]+gsPort+gsSlash+this.cdeGetPathInfo(iEachBookIdx);sResultBasePath=gsProtocol+sImgBasePath+gsSlash+sLevelPath+gsSlash;break;}return sResultBasePath;}function cdeGetPrintImg(arg_Page,arg_Level){var sPrintImgName=this.cdeGetTileName(arg_Level,arg_Page,0,0);return sPrintImgName;}function cdeGetLevelPath(arg_Level){var sResultLevelPath="Level_00"+arg_Level;return sResultLevelPath;}function cdeSetEachBookHost(arg_EachBookiIdx){var aServer=new Array();for(var iIdx=0;iIdx < gaSrv_Image.length;iIdx++){for(var jIdx=0;jIdx < this.oBookInfo.EachBookInfo[0][1].length;jIdx++){if(this.oBookInfo.EachBookInfo[arg_EachBookiIdx][1][jIdx]==gaSrv_Image[iIdx]){aServer[aServer.length]=gaSrv_Image[iIdx];}}}this.oBookInfo.EachBookInfo[arg_EachBookiIdx][0]=aServer[Math.floor(Math.random()* aServer.length)];gsSrv_Image=this.oBookInfo.EachBookInfo[arg_EachBookiIdx][0];}function cdeGetTileCount(arg_ImgSize,arg_TileSize){var iResult=Math.ceil((arg_ImgSize)/ arg_TileSize);return iResult;}oDecoder2=new Decoder2();
