/**
 * @author Song Ji-Hoon.
 *
 * Copyright by Softmagic. All rights reserved.
 */

var bufferImg = new Image();
var bufferOrder = new Array(0, 1, 3, 2, -2, -1);

var sliceNum = parent.sliceNumber;
var currSliceNum;
var currDetailLeftPage;

var NZX, NZY; 
var SZX, SZY;
var SZMX, SZMY;

var SEP = false;
var SSP = false;
var isVirtualWidth = false;
var isVirtualHeight = false;

var borderThickness;
var displayAreaWidth, displayAreaHeight;
var briefViewLeft, briefViewTop;
var openedBookWidth, openedBookHeight; 
var totalOpenedBookWidth, totalOpenedBookHeight;
 
var ID_GotoPage, IIDGet_8X, IIDGet_2X, IIDGet_1X, IIDWFS, IIDPS, IIDPZ; 
var isRunning = false;
var detailViewLeft, detailViewTop;                                                               

var okSliceImgs = new Array();  
var okIPR, okIPL, okIPS, okIPS1, okRight_M_Img, okLeft_M_Img;                                       

var dragStartTop;
var dragStartLeft;
var isScrolling;
var isDragging;

var IIDScrollX, IIDScrollY;   
var currScrollPointX, currScrollPointY;
var beforeScrollPointX, beforeScrollPointY;  
var isMouseDown      = false;
var clickedGotoPage  = -1;
var psize            = 0;

var sPos_x = 0;
var sPos_y = 0;

var isImgLoadComplete;

function InitScreenFrame() {	
    isRunning = true;
    if (parent.menuFrameLoaded != true) {
        setTimeout("InitScreenFrame()", 10);
        return;
    }

	if (parent.backgroundColor) {
		document.body.style.backgroundColor = parent.backgroundColor;
		BorderEdge1.style.backgroundColor = parent.backgroundColor;
		BorderEdge2.style.backgroundColor = parent.backgroundColor;
		BorderEdge3.style.backgroundColor = parent.backgroundColor;
		BorderEdge4.style.backgroundColor = parent.backgroundColor;
		BorderTop.style.backgroundColor = parent.backgroundColor;
		BorderBottom.style.backgroundColor = parent.backgroundColor;
	} else {
		if (parent.BodyBackImg == "") {
			document.body.background = "./image/bg.gif";
			BorderEdge1.style.backgroundimage = "./image/bg.gif";
			BorderEdge2.style.backgroundimage = "./image/bg.gif";
			BorderEdge3.style.backgroundimage = "./image/bg.gif";
			BorderEdge4.style.backgroundimage = "./image/bg.gif";
			BorderTop.style.backgroundimage = "./image/bg.gif";
			BorderBottom.style.backgroundimage = "./image/bg.gif";

			BriefViewLayer.style.backgroundcolor = "#E0E0E0";
		}
		else {
			document.body.background = parent.BodyBackImg;
			BorderEdge1.style.backgroundimage = parent.BodyBackImg;
			BorderEdge2.style.backgroundimage = parent.BodyBackImg;
			BorderEdge3.style.backgroundimage = parent.BodyBackImg;
			BorderEdge4.style.backgroundimage = parent.BodyBackImg;
			BorderTop.style.backgroundimage = parent.BodyBackImg;
			BorderBottom.style.backgroundimage = parent.BodyBackImg;

			BriefViewLayer.style.backgroundimage = parent.BodyBackImg;
		}
	}

    displayAreaWidth  = document.body.clientWidth;
    displayAreaHeight = document.body.clientHeight;

    isVirtualWidth   = false;
    isVirtualHeight  = false;
    openedBookWidth  = parent.pageWidth_1X * 2;
    openedBookHeight = parent.pageHeight_1Y;

    if (parent.pageWidth_2X > displayAreaWidth)   isVirtualWidth = true;
    if (parent.pageHeight_2Y > displayAreaHeight) isVirtualHeight = true;
        
	borderThickness = parent.borderThickness;
    totalOpenedBookWidth  = openedBookWidth  + borderThickness * 2;
    totalOpenedBookHeight = openedBookHeight + borderThickness * 2;
    briefViewLeft = (displayAreaWidth - totalOpenedBookWidth)/2;
    briefViewTop  = (displayAreaHeight - totalOpenedBookHeight)/2;

    BriefViewLayer.style.top    = briefViewTop;
    BriefViewLayer.style.left   = briefViewLeft;
    BriefViewLayer.style.width  = totalOpenedBookWidth;
    BriefViewLayer.style.height = totalOpenedBookHeight;

    NZX = 0;
    NZY = 0;
           
    BorderEdge1.style.left   = 0;
    BorderEdge1.style.top    = 0;
    BorderEdge1.style.width  = parent.borderEdgeWidth;
    BorderEdge1.style.height = parent.borderEdgeHeight;

    BorderEdge2.style.width  = parent.borderEdgeWidth;
    BorderEdge2.style.height = parent.borderEdgeHeight;
    BorderEdge2.style.left   = totalOpenedBookWidth - parent.borderEdgeWidth;
    BorderEdge2.style.top    = 0;

    BorderEdge3.style.left   = totalOpenedBookWidth  - parent.borderEdgeWidth;
    BorderEdge3.style.top    = totalOpenedBookHeight - parent.borderEdgeHeight * 2;
    BorderEdge3.style.width  = parent.borderEdgeWidth;
    BorderEdge3.style.height = parent.borderEdgeHeight;

    BorderEdge4.style.left   = 0;
    BorderEdge4.style.top    = totalOpenedBookHeight - parent.borderEdgeHeight * 2;
    BorderEdge4.style.width  = parent.borderEdgeWidth;
    BorderEdge4.style.height = parent.borderEdgeHeight;
         
    BorderLeft.style.left    = 0;
    BorderLeft.style.top     = parent.borderEdgeHeight;
    BorderLeft.style.width   = parent.borderEdgeWidth;
    BorderLeft.style.height  = totalOpenedBookHeight - parent.borderEdgeHeight * 2;

    BorderTop.style.left     = parent.borderEdgeWidth;
    BorderTop.style.top      = parent.borderEdgeHeight - 1;
    BorderTop.style.width    = totalOpenedBookWidth - parent.borderEdgeWidth * 2;
    BorderTop.style.height   = 1;

    BorderRight.style.left   = totalOpenedBookWidth - parent.borderEdgeWidth;
    BorderRight.style.top    = parent.borderEdgeHeight;
    BorderRight.style.width  = parent.borderEdgeWidth;
    BorderRight.style.height = totalOpenedBookHeight - parent.borderEdgeHeight * 2;

    BorderBottom.style.left  = parent.borderEdgeWidth - parent.borderEdgeWidth;
    BorderBottom.style.top   = totalOpenedBookHeight - parent.borderEdgeHeight;
    BorderBottom.style.width = totalOpenedBookWidth;
    BorderBottom.style.height= parent.borderEdgeHeight;
    
    OpennedBookLayer.style.top    = borderThickness;
    OpennedBookLayer.style.left   = borderThickness;
    OpennedBookLayer.style.width  = openedBookWidth;
    OpennedBookLayer.style.height = openedBookHeight;

    PL.style.top    = 0;
    PL.style.left   = 0;
    PL.style.width  = parent.pageWidth_1X;
    PL.style.height = parent.pageHeight_1Y;

    PR.style.top    = 0;
    PR.style.left   = parent.pageWidth_1X;
    PR.style.width  = parent.pageWidth_1X;
    PR.style.height = parent.pageHeight_1Y;

    Left_M_Layer.style.width   = parent.pageWidth_1X;
    Left_M_Layer.style.height  = parent.pageHeight_1Y;   
    Right_M_Layer.style.width  = parent.pageWidth_1X;
    Right_M_Layer.style.height = parent.pageHeight_1Y;

    Left_M_Img.style.width     = parent.pageWidth_1X;
    Left_M_Img.style.height    = parent.pageHeight_1Y;
    Right_M_Img.style.width    = parent.pageWidth_1X;
    Right_M_Img.style.height   = parent.pageHeight_1Y;
  
    IPL.width   = parent.pageWidth_1X;
    IPL.height  = parent.pageHeight_1Y;
    IPR.width   = parent.pageWidth_1X;
    IPR.height  = parent.pageHeight_1Y;
    IPS.width   = parent.pageWidth_1X;
    IPS.height  = parent.pageHeight_1Y;
    IPS1.width  = parent.pageWidth_1X;
    IPS1.height = parent.pageHeight_1Y;

	StartBookMark();

	isRunning = false;
	GotoPage(parent.briefLeftPage + 2);

    setTimeout("loading()", 100);
}

function loading() {    
	if (isRunning == false) {
        if (parent.detailViewStatus) {
            if (parent.detailRightPage) {
                GotoPage(parent.briefLeftPage+1);
            } else {
                GotoPage(parent.briefLeftPage);
            }
        } else {
			GotoPage(parent.firstPage);
        }

		if (parent.autoInterval) {
			autoInterval = parent.autoInterval;
		}

		ShowLayer("BriefViewLayer");   
	} else {	
		setTimeout("loading()", 10);    
	}
}
    
var currentPage = 1;
var cacheSize = 4;
var nextMBuffer = new Array(cacheSize);
var previousMBuffer = new Array(cacheSize);
function startCache() {
	showPageLink();
	for (var i=0; i<cacheSize; i++) {
		if (parent.briefLeftPage+i+2 <= parent.lastPage) {
			nextMBuffer[i] = new Image();
			nextMBuffer[i].src = parent.GetImgUrl(parent.briefLeftPage+i+2, 2, 0);
		}
		if (parent.briefLeftPage-i-2 >= 0) {
			previousMBuffer[i] = new Image();
			previousMBuffer[i].src = parent.GetImgUrl(parent.briefLeftPage-i-2, 2, 0);
		}
	}
}

function stopCache() {
	hidePageLink();
	for (var i=0; i<cacheSize; i++) {
		if (nextMBuffer[i] && nextMBuffer[i].readyState != "complete") {
			nextMBuffer[i].src = "";
		}
		if (previousMBuffer[i] && previousMBuffer[i].readyState != "complete") {
			previousMBuffer[i].src = "";
		}
	}
}

function PageMove(isRight) {
	if (event.button == 2 || event.button == 3) {
		ZoomIn(isRight);
	} else {
		if (isRunning == false) {
			parent.detailRightPage = isRight;
			if (parent.detailRightPage) {
				setTimeout("LeafToNext()", parent.pageMoveTime);
			} else {
				setTimeout("LeafToPrev()", parent.pageMoveTime);
			}
		}
	}
}

function WheelMove() {
	if (!parent.detailViewStatus) {
		if(event.wheelDelta < 0) { 
			if (parent.frames['Frame_Screen'].isRunning == false)
				LeafToNext();
		} else {
			if (parent.frames['Frame_Screen'].isRunning == false)
				LeafToPrev();
		}
	}
}

function LeafToNext() { 
    if (!isRunning) {
		stopCache();
        if (parent.detailViewStatus) { 
            if (currDetailLeftPage < parent.lastPage) {
				if (parent.detailGotoPage != -1) {
	                GotoPage(parent.detailGotoPage);
					parent.detailGotoPage = -1;
				}
				else {
	                GotoPage(currDetailLeftPage+1);
				}
                DetailViewLayer.top = 0;       
            }
            return;
        }
        if (parent.briefLeftPage+2 < parent.lastPage) { 
            isRunning = true;
            //ClearBuffering();

            HideLayer("Right_M_Layer");
            HideLayer("Left_M_Layer");

            PS.style.top   = 0;
			PS.style.left  = parent.pageWidth_1X;
            PS1.style.top  = 0;
            PS1.style.left = parent.pageWidth_1X;

            okIPS = okIPS1 = false;
            
            IPS.width  = parent.pageWidth_1X;
			IPS1.width = 0;
            IPS.src  = parent.GetImgUrl(parent.briefLeftPage+1, 2, 0);
            IPS1.src = parent.GetImgUrl(parent.briefLeftPage+2, 2, 0);

            IIDGet_8X = setTimeout("LeafToNext1()", parent.pageMoveTime); 
        }
	} else { 
        setTimeout("LeafToNext()", parent.pageMoveTime);    
    }
}

function LeafToNext1() { 
    if (okIPS && okIPS1) { 
        SetSrc("Left_M_Img", parent.backgroundImgFile);
        SetSrc("Right_M_Img", parent.backgroundImgFile);
        ShowLayer("PS");
        okIPR = false;
        IPR.src = parent.GetImgUrl(parent.briefLeftPage+3, 2, 0);

        IIDGet_8X = setTimeout("LeafToNext2()", parent.pageMoveTime);
    } else { 
		IIDGet_8X = setTimeout("LeafToNext1()", parent.pageMoveTime);
	}
}

function LeafToNext2() { 
    if (okIPR) { 
        IIDGet_8X = setTimeout("LeafToNext3(parent.pageWidth_1X - parent.stepForSkip)", 1);
    } else { 
		IIDGet_8X = setTimeout("LeafToNext2()", parent.pageMoveTime);
	}
}

function LeafToNext3(arg_Size) {
    if (arg_Size != 0) {
        arg_Size = arg_Size - parent.stepForSkip;
        if (arg_Size < parent.stepForSkip) {
            arg_Size = 0;
        }
		IPS.width = arg_Size;

        IIDPS = setTimeout("LeafToNext3("+arg_Size+")", 1);
    } else {
        HideLayer("PS");
        IIDPS = setTimeout("LeafToNext4()", 2);
    }
}

function LeafToNext4() {
    if (IsImgSrcCompleteLoaded("IPS1")) {
        ShowLayer("PS1");
        IIDPS = setTimeout("LeafToNext5(" + parent.stepForSkip + ")", 1);
    } else {
		IIDGet_8X = setTimeout("LeafToNext4()", parent.pageMoveTime);
	}
}

function LeafToNext5(arg_Size) {
    if (arg_Size != parent.pageWidth_1X) {	
        arg_Size = arg_Size + parent.stepForSkip;
        if (arg_Size >= parent.pageWidth_1X) {
            arg_Size = parent.pageWidth_1X;
			PS1.style.left = 0;
        } else {
			PS1.style.left = parent.pageWidth_1X - arg_Size;
		}
		IPS1.width = arg_Size;    
        IIDPS = setTimeout("LeafToNext5("+arg_Size+")", 1);
    } else {
        PS1.style.left = 0;
        IPS1.width = arg_Size;
        okIPL = false;
        IPL.src = parent.GetImgUrl(parent.briefLeftPage+2, 2, 0);      
		IIDGet_8X = setTimeout("LeafToNext6()", 2);
    } 
}

function LeafToNext6() {
    if (okIPL) {
        HideLayer("PS1");
        parent.briefLeftPage = parent.briefLeftPage + 2;
        parent.frames['Frame_Hind'].ShowPageNumber();
        InitBookMark();

		soundOnForMac();
		startCache();
		Show_2XPage();

		isRunning = false;
        //IIDGet_8X = setTimeout("BufferingNext()", 10);
    } else {
		IIDGet_8X = setTimeout("LeafToNext6()", parent.pageMoveTime);
	}
}

function LeafToPrev() {
    if (!isRunning) {
		stopCache();
        if (parent.detailViewStatus) {                                                   
            if (currDetailLeftPage > parent.firstPage) {
				if (parent.detailGotoPage != -1) {
	                GotoPage(parent.detailGotoPage);
					parent.detailGotoPage = -1;
				}
				else {
	                GotoPage(currDetailLeftPage - 1);
				}
                DetailViewLayer.top = 0;                
            }
            return;
        }  
        if (parent.briefLeftPage > parent.firstPage) {   
            isRunning = true;
            //ClearBuffering();

            HideLayer("Right_M_Layer");
            HideLayer("Left_M_Layer");

            PS.style.top   = 0;
            PS.style.left  = 0;
            PS1.style.top  = 0;
            PS1.style.left = parent.pageWidth_1X;

            okIPS = okIPS1 = false;

            
            IPS.width  = parent.pageWidth_1X;
			IPS1.width = 0;
            IPS.src    = parent.GetImgUrl(parent.briefLeftPage, 2, 0);
            IPS1.src   = parent.GetImgUrl(parent.briefLeftPage-1, 2, 0);
            IIDGet_8X  = setTimeout("LeafToPrev1()", parent.pageMoveTime);
        }
	} else {
        setTimeout("LeafToPrev()", parent.pageMoveTime);  
    }
}

function LeafToPrev1() {
    if (okIPS && okIPS1) {
        SetSrc("Left_M_Img", parent.backgroundImgFile);
        SetSrc("Right_M_Img", parent.backgroundImgFile);
        ShowLayer("PS");
        okIPL = false;
        IPL.src = parent.GetImgUrl(parent.briefLeftPage-2, 2, 0);	  	  
        IIDGet_8X = setTimeout("LeafToPrev2()", parent.pageMoveTime); 
    } else {
		IIDGet_8X = setTimeout("LeafToPrev1()", parent.pageMoveTime);
	}
}


function LeafToPrev2() {
    if (okIPL) {
        IIDGet_8X = setTimeout("LeafToPrev3(parent.pageWidth_1X - parent.stepForSkip)", 1);
    } else {
		IIDGet_8X = setTimeout("LeafToPrev2()", parent.pageMoveTime);
    }
}

function LeafToPrev3(arg_Size) {
    if (arg_Size != 0) {    		
        arg_Size = arg_Size - parent.stepForSkip;
        if (arg_Size < parent.stepForSkip) {
			PS.style.left = parent.pageWidth_1X;
            arg_Size = 0;
        } else {
			PS.style.left = parent.pageWidth_1X - arg_Size;
		}
		IPS.width = arg_Size;
        IIDPS = setTimeout("LeafToPrev3("+arg_Size+")", 1);
    } else {
        HideLayer("PS");
        IIDGet_8X = setTimeout("LeafToPrev4()", 2);
    }
}

function LeafToPrev4() {
    if (IsImgSrcCompleteLoaded("IPS1")) {
        ShowLayer("PS1");
        IIDGet_8X = setTimeout("LeafToPrev5(0)", 1);
    } else {
		IIDGet_8X = setTimeout("LeafToPrev4()", parent.pageMoveTime);
	}
}

function LeafToPrev5(arg_Size) {
    if (arg_Size != parent.pageWidth_1X) {
        arg_Size = arg_Size + parent.stepForSkip;
        if (arg_Size > parent.pageWidth_1X) {
			arg_Size = parent.pageWidth_1X;
		}
		IPS1.width = arg_Size; 
        IIDPS = setTimeout("LeafToPrev5("+arg_Size+")", 1);
    } else {
		PS1.style.left = arg_Size;
        IPS1.width = arg_Size;
        okIPR = false;
        IPR.src = parent.GetImgUrl(parent.briefLeftPage-1, 2, 0);
        IIDPS = setTimeout("LeafToPrev6()", 2);
    }
}

function LeafToPrev6() {
    if (okIPR) {
        HideLayer("PS1");
        parent.briefLeftPage = parent.briefLeftPage - 2;
        parent.frames['Frame_Hind'].ShowPageNumber();
		InitBookMark();

		soundOnForMac();
		startCache();
		Show_2XPage();

        isRunning = false;
        //IIDGet_8X = setTimeout("BufferingPrev()", 10);
    } else {
		IIDGet_8X = setTimeout("LeafToPrev6()", parent.pageMoveTime);
	}
}

function BufferingNext() {
    if (parent.briefLeftPage+2 < parent.lastPage) {
        delete bufferImg;
        bufferImg = new Image();
        SetBuffer(bufferImg, parent.GetImgUrl(parent.briefLeftPage+3, 2, 0));
        IIDGet_8X = setTimeout("BufferingNext1()", parent.pageMoveTime);
    } else {
        IIDGet_8X = setTimeout("Show_2XPage()", parent.pageMoveTime);
    }
}

function BufferingNext1() {
    if (IsBufferDone(bufferImg)) {
        delete bufferImg;
        bufferImg = new Image();
        SetBuffer(bufferImg, parent.GetImgUrl(parent.briefLeftPage+2, 2, 0));
        IIDGet_8X = setTimeout("Show_2XPage()", parent.pageMoveTime);
		soundOnForMac();
		startCache();
    } else {
		IIDGet_8X = setTimeout("BufferingNext1()", parent.pageMoveTime);
	}
}

function BufferingPrev() {
    if (parent.briefLeftPage-2 > 0) {
        delete bufferImg;
        bufferImg = new Image();
        SetBuffer(bufferImg, parent.GetImgUrl(parent.briefLeftPage-2, 2, 0));
        IIDGet_8X = setTimeout("BufferingPrev1()", parent.pageMoveTime);
    } else {
        IIDGet_8X = setTimeout("Show_2XPage()", parent.pageMoveTime);
    }
}

function BufferingPrev1() {
    if (IsBufferDone(bufferImg)) {
        delete bufferImg;
        bufferImg = new Image();
        SetBuffer(bufferImg, parent.GetImgUrl(parent.briefLeftPage-1, 2, 0));
        IIDGet_8X = setTimeout("Show_2XPage()", parent.pageMoveTime);
		soundOnForMac();
		startCache();
    } else {
		IIDGet_8X = setTimeout("BufferingPrev1()", parent.pageMoveTime);
	}
}

function ClearBuffering() {
    clearTimeout(IIDWFS);
    clearTimeout(IIDGet_8X);
    clearTimeout(IIDGet_2X);
    bufferImg.src = parent.backgroundImgFile;
    delete bufferImg;
    bufferImg = new Image();
}

function GotoPage(arg_Page) {
	stopCache();
    if ( (arg_Page >= (parent.firstPage - parent.startRight)) && (arg_Page <= parent.lastPage) ) {
        isRunning = true;
        parent.briefLeftPage = arg_Page;
        if (((arg_Page + parent.firstPage)%2) != 0) parent.briefLeftPage--;
            
        HideLayer("Right_M_Layer");
        HideLayer("Left_M_Layer");
            
	    SetSrc("IPR", "image/s.gif");
	    SetSrc("IPL", "image/s.gif");

	    SetSrc("Right_M_Img", "image/s.gif");
	    SetSrc("Left_M_Img", "image/s.gif");

        ShowLayer("PR");
        ShowLayer("PL");

        if (parent.detailViewStatus) { 
            currDetailLeftPage = arg_Page;
            if (((arg_Page + parent.firstPage)%2) != 0) {
				parent.detailRightPage = true; 
            } else { 
				parent.detailRightPage = false; 
			}
            clearTimeout(IIDGet_1X); 
            clearTimeout(IIDPZ);      

            for(n = 1; n <= sliceNum; n++) { 
                document.images("DetailViewSliceImg_" + n).src = parent.backgroundImgFile;
            }           
        }
        parent.frames['Frame_Hind'].ShowPageNumber();
        okIPR = okIPL = false;
        IIDGet_8X = setTimeout("ShowTinyPage(0)", parent.pageMoveTime);
		InitBookMark();
    }
}

function ShowTinyPage(Step) {
    switch (Step) {
		case 0 : if (parent.briefLeftPage >= 1) {
					 SetSrc("IPL", parent.GetImgUrl(parent.briefLeftPage, 2, 0));
				 }
                 Step++;
				 IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                 return;
        case 1 : if (IsImgSrcCompleteLoaded("IPL")) {
					 Step++;
					 if (parent.briefLeftPage+1 <= parent.lastPage) {
						 SetSrc("IPR", parent.GetImgUrl(parent.briefLeftPage+1, 2, 0));
					 }
                     IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                 } else {
                     IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                 }
                 return;
        case 2 : if (IsImgSrcCompleteLoaded("IPR")) {
                     if (parent.briefLeftPage+bufferOrder[Step] > parent.lastPage) Step = 4;
                     if (parent.briefLeftPage+bufferOrder[Step] < 1) {
                         isRunning = false;
                         IIDWFS = setTimeout("Show_2XPage()", 10);
                         return;
                     }
                     delete bufferImg;
                     bufferImg = new Image(); 
					 SetBuffer(bufferImg, parent.GetImgUrl(parent.briefLeftPage + bufferOrder[Step], 2, 0));
                     Step++;
                     IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                 } else {
                     IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                 }
                 return;
        default : if (IsBufferDone(bufferImg)) {
                      if (Step == 5) {
                          isRunning = false;
                          IIDWFS = setTimeout("Show_2XPage_()", 10);
                          return;
                      }
                      if (bufferOrder[Step] < 1) {
                          IIDWFS = setTimeout("Show_2XPage_()", 10);
                          isRunning = false;
                          return;
                      }
                      delete bufferImg;
                      bufferImg = new Image();                        
                      SetBuffer(bufferImg, temp = parent.GetImgUrl(parent.briefLeftPage+bufferOrder[Step], 2, 0));
                      Step++;
                      IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                  } else {
                      IIDGet_8X = setTimeout("ShowTinyPage("+Step+")", 10);
                  }
                  return;
	}
}

function Show_2XPage() {
    if (parent.detailViewStatus) {
        t = true;
        for (n = 1; n <= sliceNum; n++) {
             t = t && document.images("DetailViewSliceImg_" + n).complete;
        }

        if (t) {
            NZY = document.body.clientHeight - parent.pageHeight_2Y;
            detailViewTop = NZY / 2;
            DetailViewLayer.style.left = (document.body.clientWidth  - parent.pageWidth_2X ) / 2;
            DetailViewLayer.style.top  = (document.body.clientHeight - parent.pageHeight_2Y) / 2;

            SetSrc("IZ", parent.GetImgUrl(currDetailLeftPage, 2, 0));

            IIDGet_1X = setTimeout("ShowZoom()", 10);
        } else {
            IIDGet_1X = setTimeout("Show_2XPage()", 10);
        }
	}  

    isRunning = false;
    okLeft_M_Img = okRight_M_Img = false;
          
    SetSrc("Left_M_Img", parent.GetImgUrl(parent.briefLeftPage, 0, 0));
    IIDGet_2X = setTimeout("Show_2XPage1()", 10);
}  

function Show_2XPage_() {
    if (parent.detailViewStatus) {
        t = true;
        for (n = 1; n <= sliceNum; n++) {
             t = t && document.images("DetailViewSliceImg_" + n).complete;
        }
        if (t) {
            NZY = document.body.clientHeight - parent.pageHeight_2Y;
            DetailViewLayer.style.left = (document.body.clientWidth - parent.pageWidth_2X) / 2;
            if (document.body.clientHeight > parent.pageHeight_2Y) {
                DetailViewLayer.style.top = (document.body.clientHeight - parent.pageHeight_2Y) / 2;
            } else {
                DetailViewLayer.style.top = 0;
                detailViewTop = 0;
                NZY = 0;
            }

            if (document.body.clientWidth < parent.pageWidth_2X) {
                ShowImg(LeftAutoScrollArea, 0);
                ShowImg(RightAutoScrollArea, 2);
            } else {
                HideImg(LeftAutoScrollArea, 0);
                HideImg(RightAutoScrollArea, 2);
            }
            if (document.body.clientHeight < parent.pageHeight_2Y) {
                HideImg(TopAutoScrollArea, 1);
                ShowImg(BottomAutoScrollArea, 3);
            } else {
                HideImg(TopAutoScrollArea, 1);
                HideImg(BottomAutoScrollArea, 3);
            }
              
            SetSrc("IZ", parent.GetImgUrl(currDetailLeftPage, 2, 0));

            IIDGet_1X = setTimeout("ShowZoom()", 10);
        } else {
            IIDGet_1X = setTimeout("Show_2XPage()", 10);
        }
	}

    isRunning = false;
    okLeft_M_Img = okRight_M_Img = false;
    SetSrc("Left_M_Img", parent.GetImgUrl(parent.briefLeftPage, 0, 0));
    IIDGet_2X = setTimeout("Show_2XPage1()", 10);
}        

function Show_2XPage1() {
    if (okLeft_M_Img) {
        SetSrc("Right_M_Img", parent.GetImgUrl(parent.briefLeftPage+1, 0, 0));
        ShowLayer("Left_M_Layer");
        IIDGet_2X = setTimeout("Show_2XPage2()", 10);
    } else {
		IIDGet_2X = setTimeout("Show_2XPage1()", 10);
	}
}

function Show_2XPage2() {
    if (okRight_M_Img) {
        ShowLayer("Right_M_Layer");
		soundOnForMac();
		startCache();
    } else {
		IIDGet_2X = setTimeout("Show_2XPage2()", 10);
	}
}

function ShowZoom() {
    if (IsImgSrcCompleteLoaded("IZ")) {
        SEP = SSP = false;
        currSliceNum = Math.floor((displayAreaHeight/3 - NZY) / parent.sliceImgHeight);

        if (currSliceNum > sliceNum) currSliceNum = sliceNum;
        else if (currSliceNum < 1) currSliceNum = 1;

        document.images("DetailViewSliceImg_" + currSliceNum).src = parent.GetImgUrl(currDetailLeftPage, 1, currSliceNum);
        IIDGet_1X = setTimeout(("ZoomIn3(0)"), 10);
		hideLink();
		showLink();
        isRunning = false;
    } else {
		IIDGet_1X = setTimeout("ShowZoom()", 10);
	}
}

function ZoomIn(isRight) {
    if (isRunning) {
        return;
    }
    isRunning = true;
    parent.detailViewStatus = true;
	HideBookMark();

//AutoPlay 실행 막기
	parent.frames['Frame_Hind'].PreventAutoPlayArea();

    parent.detailRightPage = isRight;
    eventOffsetX = event.offsetX;
    detailViewLeft = briefViewLeft + borderThickness;
    currDetailLeftPage = parent.briefLeftPage;
    if (parent.detailRightPage) {
        detailViewLeft = detailViewLeft + parent.pageWidth_1X;
        currDetailLeftPage++;
    }

    parent.frames['Frame_Hind'].ShowPageNumber();
	InitBookMark();

    eventOffsetY = event.offsetY;
    currSliceNum = Math.floor(eventOffsetY*parent.sliceNumber / parent.pageWidth_2X) + 3;
    if (currSliceNum > sliceNum) {
		currSliceNum = sliceNum;
	}

    detailViewTop = briefViewTop + borderThickness;

    if (displayAreaWidth >= parent.pageWidth_2X) {
        NZX = Math.floor((displayAreaWidth - parent.pageWidth_2X)/2);
    } else {
        NZX = Math.floor(displayAreaWidth/2 - eventOffsetX*parent.zoomRatio);
        if (NZX > 0) {
			NZX = 0;
        } else if (NZX < (displayAreaWidth - parent.pageWidth_2X)) {
			NZX = displayAreaWidth - parent.pageWidth_2X;
		}
    }

    if (displayAreaHeight >= parent.pageHeight_2Y) {
        NZY = Math.floor((displayAreaHeight - parent.pageHeight_2Y)/2);
    } else { 
        NZY = Math.floor(displayAreaHeight/2 - eventOffsetY*parent.zoomRatio);
        if (NZY > 0) {
			NZY = 0;
        } else if (NZY < (displayAreaHeight - parent.pageHeight_2Y)) {
			NZY = displayAreaHeight - parent.pageHeight_2Y;
		}
    }

    SZX  = Math.round((parent.pageWidth_2X - parent.pageWidth_1X) / parent.stepForDetailView);
    SZY  = Math.round((parent.pageHeight_2Y - parent.pageHeight_1Y) / parent.stepForDetailView);
    SZMX = Math.round((NZX - detailViewLeft) / parent.stepForDetailView);
    SZMY = Math.round((NZY - detailViewTop) / parent.stepForDetailView);
              
    DetailView.style.width  = parent.pageWidth_2X;
    DetailView.style.height = parent.pageHeight_2Y;	
	DetailViewLayer.style.left = detailViewLeft;          
    DetailViewLayer.style.top  = detailViewTop;                  
    
    IZ.width = parent.pageWidth_1X;
    IZ.height = parent.pageHeight_1Y;
    
	if (parent.detailRightPage) SetSrc("IZ", IPR.src);
    else SetSrc("IZ", IPL.src);

    IIDPZ = setTimeout("ZoomIn1()", 1);
}

function ZoomIn1() {
    if (IsImgSrcCompleteLoaded("IZ")) { 
		ShowLayer("DetailView");
        ShowLayer("DetailViewLayer");
        IIDPZ = setTimeout("ZoomIn2(1)", 1);
    } else {
		IIDPZ = setTimeout("ZoomIn1()", 2);
	}
}

function ZoomIn2(step) {
    if (step == parent.stepForDetailView) {
        DetailViewLayer.style.left = NZX;
        DetailViewLayer.style.top  = NZY;

        IZ.width  = parent.pageWidth_2X;
        IZ.height = parent.pageHeight_2Y;

        if (parent.detailRightPage && (Right_M_Img.width > 100)) {
            SetSrc("IZ", Right_M_Img.src);
        } else if (!parent.detailRightPage && (Left_M_Img.width > 100)) {
            SetSrc("IZ", Left_M_Img.src);
        }
      
        for (n = 1; n <= sliceNum; n++) {
             document.all("DetailViewSlice_" + n).style.top = parent.sliceImgHeight*(n-1);
             document.all("DetailViewSlice_" + n).style.left = 0;
             document.images("DetailViewSliceImg_" + n).src = parent.backgroundImgFile;
        }

        isRunning = false;
        SEP = SSP = false;
        okSliceImgs[currSliceNum] = false;
        document.images("DetailViewSliceImg_" + currSliceNum).src = parent.GetImgUrl(currDetailLeftPage, 1, currSliceNum);    
        IIDGet_1X = setTimeout(("ZoomIn3(0)"), 1);

        if (parseInt(DetailViewLayer.style.left) < 0) ShowImg(LeftAutoScrollArea, 0);
        if (parseInt(DetailViewLayer.style.top)  < 0) ShowImg(TopAutoScrollArea, 1);
        if (parseInt(DetailView.style.width) + parseInt(DetailViewLayer.style.left) > document.body.clientWidth) ShowImg(RightAutoScrollArea , 2);
        if (parseInt(DetailView.style.height) + parseInt(DetailViewLayer.style.top) > document.body.clientHeight) ShowImg(BottomAutoScrollArea , 3);
	} else {
        DetailViewLayer.style.left = detailViewLeft + SZMX*step;
        DetailViewLayer.style.top = detailViewTop + SZMY*step;
        IZ.width = parent.pageWidth_1X + SZX*step;
        IZ.height = parent.pageHeight_1Y + SZY*step;

        if (IZ.width > parent.pageWidth_2X) {
            IZ.width = parent.pageWidth_2X;
        }
        if (IZ.height > parent.pageHeight_2Y ) {
            IZ.width = parent.pageHeight_2Y;
        }

        step++;
        IIDPZ = setTimeout("ZoomIn2("+step+")", 1);
	}
}   
   
function ZoomIn3(step) {
    temp = currSliceNum + step;
    if ((temp > sliceNum) || ( temp < 0)) {
        if (step > 0) step = -step; 
        else step = 1 - step;
    }
    if (IsImgSrcCompleteLoaded("DetailViewSliceImg_" + temp)) {
        ShowLayer("DetailViewSlice_" + temp);
        if (SEP && SSP) {
            IIDPZ = setTimeout("ZoomIn4()", 1); 
            return;
        }
        if (step == 0) {
            for (n = 1; n <= sliceNum; n++) {
                 okSliceImgs[n] = false;
            }
            ShowLayer("DetailViewLayer");
            if (temp != sliceNum) 
				step = +1;
            else { 
                SEP = true;
                step = -1;
            }
        } else if (step > 0) {
            if (currSliceNum-step > 0) step = -step;
            else {
                SSP = true;
                if ((temp != sliceNum) || (temp != 1)) 
					step++;
                else {
					IIDPZ = setTimeout("ZoomIn4()", 1); 
					return;
                }
            }
        } else {
            if (currSliceNum-step < sliceNum) 
				step = 1 - step;
            else {
                if ((temp != 1) || (temp != sliceNum)) 
					step--;
                else {
					IIDPZ = setTimeout("ZoomIn4()", 1); 
					return;
                }
            }
        }
        temp = currSliceNum + step;
        if ((temp < 1) || (temp > sliceNum)) {
            IIDPZ = setTimeout("ZoomIn4()", 1); 
            return;
        }
        document.images("DetailViewSliceImg_" + temp).src = parent.GetImgUrl(currDetailLeftPage, 1, temp);
        IIDGet_1X = setTimeout(("ZoomIn3("+step+")"), 1);
	} else {
        IIDGet_1X = setTimeout(("ZoomIn3("+step+")"), 1);
    }
}


function ZoomIn4() {
	GoodsLayer.style.left = NZX;
    GoodsLayer.style.top  = NZY;
	GoodsLayer.style.width = DetailViewLayer.style.width;
	GoodsLayer.style.height = DetailViewLayer.style.height;	
	showLink();
}

function ZoomOut() {
    if (isRunning) return;

    isRunning = true;
    clearTimeout(IIDScrollX);
    clearTimeout(IIDScrollY);
    clearTimeout(IIDGet_1X);
    clearTimeout(IIDPZ);

	hideLink();

    parent.detailViewStatus = false;
    parent.frames['Frame_Hind'].ShowPageNumber();
	InitBookMark();

//AutoPlay 풀기
	parent.frames['Frame_Hind'].SetAutoPlayArea();

    detailViewLeft = briefViewLeft + borderThickness;
    if (parent.detailRightPage) {
        detailViewLeft = detailViewLeft + parent.pageWidth_1X;
    }
    detailViewTop = briefViewTop + borderThickness;
    for (n = 1; n <= sliceNum; n++) {
         HideLayer("DetailViewSlice_" + n);
         SetSrc("DetailViewSliceImg_" + n, parent.backgroundImgFile);
    }

    SZMX = Math.round((NZX-detailViewLeft) / parent.stepForDetailView);
    SZMY = Math.round((NZY-detailViewTop) / parent.stepForDetailView);

    IIDPZ = setTimeout("ZoomOut1(parent.stepForDetailView)", 1);

    HideImg(TopAutoScrollArea, 1);
    HideImg(BottomAutoScrollArea, 3);
    HideImg(LeftAutoScrollArea, 0);
    HideImg(RightAutoScrollArea, 2);
}   

function ZoomOut1(arg_StepForDetailView) {
    if (arg_StepForDetailView == 1) {
        IZ.width = parent.pageWidth_1X;
        IZ.height = parent.pageHeight_1Y;
        HideLayer("DetailViewLayer");
        HideLayer("DetailView");
		ShowBookMark();
        isRunning = false;
    } else {
        DetailViewLayer.style.left = detailViewLeft + SZMX*arg_StepForDetailView;
        DetailViewLayer.style.top = detailViewTop + SZMY*arg_StepForDetailView;
        IZ.width = parent.pageWidth_1X + SZX*arg_StepForDetailView;
        IZ.height = parent.pageHeight_1Y + SZY*arg_StepForDetailView;
        arg_StepForDetailView--;
        IIDPZ = setTimeout("ZoomOut1("+arg_StepForDetailView+")", 1);
    }
}   

function Scrolling(arg_obj) {
    var ScrollImg = arg_obj.all.tags("IMG");
    
	if (ScrollImg[0].style.visibility == "hidden") return; 
    if (!(parent.detailViewStatus)) return;

    currScrollPointX = event.clientX;
    currScrollPointY = event.clientY;

    if ((currScrollPointX == beforeScrollPointX) && (currScrollPointY == beforeScrollPointY)) return;

	beforeScrollPointX = currScrollPointX;
	beforeScrollPointY = currScrollPointY;
    ZoomInScrollStop();

    var itmp = 0;
    switch (eval(arg_obj.id)) {
		case 0 : t = (event.clientX);
                 isScrolling = true;
                 IIDScrollX = setTimeout("ZoomInScrollRight("+t+")", 10);
                 return;               
        case 1 : t = (event.clientY);
                 isScrolling = true;
                 IIDScrollY = setTimeout("ZoomInScrollDown("+t+")", 10);
                 return;
        case 2 : t = (displayAreaWidth - event.clientX);
                 isScrolling = true;
                 IIDScrollX = setTimeout("ZoomInScrollLeft("+t+")", 10);
                 return;
        case 3 : t = (displayAreaHeight - event.clientY);
                 isScrolling = true;
                 IIDScrollY = setTimeout("ZoomInScrollUp("+t+")", 10);
                 return;
	}
}

function ZoomInScrollStop() {
    clearTimeout(IIDScrollX);
    clearTimeout(IIDScrollY);
}

function ZoomInScrollRight(arg_tempo) {
    if (isMouseDown) return;
    if (parseInt(DetailViewLayer.style.left) + parent.stepForScroll < 0) {
        detailViewLeft = parseInt(DetailViewLayer.style.left) + parent.stepForScroll;
        GoodsLayer.style.left = DetailViewLayer.style.left = detailViewLeft;
        NZX = detailViewLeft;

        IIDScrollY = setTimeout("ZoomInScrollRight("+arg_tempo+")", arg_tempo);
        ShowImg(LeftAutoScrollArea, 0);
        ShowImg(RightAutoScrollArea, 2);
    } else {
        GoodsLayer.style.left = DetailViewLayer.style.left = 0;
        ShowImg(RightAutoScrollArea, 2);
        setTimeout("HideImg(LeftAutoScrollArea, 0)", 10);
    }
}

function ZoomInScrollDown(arg_tempo) {
    if (isMouseDown) return;
    if (parseInt(DetailViewLayer.style.top) + parent.stepForScroll < 0) {
        detailViewTop = parseInt(DetailViewLayer.style.top) + parent.stepForScroll;
        GoodsLayer.style.top = DetailViewLayer.style.top = detailViewTop;
        NZY = detailViewTop;
        IIDScrollY = setTimeout("ZoomInScrollDown("+arg_tempo+")", arg_tempo);
        ShowImg(TopAutoScrollArea, 1);
        ShowImg(BottomAutoScrollArea, 3);
    } else {
        GoodsLayer.style.top = DetailViewLayer.style.top = 0;
        setTimeout("HideImg(TopAutoScrollArea, 1)", 10);
    }
}

function ZoomInScrollLeft(arg_tempo) {
    if (isMouseDown) return;
    if (displayAreaWidth - parseInt(DetailViewLayer.style.left) + parent.stepForScroll < parent.pageWidth_2X) {
        detailViewLeft = parseInt(DetailViewLayer.style.left) - parent.stepForScroll;
        GoodsLayer.style.left = DetailViewLayer.style.left = detailViewLeft;
        NZX = detailViewLeft;
        IIDScrollY = setTimeout("ZoomInScrollLeft("+arg_tempo+")", arg_tempo);
        ShowImg(LeftAutoScrollArea, 0);
        ShowImg(RightAutoScrollArea, 2);
    } else {
        GoodsLayer.style.left = DetailViewLayer.style.left = displayAreaWidth - parent.pageWidth_2X;
        ShowImg(LeftAutoScrollArea, 0);
        setTimeout("HideImg(RightAutoScrollArea, 2)", 10);
    }
}

function ZoomInScrollUp(arg_tempo) {
    if (isMouseDown) return;
    if (displayAreaHeight - parseInt(DetailViewLayer.style.top) + parent.stepForScroll < parent.pageHeight_2Y) {
        detailViewTop = parseInt(DetailViewLayer.style.top) - parent.stepForScroll;
        GoodsLayer.style.top = DetailViewLayer.style.top = detailViewTop;
        NZY = detailViewTop;
        IIDScrollY = setTimeout("ZoomInScrollUp("+arg_tempo+")", arg_tempo);
        ShowImg(TopAutoScrollArea, 1);
        ShowImg(BottomAutoScrollArea, 3);
    } else {
        GoodsLayer.style.top = DetailViewLayer.style.top = displayAreaHeight - parent.pageHeight_2Y;
        setTimeout("HideImg(BottomAutoScrollArea, 3)", 10);
    }
}

function ZoomInMouseWheel(arg_obj) {
	var ScrollImg = arg_obj.all.tags("IMG");
    
	if (ScrollImg[0].style.visibility == "hidden") return; 
    if (!(parent.detailViewStatus)) return;

	var viewerTop;
	var newPosition;
	switch (event.wheelDelta) {
		case 120 :
		case 240 :
		case 360 :
		case 480 :
		case 600 :
		case 720 :
		case 840 :
		case 960 :
		case 1080 :
		case 1200 :
		case 1320 : ZoomInScrollStop();
		            newPosition = parseInt(DetailViewLayer.style.top) + (parseInt(event.wheelDelta) / 2);
					if (newPosition < 0) {
						GoodsLayer.style.top = DetailViewLayer.style.top = newPosition;
						NZY = newPosition;
						ShowImg(TopAutoScrollArea, 1);
						ShowImg(BottomAutoScrollArea, 3);
					} else {
						GoodsLayer.style.top = DetailViewLayer.style.top = 0;
						NZY = 0;
						HideImg(TopAutoScrollArea, 1);
					}
					break;
		case -120 :
		case -240 :
		case -360 :
		case -480 :
		case -600 :
		case -720 :
		case -840 :
		case -960 :
		case -1080 :
		case -1200 :
		case -1320 : ZoomInScrollStop();
					 viewerTop = parseInt(displayAreaHeight) - parseInt(DetailView.style.height);
		             newPosition = parseInt(DetailViewLayer.style.top) + (parseInt(event.wheelDelta) / 2);
					 if (newPosition > viewerTop) {
						 GoodsLayer.style.top = DetailViewLayer.style.top = newPosition;
						 NZY = newPosition;
						 ShowImg(TopAutoScrollArea, 1);
						 ShowImg(BottomAutoScrollArea, 3);
					 } else {
						GoodsLayer.style.top = DetailViewLayer.style.top = viewerTop;
						NZY = viewerTop;
						HideImg(BottomAutoScrollArea, 3);
					}
					break;
	}
}

function MouseDown(arg_Obj) {
	if (parent.detailViewStatus == true) {
//		arg_Obj.setCapture();

        isMouseDown = true;
        sPos_x     = event.screenX;
        sPos_y     = event.screenY;
        dragStartTop  = parseInt(DetailViewLayer.style.top);
        dragStartLeft = parseInt(DetailViewLayer.style.left);
        DetailViewLayer.style.cursor = "hand";
    }
}

function MouseUp(arg_Obj) { 
    if (parent.detailViewStatus == true) {
        ZoomOut();
    }
    isMouseDown = false;
}

function ZoomInMove(arg_obj) {
    if (!(parent.detailViewStatus)) { return; }

    if (isMouseDown) {
        if ((Math.abs(sPos_x - event.x) > 5) || (Math.abs(sPos_y - event.y) > 5)) {
            isDragging = true;
            DetailViewLayer.style.cursor = "hand";
            Dragging();
            return;
        }
    }
}

function Dragging() {
	var MPos_x;
    var MPos_y;

    var ResultDragTop;
    var ResultDragLeft; 

    MPos_x = event.screenX;
    MPos_y = event.screenY;

    if (parent.detailViewStatus && isMouseDown) {
		ResultDragTop  = DetailViewLayer.style.top;
		ResultDragLeft = DetailViewLayer.style.left;
      
		if (((document.body.clientWidth - parent.pageWidth_2X) >= 0) && ((document.body.clientHeight - parent.pageHeight_2Y) >= 0)) {
			HideImg(TopAutoScrollArea   , 1);
			HideImg(BottomAutoScrollArea, 3);
			HideImg(LeftAutoScrollArea  , 0);
			HideImg(RightAutoScrollArea , 2);
		} else if (((document.body.clientWidth - parent.pageWidth_2X) >= 0 ) && ((document.body.clientHeight - parent.pageHeight_2Y) < 0 )) {
			ResultDragTop = dragStartTop + MPos_y - sPos_y;
			if (ResultDragTop > 0) {
				HideImg(TopAutoScrollArea, 1);
				ResultDragTop = 0;
			} else {
				ShowImg(TopAutoScrollArea, 1);
			}
			if (ResultDragTop < (document.body.clientHeight - parent.pageHeight_2Y)) {
				ResultDragTop = document.body.clientHeight - parent.pageHeight_2Y;
				HideImg(BottomAutoScrollArea, 3);
			} else {
				ShowImg(BottomAutoScrollArea, 3);
			}  
		} else if (((document.body.clientWidth - parent.pageWidth_2X) < 0) && ((document.body.clientHeight - parent.pageHeight_2Y) >= 0 )) {
			ResultDragLeft = dragStartLeft + MPos_x - sPos_x;
			if (ResultDragLeft > 0) {
				HideImg(LeftAutoScrollArea, 0);
				ResultDragLeft = 0;
			} else {
				ShowImg(LeftAutoScrollArea, 0);
			}
			if (ResultDragLeft < (document.body.clientWidth - parent.pageWidth_2X)) {
				HideImg(RightAutoScrollArea, 2);
				ResultDragLeft = document.body.clientWidth - parent.pageWidth_2X;
			} else {
				ShowImg(RightAutoScrollArea, 2);
			}
		} else {
			ResultDragTop  = dragStartTop  + MPos_y - sPos_y;
			ResultDragLeft = dragStartLeft + MPos_x - sPos_x;
			if (ResultDragTop >= 0) {
				ResultDragTop = 0;
				HideImg(TopAutoScrollArea, 1);
			} else {
				ShowImg(TopAutoScrollArea, 1);
			}
			if (ResultDragLeft >= 0) {
				ResultDragLeft = 0;
				HideImg(LeftAutoScrollArea, 0);
			} else {
				ShowImg(LeftAutoScrollArea, 0);
			}
			if (ResultDragTop <= (document.body.clientHeight - parent.pageHeight_2Y)) {
				ResultDragTop = document.body.clientHeight - parent.pageHeight_2Y;
				HideImg(BottomAutoScrollArea, 3);
			} else {
				ShowImg(BottomAutoScrollArea, 3);
			}
			if (ResultDragLeft <= (document.body.clientWidth - parent.pageWidth_2X)) {
				ResultDragLeft = document.body.clientWidth - parent.pageWidth_2X;
				HideImg(RightAutoScrollArea, 2);
			} else {
				ShowImg(RightAutoScrollArea, 2);
			}
		}      
		GoodsLayer.style.top = DetailViewLayer.style.top  = ResultDragTop;
		GoodsLayer.style.left = DetailViewLayer.style.left = ResultDragLeft;
	}
}

function ShowLayer(IN) {  
    document.all(IN).style.visibility = "visible";
}

function HideLayer(IN) {
    document.all(IN).style.visibility = "hidden";
}

function ShowImg(arg_Div, arg_Num) {
    var ScrollImg = arg_Div.all.tags("IMG");
    ScrollImg[0].style.visibility = "visible";
    arg_Div.style.zIndex = 1000 + arg_Num;
}

function HideImg(arg_Div, arg_Num) {
    var ScrollImg = arg_Div.all.tags("IMG");
    ScrollImg[0].style.visibility = "hidden";
    arg_Div.style.zIndex = arg_Num;
}

function SetSrc(IN, URL) {
    document.images(IN).src = URL;
}

function SetBuffer(IN, URL){
    IN.src = URL;
}

function SetImgLayer(o) {
    switch(o) {
		case 0 : okIPL = true;
                 break;
        case 1 : okIPR = true;
                 break;
        case 2 : okIPS = true;
                 break;
        case 3 : okIPS1 = true;
                 break;
                
        case -1 : okLeft_M_Img = true;
                  break;
        case -2 : okRight_M_Img = true;
                  break;
	}
    if (o > 100) okSliceImgs[o-100] = true;
}

function IsImgSrcCompleteLoaded(IN) {
    return document.images(IN).complete;
}

function IsBufferDone(IN) {
    return IN.complete;                                                                                
}

function IsImgLoadComplte() {
    isImgLoadComplete = true; 
}

function Resize() {
    InitScreenFrame();
}



function IB_pgini(obj){
	IB_loadtree(obj);
}

var IB_imageDir = "image/menu/";
var IB_listdata = null;
var IB_listpage = null;
function IB_loadtree(tarobj){ 
	tarobj.innerHTML = "";
	IB_listpage = parent.IB_listpage;
	for(var i=0;i<IB_listdata.length;i++){
		var source = "";
			source 	+= 	'<TABLE	BORDER		= "0"'
					+'	CELLSPACING	= "0"'
					+'	CELLPADDING	= "0">'
					+'<TR height="18">'
					+'<TD	WIDTH		= "18"'
					+'	VALIGN		= "middle"'
					+'	ALIGN		= "left">'
					+'<IMG	SRC		= "'+IB_imageDir+'default_E.gif"'
					+'	SUPERID		= "'+i+'"'
					+'	ONCLICK		= "treeiconclick(this)">'
					+'</TD>'
					+'<TD	WIDTH		= "16"'
					+'	VALIGN		= "middle"'
					+'	ALIGN		= "left">'
					+'<IMG	SRC		= "'+IB_imageDir+'icon_field.gif">'
					+'</TD>'
					+'<TD	NOWRAP		= "false"'
					+'	ONMOUSEOUT	= "textmouseout(this)"'
					+'	ONMOUSEOVER	= "textmouseover(this)"'
					+'	ONCLICK		= "textclick(this)"'
					+'	ONDBLCLICK	= "treeiconclick(this.parentElement.children(0).children(0))"'
					+'	VALIGN		= "middle"'
					+'	ALIGN		= "left"'
					+'	CLASS		= "normal"'
					+'	GOURL		= "'+IB_listpage[i]+'"'
					+'	ID		= ""'
					+'	STYLE		= "cursor:hand;">'
					+ IB_listdata[i]
					+'</TD>'
					+'</TR>'
					+'</TABLE>'
					+'<TABLE	BORDER		= "0"'
					+'	CELLSPACING	= "0"'
					+'	CELLPADDING	= "0"'
					+'	STYLE		="display:none">'
					+'<TR>'
					+'<TD	WIDTH		= "18"'
					+'	VALIGN		= "middle"><img src="'+IB_imageDir+'null.gif">'
					+'</TD>'
					+'<TD	ID		= "SUB'+i+'"'
					+'	VALIGN		= "middle"'
					+'	CLASS		= "normal"'
					+'	ALIGN		= "left">'
					+'</TD>'
					+'</TR>'
					+'</TABLE>'; 

			tarobj.insertAdjacentHTML("beforeend",source);
	}
}

function IB_opentree(str,obj){
	for(var i=0;i<IB_listdata.length;i++){
		var source = "";
		var listdataArray = IB_listdata[i].split("|");
		if(listdataArray[0] == str){
			if(listdataArray[1]=="0"){
				menudataTreeSrc = IB_imageDir+"default_E.gif";
			}
			else{
				menudataTreeSrc = IB_imageDir+"cross_E.gif";
			}

			source 	+= 	'<TABLE	BORDER		= "0"'
					+'	CELLSPACING	= "0"'
					+'	CELLPADDING	= "0">'
					+'<TR height="18">'
					+'<TD	WIDTH		= "18"'
					+'	VALIGN		= "middle"'
					+'	ALIGN		= "left">'
					+'<IMG	SRC		= "'+menudataTreeSrc+'"'
					+'	SUPERID		= "'+i+'"'
					+'	ONCLICK		= "treeiconclick(this)">'
					+'</TD>'
					+'<TD	WIDTH		= "16"'
					+'	VALIGN		= "middle"'
					+'	ALIGN		= "left">'
					+'<IMG	SRC		= "'+IB_imageDir+listdataArray[3]+'">'
					+'</TD>'
					+'<TD	NOWRAP		= "false"'
					+'	ONMOUSEOUT	= "textmouseout(this)"'
					+'	ONMOUSEOVER	= "textmouseover(this)"'
					+'	ONCLICK		= "textclick(this)"'
					+'	ONDBLCLICK	= "treeiconclick(this.parentElement.children(0).children(0))"'
					+'	VALIGN		= "middle"'
					+'	ALIGN		= "left"'
					+'	CLASS		= "normal"'
					+'	GOURL		= "'+listdataArray[4]+'"'
					+'	ID		= ""'
					+'	STYLE		= "cursor:hand;">'
					+ listdataArray[2]
					+'</TD>'
					+'</TR>'
					+'</TABLE>'
					+'<TABLE	BORDER		= "0"'
					+'	CELLSPACING	= "0"'
					+'	CELLPADDING	= "0"'
					+'	STYLE		="display:none">'
					+'<TR>'
					+'<TD	WIDTH		= "18"'
					+'	VALIGN		= "middle"><img src="'+IB_imageDir+'null.gif">'
					+'</TD>'
					+'<TD	ID		= "SUB'+i+'"'
					+'	VALIGN		= "middle"'
					+'	CLASS		= "normal"'
					+'	ALIGN		= "left">'
					+'</TD>'
					+'</TR>'
					+'</TABLE>';
			var tmpobject = obj.parentElement;
			while(tmpobject.id.indexOf("IB_tree") == -1){
				tmpobject = tmpobject.parentElement;	
			}
			eval("var obj=tmpobject.all.SUB"+listdataArray[0]+";");
			if(obj.children.length > 0){
				var temp = obj.children(obj.children.length-2).children(0).children(0).children(0).children(0);
				temp.src = temp.src.substring(0,temp.src.length-5)+"C.gif";
				
				obj.children(obj.children.length-1).children(0).children(0).children(0).background = IB_imageDir+"vline.gif";
			}
			obj.insertAdjacentHTML("beforeend",source);	
		}
	}
}

var clickObject = null;
function treeiconclick(obj){
	var tmpidx = getchildrenIndex(obj.parentElement.parentElement.parentElement.parentElement.parentElement,obj.parentElement.parentElement.parentElement.parentElement);
	var tmpobj = obj.parentElement.parentElement.parentElement.parentElement.parentElement.children(tmpidx+1);
	
	if(obj.src.substring(obj.src.length-11) == "cross_C.gif"){
		obj.src = IB_imageDir+"minus_C.gif";
		if(!tmpobj.children(0).children(0).children(1).children(0)){
			IB_opentree(obj.SUPERID,obj);
		}
		tmpobj.style.display = "";
	}
	else if(obj.src.substring(obj.src.length-11) == "cross_E.gif"){
		obj.src = IB_imageDir+"minus_E.gif";
		if(!tmpobj.children(0).children(0).children(1).children(0)){
			IB_opentree(obj.SUPERID,obj);
		}
		tmpobj.style.display = "";
	}
	else if(obj.src.substring(obj.src.length-11) == "minus_C.gif"){
		obj.src = IB_imageDir+"cross_C.gif";
		tmpobj.style.display = "none";
	}
	else if(obj.src.substring(obj.src.length-11) == "minus_E.gif"){
		obj.src = IB_imageDir+"cross_E.gif";
		tmpobj.style.display = "none";
	}
	menuwindow.style.pixelWidth = IB_treearea.offsetWidth*1+22+10;
	menuwindow.style.pixelWidth = IB_treearea.offsetWidth*1+22+10;
}

function getchildrenIndex(sobj,obj){
	var idx = -1;
	for(var i=0;i<sobj.children.length;i++){
		if(sobj.children(i) == obj){
			idx = i;
			break;
		}
	}
	return idx;
}

function textclick(obj){
	if(clickObject != null){
		if(clickObject != obj){
			clickObject.className = "normal";
			clickObject = null;
			clickObject = obj;
			clickObject.className = "click";
		}
	}
	else{
		clickObject = obj;
		clickObject.className = "click";
	}
	if(obj.GOURL.length > 0){
		parent.frames['Frame_Hind'].GotoPage(eval(obj.GOURL));
	}
}

function textmouseover(obj){
	if(clickObject != obj){
		obj.className = "mouseon";
	}
}

function textmouseout(obj){
	if(clickObject != obj){
		obj.className = "normal";
	}
}

var autoplayed = null;
var isAutoplay = false;
var autoInterval = 5000;
function startAutoplay(){ 
	if(!parent.detailViewStatus && !isRunning)
		autoplayed = window.setInterval("autoAction()", autoInterval);
}
function autoplaystop(){
	window.clearInterval(autoplayed);
	autoplayed = null;
	isAutoplay = false;
}

function autoAction(){ 
	if(!parent.detailViewStatus && !isRunning){
		isAutoplay = true;
		if(parent.briefLeftPage >= parent.lastPage-1){
			parent.frames['Frame_Hind'].GotoPage(parent.firstPage);
		}
		else{
			LeafToNext();
		}
	}
}

var linkData = null;
var linkImgPath = "./image/link_color/";
var linkImgExt = ".gif";
var source = "";
var ratio;
function showLink() {
	if (parent.userLinkData) {
		ratio = parent.linkRatio;
		linkData = parent.userLinkData; 
		var linkDataArray = new Array();
		
		for(var i=0; i<linkData.length; i++){ 
			linkDataArray = linkData[i].split(" ");			
			if (parseInt(linkDataArray[0]) == (parseInt(currDetailLeftPage) - parseInt(parent.startRight))) {
				createLink(linkDataArray);
			}
		}
		GoodsLayer.innerHTML = source;
		ShowLayer("GoodsLayer");
	}
}

function createLink(linkDataArray) {
	source += '<div '
			+ 'style="position:absolute; '
			+ 'left:' + linkDataArray[2]*ratio + 'px; '
			+ 'top:' + linkDataArray[3]*ratio + 'px; '
			+ 'z-index:250; '
			+ 'visibility:visible;">'
			+ '<table '
			+ '    style="position:absolute; ' 
			+ '    width:' + linkDataArray[4]*ratio + 'px; '
			+ '    height:' + linkDataArray[5]*ratio + 'px; '
			+ '    cursor:hand; '
			+ '    border:\'\'; '
			+ '    z-index:251; ' 
			+ '    visibility:visible;" '
			+ '	   ALT="' + getMessage(linkDataArray[1], linkDataArray[6]) + '" '
			+ '    OnMouseOver="this.style.border=\'' + getColorValue(linkDataArray[7]) + ' 2px solid\';" '
			+ '    OnMouseOut="this.style.border=\'\'" '
			+ '    OnClick="GotoLink(\'' + linkDataArray[1] + '\' , \'' + linkDataArray[6] + '\')">'
			+ '<tr><td></td></tr></table>'
			+ '</div>';
}

function getMessage(type, message) {
	var msg = "";
	if (type == "L") {
		msg = "Go to Web : " + message;
	} else if (type == "G") {
		msg = "Go to Page : " + message;
	} else if (type == "M") {
		msg = "Go to Media : " + message;
	}
	return msg;
}


function getColorValue(key) {
	if (key == "R") {
		return "#FF0000";
	} else if (key == "G") {
		return "#00FF00";
	} else if (key == "B") {
		return "#0000FF";
	} else if (key == "C") {
		return "#00FFFF";
	} else if (key == "M") {
		return "#FF00FF";
	} else if (key == "Y") {
		return "#FFFF00";
	} else if (key == "K") {
		return "#FFFFFF";
	} else {
		return "#FFFFFF";
	}
}

function hideLink() {
	source = "";
	HideLayer("GoodsLayer");
	GoodsLayer.innerHTML = "";
}

function GotoLink(type, data) {
	var id = "LinkWindow";
	if (type == "L") {
		window.open(data, id, "left=0, top=0, directories=yes, status=yes, location=yes, menubar=yes, scrollbars=yes, resizable=yes, fullscreen=no");
	} else if (type == "G") {
		if (parent.detailViewStatus) {
			var pageNum = parseInt(data) + parseInt(parent.startRight);
			GotoPage(pageNum);
		} else {
			parent.frames['Frame_Hind'].GotoPage(data);
		}
	} else if (type == "M") {
		if (navigator.platform == "MacPPC" && navigator.userAgent.indexOf("5.2") != -1) {
//			alert("Macintosh does not suppot this feature.");
//			var position = parseMyUrl(self.location.href);
			var url = "mac_page.htm?bgm=" + parent.soundDir + data;
			var temp = data.split(".");
			var ext = temp[temp.length - 1];
			if (ext != null && ext == "swf") {
				window.open(url, id, "left=0, top=0, width=340, height=270, directories=no, status=no, location=no, menubar=no, scrollbars=no, resizable=yes, fullscreen=no");
			}
			else {
				document.location.href = parent.soundDir + data;
			}
		}
		else {
			var url = "mac_page.htm?bgm=" + parent.soundDir + data;
			window.open(url, id, "left=0, top=0, width=340, height=270, directories=no, status=no, location=no, menubar=no, scrollbars=no, resizable=yes, fullscreen=no");
		}
	}
}

function parseMyUrl(currentUrl) {
	var tokens = currentUrl.split("body.htm");
	return tokens[0];
}

// ------------------------ Page Link ------------------------------ //
var pageLinkData = null;
var leftLink = "";
var rightLink = "";
function showPageLink() {
	leftLink = "";
    rightLink = "";
	if (parent.userLinkData) {
		pageLinkData = parent.userLinkData; 
		var linkDataArray = new Array();
		
		for(var i=0; i<pageLinkData.length; i++){ 
			linkDataArray = pageLinkData[i].split(" ");			
			if (parseInt(linkDataArray[0]) == (parseInt(parent.briefLeftPage) - parseInt(parent.startRight))) {
				createLeftPageLink(linkDataArray);
			}
			if (parseInt(linkDataArray[0]) == (parseInt(parent.briefLeftPage) + 1 - parseInt(parent.startRight))) {
				createRightPageLink(linkDataArray);
			}
		}
		LeftLinkLayer.innerHTML = leftLink;
		RightLinkLayer.innerHTML = rightLink;
		ShowLayer("LeftLinkLayer");
		ShowLayer("RightLinkLayer");
	}
}

function createLeftPageLink(linkDataArray) {
	leftLink += '<div '
			+ 'style="position:absolute; '
			+ 'left:' + linkDataArray[2] + 'px; '
			+ 'top:' + linkDataArray[3] + 'px; '
			+ 'z-index:70; '
			+ 'visibility:visible;">'
			+ '<table '
			+ '    style="position:absolute; '
			+ '    width:' + linkDataArray[4] + 'px; '
			+ '    height:' + linkDataArray[5] + 'px; '
			+ '    cursor:hand; '
			+ '    border:\'\'; '
			+ '    z-index:71; '
			+ '    visibility:visible;" '
			+ '	   ALT="' + getMessage(linkDataArray[1], linkDataArray[6]) + '" '
			+ '    OnMouseOver="this.style.border=\'' + getColorValue(linkDataArray[7]) + ' 2px solid\';" '
			+ '    OnMouseOut="this.style.border=\'\'" '
			+ '    OnClick="GotoLink(\'' + linkDataArray[1] + '\' , \'' + linkDataArray[6] + '\')">'
			+ '<tr><td></td></tr></table>'
			+ '</div>';
}

function createRightPageLink(linkDataArray) {
	rightLink += '<div '
			+ 'style="position:absolute; '
			+ 'left:' + linkDataArray[2] + 'px; '
			+ 'top:' + linkDataArray[3] + 'px; '
			+ 'z-index:70; '
			+ 'visibility:visible;">'
			+ '<table '
			+ '    style="position:absolute; '
			+ '    width:' + linkDataArray[4] + 'px; '
			+ '    height:' + linkDataArray[5] + 'px; '
			+ '    cursor:hand; '
			+ '    border:\'\'; '
			+ '    z-index:71; '
			+ '    visibility:visible;" '
			+ '	   ALT="' + getMessage(linkDataArray[1], linkDataArray[6]) + '" '
			+ '    OnMouseOver="this.style.border=\'' + getColorValue(linkDataArray[7]) + ' 2px solid\';" '
			+ '    OnMouseOut="this.style.border=\'\'" '
			+ '    OnClick="GotoLink(\'' + linkDataArray[1] + '\' , \'' + linkDataArray[6] + '\')">'
			+ '<tr><td></td></tr></table>'
			+ '</div>';
}

function hidePageLink() {
	leftLink = "";
    rightLink = "";
	HideLayer("LeftLinkLayer");
	HideLayer("RightLinkLayer");
	LeftLinkLayer.innerHTML = "";
	RightLinkLayer.innerHTML = "";
}

//////////////////////////////////////////////////////////////////////////////////////////////
/// 기능 : BookMark 
/// @author : 김대일
/// 2004년 8월 4일
//////////////////////////////////////////////////////////////////////////////////////////////
var LeftBookMarkArray = new Array();
var LeftBookMarkIndex = 0;

//var RightBookMarkArray = new Array();
//var RightBookMarkIndex = 0;

var LeftPreBookSource	= "";
var RightNextBookSource = "";

var LeftNowBookSource	= "";
//var RightNowBookSource	= "";

var bookMarkIndexWidth = parent.pageWidth_1X / 5;
var bookMarkIndexHeight = parent.pageHeight_1Y / 15;

function StartBookMark() {
//	//LeftBookMark
	LeftBookMarkButton.style.left    = briefViewLeft;
	LeftBookMarkButton.style.top     = briefViewTop + parent.pageHeight_1Y - parent.bookmarkButtonHeight;
	LeftBookMarkButton.style.width   = parent.bookmarkButtonWidth;
	LeftBookMarkButton.style.height  = parent.bookmarkButtonHeight;
	LeftBookMarkButton.style.cursor	 = "hand";
	LeftBookMarkButton.innerHTML	 = "<img src=image/bookmark/bookmark.gif width=37 height=37>";
	LeftBookMarkButton.onclick		 = new Function("SetLeftBookMark()");
	LeftBookMarkButton.style.visiblity = "hidden";

//	//RightBookMark
//    RightBookMarkButton.style.left    = briefViewLeft + totalOpenedBookWidth - parent.bookmarkButtonWidth;
//    RightBookMarkButton.style.top     = briefViewTop + parent.pageHeight_1Y - parent.bookmarkButtonHeight;
//    RightBookMarkButton.style.width   = parent.bookmarkButtonWidth;
//    RightBookMarkButton.style.height  = parent.bookmarkButtonHeight;
//	RightBookMarkButton.style.cursor  = "hand";
//	RightBookMarkButton.innerHTML	  = "<img src=bookmark/bookmark.gif width=37 height=37>";
//	RightBookMarkButton.onclick		  = new Function("SetRightBookMark()");
}

function SetLeftBookMark() {
	var ArrayIndex = 0;
	var isLeftBookMark = false;
	for (i = 0; i < LeftBookMarkIndex ; i++) {
		if (LeftBookMarkArray[i] == eval(parent.briefLeftPage - parent.startRight)) {			
			ArrayIndex = i;
			isLeftBookMark = true;
			break;
		}
	}

	if (isLeftBookMark) {
		DeleteLeftBookMark(ArrayIndex);
	}
	else {
		if (LeftBookMarkIndex >= parent.bookMarkMaxCount) {
			alert(parent.bookMarkAlert);
			return;
		}
		else {
			LeftBookMarkArray[LeftBookMarkIndex] = eval(parent.briefLeftPage - parent.startRight);
			GridNowLeftBookMark(LeftBookMarkIndex);
			LeftBookMarkIndex++;
		}
	}
}

//function SetRightBookMark() {
//	var ArrayIndex = 0;
//	var isRightBookMark = false;
//	for (i = 0; i < RightBookMarkIndex ; i++) {
//		if (RightBookMarkArray[i] == eval(parent.briefLeftPage - parent.startRight) + 1) {
//			ArrayIndex = i;
//			isRightBookMark = true;
//			break;
//		}
//	}
//
//	if (isRightBookMark) {
//		DeleteRightBookMark(isRightBookMark);
//	}
//	else {
//		if (LeftBookMarkIndex >= 5) {
//			alert(parent.bookMarkAlert);
//			return;
//		}
//		else {
//			RightBookMarkArray[RightBookMarkIndex] = eval(parent.briefLeftPage - parent.startRight + 1);
//			GridNowRightBookMark(RightBookMarkIndex);
//			RightBookMarkIndex++;
//		}
//	}
//}

function InitBookMark() {
	LeftPreBookSource	= "";
	RightNextBookSource = "";

	LeftNowBookSource	= "";
	RightNowBookSource	= "";

	LeftBookMarkArea.innerHTML = "";
	RightBookMarkArea.innerHTML = "";

	var nowPage = eval(parent.briefLeftPage - parent.startRight);

	for (i = 0; i < LeftBookMarkIndex; i++) {
		if (LeftBookMarkArray[i] == nowPage) {
			GridNowLeftBookMark(i);
		}
		else if (LeftBookMarkArray[i] < nowPage) {
			GridPreLeftBookMark(i, "L");
		}
		else if (LeftBookMarkArray[i] > nowPage + 1) {
			GridNextRightBookMark(i, "L");
		}
	}

//	for (j = 0; j < RightBookMarkIndex; j++) {
//		if (RightBookMarkArray[j] == nowPage + 1) {
//			GridNowRightBookMark(j);
//		}
//		else if (RightBookMarkArray[j] < nowPage) {
//			GridPreLeftBookMark(j,"R");
//		}
//		else if (RightBookMarkArray[j] > nowPage + 1) {
//			GridNextRightBookMark(j,"R");
//		}
//	}
}

function GridNowLeftBookMark(bookMarki) {
	var color = "blue";

	LeftNowBookSource += '<div style="position:absolute;left:' + (briefViewLeft - bookMarkIndexWidth/3) + ';top:' + (bookMarki*bookMarkIndexHeight*4/3 + briefViewTop + borderThickness*2) + ';width:' + bookMarkIndexWidth + ';height:' + bookMarkIndexHeight + ';z-index:2005;">'
					+ '<table cellspacing=0 cellpadding=0 border=0>'
					+ '  <tr>'
					+ '    <td width=' + bookMarkIndexWidth + ' height=' + bookMarkIndexHeight + ' bgcolor=' + color + '>&nbsp;</td>'
					+ '  </tr>'
					+ '</table>'
					+ '</div>';

	LeftBookMarkArea.innerHTML = LeftPreBookSource + LeftNowBookSource;
}

//function GridNowRightBookMark(bookMarki) {
//	var color = "red";
//
//	RightNowBookSource += '<div style="position:absolute;left:' + (briefViewLeft + totalOpenedBookWidth - bookMarkIndexWidth*3/4) + ';top:' + (bookMarki*bookMarkIndexHeight*4/3 + briefViewTop + borderThickness*2 + bookMarkIndexHeight/6 + bookMarkIndexHeight) + ';width:' + bookMarkIndexWidth + ';height:' + bookMarkIndexHeight + ';z-index:2015;">'
//					+ '<table cellspacing=0 cellpadding=0 border=0>'
//					+ '  <tr>'
//					+ '    <td width=' + bookMarkIndexWidth + ' height=' + bookMarkIndexHeight + ' bgcolor=' + color + '>&nbsp;</td>'
//					+ '  </tr>'
//					+ '</table>'
//					+ '</div>';
//
//	RightBookMarkArea.innerHTML = RightNextBookSource + RightNowBookSource;
//}

function GridPreLeftBookMark(bookMarki, direction) {
	var addValue = 0;
	var color = "blue";
	var gotoPage = 0;

	if (direction == "L") {
		addValue = 0;
		gotoPage = LeftBookMarkArray[bookMarki];
	}
	else {
		addValue = bookMarkIndexHeight/6 + bookMarkIndexHeight;
		color = "red"
		gotoPage = RightBookMarkArray[bookMarki];
	}

	LeftPreBookSource += '<div style="position:absolute;left:' + (briefViewLeft - bookMarkIndexWidth/3) + ';top:' + (bookMarki*bookMarkIndexHeight*4/3 + briefViewTop + borderThickness*2 + addValue) + ';width:' + bookMarkIndexWidth/3 + ';height:' + bookMarkIndexHeight + ';z-index:2006;">'
					+ '<table cellspacing=0 cellpadding=0 border=0>'
					+ '  <tr>'
					+ '    <td align=center width=' + bookMarkIndexWidth/3 + ' height=' + bookMarkIndexHeight + ' bgcolor=' + color + ' title=\"' + gotoPage + 'P\" OnClick=\"MoveBookMark(' + gotoPage + ')\" style=\"cursor:hand\"><font color=white>' + gotoPage + '</font></td>'
					+ '  </tr>'
					+ '</table>'
					+ '</div>';

	LeftBookMarkArea.innerHTML = LeftPreBookSource + LeftNowBookSource;
}

function GridNextRightBookMark(bookMarki, direction) {
	var addValue = 0;
	var color = "blue";
	if (direction == "L") {
		addValue = 0;
		gotoPage = LeftBookMarkArray[bookMarki];
	}
	else {
		addValue = bookMarkIndexHeight/6 + bookMarkIndexHeight;
		color = "red"
		gotoPage = RightBookMarkArray[bookMarki];
	}

	RightNextBookSource += '<div style="position:absolute;left:' + (briefViewLeft + totalOpenedBookWidth) + ';top:' + (bookMarki*bookMarkIndexHeight*4/3 + briefViewTop + borderThickness*2 + addValue) + ';width:' + bookMarkIndexWidth/3 + ';height:' + bookMarkIndexHeight + ';z-index:2016;">'
					+ '<table cellspacing=0 cellpadding=0 border=0>'
					+ '  <tr>'
					+ '    <td align=center width=' + bookMarkIndexWidth/3 + ' height=' + bookMarkIndexHeight + ' bgcolor=' + color + '  title=\"' + gotoPage + 'P\" OnClick=\"MoveBookMark(' + gotoPage + ')\" style=\"cursor:hand\"><font color=white>' + gotoPage + '</font></td>'
					+ '  </tr>'
					+ '</table>'
					+ '</div>';

	RightBookMarkArea.innerHTML = RightNextBookSource + RightNowBookSource;
}

function DeleteLeftBookMark(arrayIndex) {
	LeftNowBookSource = "";
	LeftBookMarkArea.innerHTML = LeftPreBookSource + LeftNowBookSource;

	if (LeftBookMarkIndex == 1) {
		LeftBookMarkArray[LeftBookMarkIndex-1] = -1; 
	}
	else {
		for (i = arrayIndex ; i < LeftBookMarkIndex - 1 ; i++ ) {
			LeftBookMarkArray[i] = LeftBookMarkArray[i+1];
		}
	}
	LeftBookMarkIndex--;
}

function DeleteRightBookMark(arrayIndex) {
	RightNowBookSource = "";
	RightBookMarkArea.innerHTML = RightNextBookSource + RightNowBookSource;

	if (RightBookMarkIndex == 1) {
		RightBookMarkArray[RightBookMarkIndex-1] = -1; 
	}
	else {
		for (i = arrayIndex ; i < RightBookMarkIndex - 1 ; i++ ) {
			RightBookMarkArray[i] = RightBookMarkArray[i+1];
		}
	}
	RightBookMarkIndex--;
}

function MoveBookMark(pageNumber) {
	parent.frames['Frame_Hind'].GotoPage(pageNumber);
}

function HideBookMark() {
	HideLayer("LeftBookMarkButton");
//	HideLayer("RightBookMarkButton");
	HideLayer("LeftBookMarkArea");
	HideLayer("RightBookMarkArea");
}

function ShowBookMark() {
	if (parent.showBookMark) {
		ShowLayer("LeftBookMarkButton");
//		ShowLayer("RightBookMarkButton");
		ShowLayer("LeftBookMarkArea");
		ShowLayer("RightBookMarkArea");
	}
}

function HideBookMarkButton() {
	HideLayer("LeftBookMarkButton");
//	HideLayer("RightBookMarkButton");
}