////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   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_07_19 10:24:01 by tews                                                                                              //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function Scrap2(){
	 this.id="oScrap2";
	 this.oParentDiv=arguments[0];
	 this.oScrapTable=null;
	 this.cssText="position:absolute;left:0;top:0;width:200;height:200;visibility:hidden;z-index:1005;";
	 this.Clicked=false;
	 this.ScrapAreaLeft=0;
	 this.ScrapAreaTop=0;
	 this.ScrapClicked_X=0;
	 this.ScrapClicked_Y=0;
	 this.ImgPath=gsProtocol+gsSrv_Cache+gsPort+"/engine/java/Deco/Scrap/";
	 this.LimitPos=new Limit();
	 this.ResizeLeft=0;
	 this.ResizeTop=0;
	 this.ResizeClicked_X=0;
	 this.ResizeClicked_Y=0;
	 this.ResizeWidth=0;
	 this.ResizeHeight=0;
	 this.BookIndex=null;
	 this.BookName=null;
	 this.BookDate=null;
	 this.Page		=null;
	 this.TileHCount=0;
	 this.TileVCount=0;
	 this.TileW	=0;
	 this.TileH	=0;
	 this.ScrapL	=0;
	 this.ScrapT	=0;
	 this.ScrapW	=0;
	 this.ScrapH	=0;
	 this.TileBaseUR="";
	 this.TileImages="";
	 this.GetLimit=GetLimit;
	 this.ScrapHide=ScrapHide;
	 this.SetScrapData=SetScrapData;
	 this.CallScrapFunc=CallScrapFunc;
	 this.DoDark=DoDark;
	 this.DoSoft=DoSoft;
	 this.OnMouseDownScrapDiv=OnMouseDownScrapDiv;
	 this.OnMouseMoveScrapDiv=OnMouseMoveScrapDiv;
	 this.OnMouseUpScrapDiv=OnMouseUpScrapDiv;
	 this.OnMouseDownResize=OnMouseDownResize;
	 this.OnMouseMoveResize=OnMouseMoveResize;
	 this.OnMouseUpResize=OnMouseUpResize;
	 this.OnMouseDown=OnMouseDown;
	 this.dscDoReposition=dscDoReposition;
	 this.dscShowScrap=dscShowScrap;
	 this.dscDoScrap=dscDoScrap;
	 this.dscViewScrap=dscViewScrap;
	 this.dscInitial=dscInitial;
	 this.dscInitial();
}

function Point(){this.x=0;this.y=0;}
function Limit(){this.MinLeft=0;this.MinTop=0;this.MaxLeft=0;this.MaxTop=0;}
function dscInitial(){if(typeof(this.oParentDiv)=="undefined"){this.oParentDiv=oBook.oBookBaseDiv;}this.BookIndex=oBook.oBookInfo.iBookCode;this.BookName=gsBookTitle;this.BookDate=gsRegDate;var tmpScrapDiv=document.createElement("DIV");this.oParentDiv.appendChild(tmpScrapDiv);tmpScrapDiv.outerHTML=" <table id=\"oScrapTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" > "+"\n"+" <tr> "+"\n"+" <td id=\"nw\" onmousedown=\""+""+this.id+".OnMouseDownResize(nw)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(nw,'LT')\" onmouseup=\""+""+this.id+".OnMouseUpResize(nw)\" style=\"width:1;height:5;cursor:nw-resize\"><img src=\""+this.ImgPath+"Border_LT.gif\"></td> "+"\n"+" <td id=\"n\" onmousedown=\""+""+this.id+".OnMouseDownResize(n)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(n,'T')\" onmouseup=\""+""+this.id+".OnMouseUpResize(n)\" style=\"height:5;cursor:n-resize;background-Image:url("+this.ImgPath+"Border_T.gif)\" ></td> "+"\n"+" <td id=\"ne\" onmousedown=\""+""+this.id+".OnMouseDownResize(ne)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(ne,'RT')\" onmouseup=\""+""+this.id+".OnMouseUpResize(ne)\" style=\"width:1;height:5;cursor:ne-resize\"><img src=\""+this.ImgPath+"Border_RT.gif\"></td> "+"\n"+" </tr> "+"\n"+" <tr> "+"\n"+" <td id=\"w\" onmousedown=\""+""+this.id+".OnMouseDownResize(w)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(w,'L')\" onmouseup=\""+""+this.id+".OnMouseUpResize(w)\" style=\"width:5;height:1;cursor:w-resize;background-Image:url("+this.ImgPath+"Border_L.gif)\"></td> "+"\n"+" <td id=\"oCaption\" onmousedown=\" "+""+this.id+".OnMouseDownScrapDiv(this)\" onmousemove=\" "+""+this.id+".OnMouseMoveScrapDiv(this)\" onmouseup=\" "+""+this.id+".OnMouseUpScrapDiv(this)\" style=\"width:100%;height:100%;background-Color:blue;cursor:move;filter:alpha(Opacity=20);\" > "+"\n"+" <table cellpadding=\"0\" cellspacing=\"0\" style=\"position:absolute;right:5;top:5;\" > "+"\n"+" <tr> "+"\n"+" <td style=\"cursor:hand;\" onmousedown=\""+" "+this.id+".DoDark();"+this.id+".dscDoScrap();"+"\"><img src=\""+this.ImgPath+"scrap_mouseout.gif\" title=\""+GetRes("MsgStore",gaRes_Deco)+"\"></td> "+"\n"+" <td style=\"cursor:hand;\" onmousedown=\""+this.id+".ScrapHide();"+"\"><img id=\"oImg\" colspan=\"3\" src=\""+this.ImgPath+"close_mouseout.gif\" title=\""+GetRes("Close",gaRes_Deco)+"\"></td> "+"\n"+" </tr> "+"\n"+" </table> "+"\n"+" </td> "+"\n"+" <td id=\"e\" onmousedown=\""+""+this.id+".OnMouseDownResize(e)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(e,'R')\" onmouseup=\""+""+this.id+".OnMouseUpResize(e)\" style=\"width:5;height:1;cursor:e-resize;background-Image:url("+this.ImgPath+"Border_R.gif)\"></td> "+"\n"+" </tr> "+"\n"+" <tr> "+"\n"+" <td id=\"sw\" onmousedown=\""+""+this.id+".OnMouseDownResize(sw)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(sw,'LB')\" onmouseup=\""+""+this.id+".OnMouseUpResize(sw)\" style=\"width:1;height:5;cursor:sw-resize\"><img src=\""+this.ImgPath+"Border_LB.gif\"></td> "+"\n"+" <td id=\"s\" onmousedown=\""+""+this.id+".OnMouseDownResize(s)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(s,'B')\" onmouseup=\""+""+this.id+".OnMouseUpResize(s)\" style=\"height:5;cursor:s-resize;background-Image:url("+this.ImgPath+"Border_B.gif)\" ></td> "+"\n"+" <td id=\"se\" onmousedown=\""+""+this.id+".OnMouseDownResize(se)\" onmousemove=\""+""+this.id+".OnMouseMoveResize(se,'RB')\" onmouseup=\""+""+this.id+".OnMouseUpResize(se)\" style=\"width:1;height:5;cursor:se-resize\"><img src=\""+this.ImgPath+"Border_RB.gif\"></td> "+"\n"+" </tr> "+"\n"+" </table> ";this.oScrapTable=oScrapTable;this.oScrapTable.style.cssText=this.cssText;this.oScrapTable.style.left=(parseInt(this.oParentDiv.style.width)-parseInt(this.oScrapTable.style.width))/ 2;this.oScrapTable.style.top=(parseInt(this.oParentDiv.style.height)-parseInt(this.oScrapTable.style.height))/ 2;}
function GetLimit(){this.MinLeft=0;this.MinTop=0;this.MaxLeft=parseInt(this.oParentDiv.style.width)-parseInt(this.oScrapTable.style.width);this.MaxTop=parseInt(this.oParentDiv.style.height)-parseInt(this.oScrapTable.style.height);}
function ScrapHide(){this.oScrapTable.style.visibility="hidden";}
function dscShowScrap(){if(String(typeof(Scrap))=="undefined"){var tmpDiv=document.createElement("DIV");document.body.appendChild(tmpDiv);tmpDiv.outerHTML="<div id=\"Scrap\"></div>";tmpDiv=Scrap;}switch(gsLanguage){case "ko" : Scrap.innerHTML=" <OBJECT ID=\"oScrapX\" onError=\"\" style=\"width:0;height:0;\" CLASSID=\"CLSID:7D6EB1E5-ABB4-4957-9AE4-180DB0A13E4C\" CODEBASE=\"/engine/Program/ScrapX.cab#version=1,0,0,6\"></OBJECT>";break;case "ja" : Scrap.innerHTML=" <OBJECT ID=\"oScrapX\" style=\"width:0;height:0;\" CLASSID=\"CLSID:7D6EB1E5-ABB4-4957-9AE4-180DB0A13E4C\" CODEBASE=\"/engine/Program/ja/ScrapX.cab#version=1,0,0,6\"></OBJECT>";break;default : Scrap.innerHTML=" <OBJECT ID=\"oScrapX\" style=\"width:0;height:0;\" CLASSID=\"CLSID:7D6EB1E5-ABB4-4957-9AE4-180DB0A13E4C\" CODEBASE=\"/engine/Program/en/ScrapX.cab#version=1,0,0,6\"></OBJECT>";}	 this.oScrapTable.style.visibility="visible";}
function dscDoReposition(){var iLimitLeft=parseInt(this.oScrapTable.style.left);var iLimitTop=parseInt(this.oScrapTable.style.top);if(parseInt(this.oScrapTable.style.left)>(parseInt(this.oParentDiv.style.width)-parseInt(this.oScrapTable.style.width))){iLimitLeft=parseInt(this.oParentDiv.style.width)-parseInt(this.oScrapTable.style.width);}if(parseInt(this.oScrapTable.style.top)>(parseInt(this.oParentDiv.style.height)-parseInt(this.oScrapTable.style.height))){iLimitTop=parseInt(this.oParentDiv.style.height)-parseInt(this.oScrapTable.style.height);}this.oScrapTable.style.left=iLimitLeft;this.oScrapTable.style.top=iLimitTop;}
function SetScrapData(){var iIdx;var jIdx;var aTmpTileName=new Array();var iTargetLevelIdx=oBook.cobGetCurrLevelIdx();var Click_X=0;var Click_Y=0;var r,re;var iMod;var iDiv;this.Page=oBook.cobGetCurrPage();var iMaxTileHCount=oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][4];var iMaxTileVCount=oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][5];this.TileW=oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][0];this.TileH=oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][1];if(iTargetLevelIdx==0){this.ScrapL=parseInt(this.oScrapTable.style.left)-parseInt(oBook.oBasicLevelDiv.style.left)-iBorder_L_Bg_Width;this.ScrapT=parseInt(this.oScrapTable.style.top)-parseInt(oBook.oBasicLevelDiv.style.top)-iBorder_T_Bg_Height;}else{this.ScrapL=parseInt(this.oScrapTable.style.left)-parseInt(MgrLevel.Levels[iTargetLevelIdx].oLevelDiv.style.left);this.ScrapT=parseInt(this.oScrapTable.style.top)-parseInt(MgrLevel.Levels[iTargetLevelIdx].oLevelDiv.style.top);}this.ScrapW=parseInt(this.oScrapTable.style.width);this.ScrapH=parseInt(this.oScrapTable.style.height);if(iTargetLevelIdx==0){if(this.ScrapL >(parseInt(oBook.oBasicLevelDiv.style.width)-(iBorder_L_Bg_Width*2)))return false;if(this.ScrapT >(parseInt(oBook.oBasicLevelDiv.style.height)-(iBorder_T_Bg_Height*2)))return false;}if((this.ScrapL+this.ScrapW)< 0)return false;if((this.ScrapT+this.ScrapH)< 0)return false;this.TileBaseURL=oDecoder2.cdeGetImgPath(iTargetLevelIdx,this.Page);this.TileImages="";Click_X=this.ScrapL;Click_Y=this.ScrapT;this.ScrapL %=oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][0];this.ScrapT %=oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][1];iMod=0;iDiv=Math.floor((this.ScrapL+this.ScrapW)/ this.TileW);if(iTargetLevelIdx==0){if(Click_X > oBook.oBookInfo.aLevelInfo[iTargetLevelIdx][0]){iDiv=0;}}if((this.ScrapL+this.ScrapW)% this.TileW !=0){iMod=1};this.TileHCount=iDiv+iMod;iMod=0;iDiv=Math.floor((this.ScrapT+this.ScrapH)/ this.TileH);if((this.ScrapH+this.ScrapH)% this.TileH !=0){iMod=1};this.TileVCount=iDiv+iMod;if(this.TileVCount > iMaxTileVCount){this.TileVCount=iMaxTileVCount;}var ClicedTilePos=new Point();ClicedTilePos=MgrLevel.GetClickedTilePos(iTargetLevelIdx,Click_X,Click_Y);re=new RegExp(this.TileBaseURL,"g");var kIdx=0;if(iTargetLevelIdx==0){if(Click_X < this.TileW){tmpTileName=oDecoder2.cdeGetTileName(iTargetLevelIdx,(this.Page-0.5 * giLeafDirect),0,0);tmpTileName=tmpTileName.replace(re,"");aTmpTileName[kIdx]=tmpTileName;kIdx++;}if((Click_X >=this.TileW)||(this.ScrapL+this.ScrapW)> this.TileW){tmpTileName=oDecoder2.cdeGetTileName(iTargetLevelIdx,(this.Page+0.5 * giLeafDirect),0,0);tmpTileName=tmpTileName.replace(re,"");aTmpTileName[kIdx]=tmpTileName;}}else{switch(giDouble){case 1 : for(jIdx=ClicedTilePos.y;jIdx <(ClicedTilePos.y+this.TileVCount);jIdx++){for(iIdx=ClicedTilePos.x;iIdx <(ClicedTilePos.x+this.TileHCount);iIdx++){tmpTileName=oDecoder2.cdeGetTileName(iTargetLevelIdx,this.Page,jIdx,iIdx);tmpTileName=tmpTileName.replace(re,"");aTmpTileName[kIdx]=tmpTileName;kIdx++;}}case 0 : break;}}this.TileImages=aTmpTileName.join(",");return true;}
function DoDark(){}
function DoSoft(){oCaption.style.filter="alpha(Opacity=20);";}
function OnMouseDownScrapDiv(arg_Obj){this.ScrapAreaLeft=parseInt(this.oScrapTable.style.left);this.ScrapAreaTop=parseInt(this.oScrapTable.style.top);this.Clicked=true;this.ScrapClicked_X=event.clientX;this.ScrapClicked_Y=event.clientY;arg_Obj.setCapture();this.GetLimit();}
function OnMouseMoveScrapDiv(){if(this.Clicked==false)return;var tmpLeft=this.ScrapAreaLeft-(parseInt(this.ScrapClicked_X)-parseInt(event.clientX));var tmpTop=this.ScrapAreaTop-(parseInt(this.ScrapClicked_Y)-parseInt(event.clientY));if(tmpLeft < this.MinLeft){tmpLeft=this.MinLeft;}if(tmpTop < this.MinTop){tmpTop=this.MinTop;}if(tmpLeft > this.MaxLeft){tmpLeft=this.MaxLeft;}if(tmpTop > this.MaxTop){tmpTop=this.MaxTop;}this.oScrapTable.style.left=tmpLeft;this.oScrapTable.style.top=tmpTop;}
function OnMouseUpScrapDiv(arg_Obj){this.Clicked=false;arg_Obj.releaseCapture();}
 
 
 function OnMouseDownResize(arg_Obj){
	 this.ResizeLeft=parseInt(this.oScrapTable.style.left);

	 this.ResizeTop=parseInt(this.oScrapTable.style.top);
	 this.ResizeWidth=parseInt(this.oScrapTable.style.width);
	 this.ResizeHeight=parseInt(this.oScrapTable.style.height);
	 this.Clicked=true;
	 this.ResizeClicked_X=event.clientX;
	 this.ResizeClicked_Y=event.clientY;

	 arg_Obj.setCapture();

	}
 
 
 function OnMouseMoveResize(arg_Obj,arg_Direct){if(this.Clicked==false)return;var tmpLeft=0;var tmpTop=0;var tmpWidth=0;var tmpHeight=0;var iVarX=parseInt(this.ResizeClicked_X)-parseInt(event.clientX);var iVarY=parseInt(this.ResizeClicked_Y)-parseInt(event.clientY);if((this.ResizeWidth < iVarX+40)||(this.ResizeHeight < iVarY+30)){return}switch(arg_Direct){case "L" : this.oScrapTable.style.left=this.ResizeLeft-iVarX;this.oScrapTable.style.width=this.ResizeWidth+iVarX;break;case "T" : this.oScrapTable.style.top=this.ResizeTop-iVarY;this.oScrapTable.style.height=this.ResizeHeight+iVarY;break;case "R" : this.oScrapTable.style.width=this.ResizeWidth-iVarX;break;case "B" : this.oScrapTable.style.height=this.ResizeHeight-iVarY;break;case "LT" : this.oScrapTable.style.left=this.ResizeLeft-iVarX;this.oScrapTable.style.top=this.ResizeTop-iVarY;this.oScrapTable.style.width=this.ResizeWidth+iVarX;this.oScrapTable.style.height=this.ResizeHeight+iVarY;break;case "RT" : this.oScrapTable.style.top=this.ResizeTop-iVarY;this.oScrapTable.style.width=this.ResizeWidth-iVarX;this.oScrapTable.style.height=this.ResizeHeight+iVarY;break;case "LB" : this.oScrapTable.style.left=this.ResizeLeft-iVarX;this.oScrapTable.style.width=this.ResizeWidth+iVarX;this.oScrapTable.style.height=this.ResizeHeight-iVarY;break;case "RB" : this.oScrapTable.style.width=this.ResizeWidth-iVarX;this.oScrapTable.style.height=this.ResizeHeight-iVarY;break;}}
 function OnMouseUpResize(arg_Obj){this.Clicked=false;arg_Obj.releaseCapture();}
 function OnMouseDown(arg_FileName){arg_Obj.src=arg_FileName;window.status=arg_Obj.src;}
 function dscDoScrap(){event.cancelBubble=true;if(this.SetScrapData()){setTimeout(this.id+".CallScrapFunc()",10);}else{}}
 function dscViewScrap(){oScrapX.ViewScrap("","","");}
 
 function CallScrapFunc(){ 
 
	    var iCurrLevel=oBook.cobGetCurrLevelIdx();
            if(this.TileHCount == 3 && iCurrLevel == 0){
		 alert("スクラップ可能領域を超えているためスクラップできません。");
	 }


	 else if(String(typeof(oScrapX.Scrap))!="undefined"){
		 oScrapX.Scrap(this.BookIndex,this.BookName,this.BookDate,Math.floor(this.Page),this.TileHCount,this.TileVCount,this.TileW	,this.TileH	,this.ScrapL	,this.ScrapT	,this.ScrapW	,this.ScrapH	,this.TileBaseURL,this.TileImages,"",true,false);
	 }else{
		 alert(""+GetRes("MsgAlertScrap",gaRes_Deco)+"");
	 }
}
