
//名前空間用のオブジェクトを用意する
var CONTENTVIEW_EVENTS = {};

/* add memo click */
CONTENTVIEW_EVENTS.handleAddMemo = function(event) {
    
    if (ClientData.IsAddingMemo() == true) {
        ClientData.IsAddingMemo(false);
        CONTENTVIEW_GENERAL.isCopyMemo = false;

        /* draw memo */
        CONTENTVIEW.drawMemoOnScreen();
        
        //Start Function : No.4
        if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        	CONTENTVIEW.drawMemoOnScreen(1);
        }
        
        if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        	CONTENTVIEW.drawMemoOnScreen(2);
        }
        //End Function : No.4
        
        ////Start Function : No.4
        //if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        //	CONTENTVIEW.drawMemoOnScreen(1);
        //}
        //
        //if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        //	CONTENTVIEW.drawMemoOnScreen(2);
        //}
        ////End Function : No.4
        //change class
        $('#imgaddmemo').removeClass();
        $('#imgaddmemo').addClass('memoAdd');

    } 
    else {

        ClientData.IsDisplayMemo(true);
        ClientData.IsAddingMemo(true);
        CONTENTVIEW_GENERAL.isCopyMemo = false;

        /* draw memo */
        CONTENTVIEW.drawMemoOnScreen();
        //Start Function : No.4
        if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        	CONTENTVIEW.drawMemoOnScreen(1);
        }
        
        if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        	CONTENTVIEW.drawMemoOnScreen(2);
        }
        //End Function : No.4
        //change class
        $('#imgmemo').removeClass();
        $('#imgmemo').addClass('memoDisplay_hover');

        $('#imgaddmemo').removeClass();
        $('#imgaddmemo').addClass('memoAdd_hover');

        if (ClientData.memo_copyText()) {
            $("#overlay").show();
            $('#boxAddMemo').css('z-index', '101');
            $('#boxAddMemo').css('display', 'block');
            $('#boxAddMemo').draggable({ handle: "h1" });
            $("#boxAddMemo").offset({ left: event.pageX, top: event.pageY });
            $("#divAddMemo").show();
            $("#divAddMemo").offset({ left: event.pageX, top: (event.pageY + $('#bookmarkBoxHdMemo').height() - 2) });
        }
    }
};

/* Marking toolbar*/
CONTENTVIEW_EVENTS.imgmarking_click = function() {
    
    if (ClientData.IsDisplayMarking() == false) {
        ClientData.IsDisplayMarking(true);
        
        
        CONTENTVIEW.drawCanvas();
        
        //Start Function : No.4
        if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        	CONTENTVIEW.drawCanvas(1);
        }
        
        if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        	CONTENTVIEW.drawCanvas(2);
        }

        //End Function : No.4
        $("#dlgMarking").hide();

        // change class
        /*$('#imgmarking').removeClass();
        $('#imgmarking').addClass('marking_hover');*/
    } else {
        ClientData.IsDisplayMarking(false);
        ClientData.IsAddingMarking(false);
        $('#draw_canvas').css('display', 'none');

        /*// change class
        $('#imgmarking').removeClass();
        $('#imgmarking').addClass('marking');*/

        CONTENTVIEW.drawCanvas();
        
        //Start Function : No.4
        if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        	CONTENTVIEW.drawCanvas(1);
        }
        
        if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        	CONTENTVIEW.drawCanvas(2);
        }
    }
        //End Function : No.4

};


/* event for list bookmark: changePageNo */
CONTENTVIEW_EVENTS.clickBookmark = function() {
    
    var targetPageIndex = $(this).attr('id');
    
    if(targetPageIndex != CONTENTVIEW_GETDATA.getPageIndex()){
    	CONTENTVIEW.changePage(targetPageIndex);
    }
    
    /* close popup */
    // $('#divListBookmark').dialog("close");
    $("#overlay").hide();

    $('#listbookmark').removeClass();
    $('#listbookmark').addClass('bmList');

    $("#divListBookmark").hide();
    $('#boxBookMark').css('display', 'none');
};

/* event close list bookmark box */
CONTENTVIEW_EVENTS.closeBookmarkBox = function() {
    $("#divListBookmark").hide();
    CONTENTVIEW_GENERAL.isSendingData = false;
    $('#boxBookMark').css('display', 'none');
    CONTENTVIEW_GENERAL.isDisplayBookMarkList = false;

    /* unlock dialog overlay */
    $("#overlay").hide();

    //change class
    $('#listbookmark').removeClass();
    if (COMMON.isTouchDevice() == true) {
        $('#listbookmark').addClass('bmList_device');
    } else {
        $('#listbookmark').addClass('bmList');
    }

};


/*event click show dialog bookmark */
CONTENTVIEW_EVENTS.showListBookMark = function(e) {
    var array = [e.pageX, e.pageY];
    CONTENTVIEW_GENERAL.isDisplayBookMarkList = true;

    //change class
    $('#listbookmark').removeClass();
    $('#listbookmark').addClass('bmList_hover');

    /* display dialog overlay */
    $("#overlay").show();

    CONTENTVIEW_GETDATA.getBookmarklist(array);
};

/*event click show dialog index*/
CONTENTVIEW_EVENTS.showListPageIndex = function(e) {
	CONTENTVIEW_GENERAL.isDisplayListIndex = true;
    var array = [e.pageX, e.pageY];
    CONTENTVIEW_GETDATA.getPageIndexJson(array);

    //change class
    $('#listindex').removeClass();
    $('#listindex').addClass('index_hover');

    /* display dialog overlay */
    $("#overlay").show();
};

/* event close list bookmark box */
CONTENTVIEW_EVENTS.closeIndexBox = function() {
	CONTENTVIEW_GENERAL.isDisplayListIndex = false;
    $("#divListIndex").hide();
    $('#boxIndex').css('display', 'none');

    //change class
    $('#listindex').removeClass();
    if (COMMON.isTouchDevice() == true) {
        $('#listindex').addClass('index_device');
    } else {
        $('#listindex').addClass('index');
    }

    /* unlock dialog overlay */
    $("#overlay").hide();
};

/* event click on list index */
CONTENTVIEW_EVENTS.listIndex_Callback = function(selectedNode) {
    var node = new TreeNode();
    node = selectedNode;

    // Hide dialog index
    $("#divListIndex").dialog('close');

    CONTENTVIEW.changePage(node.Value - 1);
};

/*event click show copy text */
CONTENTVIEW_EVENTS.showCopyText = function(e) {
    /* display dialog overlay */
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
    	CONTENTVIEW.copyText();
    } else {
    	CONTENTVIEW_GENERAL.isDisplayCopyText = true;
        //change class
        $('#copytext').removeClass();
        $('#copytext').addClass('copy_hover');
        $("#overlay").show();
        var array = [e.pageX, e.pageY];
        var contentPage = CONTENTVIEW_GENERAL.dataWebContentPage.pages;
        CONTENTVIEW.handleCopyTextData(contentPage, array)
    }
};

/* event close copy text box */
CONTENTVIEW_EVENTS.closeCopyTextBox = function() {
	CONTENTVIEW_GENERAL.isDisplayCopyText = false;
    $("#divCopyText").hide();
    $('#boxCopyText').css('display', 'none');

    //change class
    $('#copytext').removeClass();
    if (COMMON.isTouchDevice() == true) {
        $('#copytext').addClass('copy_device');
    } else {
        $('#copytext').addClass('copy');
    }

    /* unlock dialog overlay */
    $("#overlay").hide();
};


/*event click show dialog search*/
CONTENTVIEW_EVENTS.showListSearchResult = function() {
    $('#txtSearch').keydown(function (e) {
        if (e.keyCode == 13) {
        	CONTENTVIEW.searchHandle();

            /* display dialog overlay */
            //$("#overlay").show();
            return false;
        }
    });
};

/* event close searching result box */
CONTENTVIEW_EVENTS.closeSearchingBox = function() {
	CONTENTVIEW_GENERAL.isSendingData = false;
    $("#divSearchResult").hide();
    $('#boxSearching').css('display', 'none');

    /* unlock dialog overlay */
    //$("#overlay").hide();
};


/* event for list search results */
CONTENTVIEW_EVENTS.clickSearchDetail = function() {
    // Hide dialog
    $("#divSearchResult").dialog('close');
    CONTENTVIEW.changePage($(this).attr('id'));
};

//Start: Function : No.4 - Editor : Long - Date : 08/09/2013 - Summary : 
/* event next page */
CONTENTVIEW_EVENTS.nextPage_click = function() {
    
    if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
    
    	var pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1;
    	
        COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, pageNo);
    
        CONTENTVIEW.playBGMOfContent();
        CONTENTVIEW.playBGMOfPage(pageNo); 
           
        CONTENTVIEW_GENERAL.isLoadingObject = true;
        CONTENTVIEW.cancelClick = true;
        
        CONTENTVIEW_GENERAL.disableAllControl();       
        $('#divImageLoading').css('display', 'block');
        
        var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
        CONTENTVIEW_EVENTS.createLockLayout(true);
        tran.flipNextPage();
        
    }
};


/* event prev page */
CONTENTVIEW_EVENTS.prevPage_click = function() {
    
    if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {
    
    	var pageNo = CONTENTVIEW_GETDATA.getPageIndex() - 1;
    	
        COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, pageNo);
    
        CONTENTVIEW.playBGMOfContent();
        CONTENTVIEW.playBGMOfPage(pageNo);
        
        CONTENTVIEW_GENERAL.isLoadingObject = true;   
        CONTENTVIEW.cancelClick = true;
        
        CONTENTVIEW_GENERAL.disableAllControl();
        $('#divImageLoading').css('display', 'block');
        
        var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
        CONTENTVIEW_EVENTS.createLockLayout(true);
        tran.flipPreviousPage();
        
    }
};
//End: Function : No.4 - Editor : Long - Date : 08/09/2013 - Summary : 
/* event first page */
CONTENTVIEW_EVENTS.firstPage_click = function() {
    if (CONTENTVIEW_GETDATA.getContent().pageIndex != 0) {
        
        if(CONTENTVIEW_GETDATA.getContent().pageIndex == 1){
        	CONTENTVIEW_EVENTS.prevPage_click();
        }
        else{
        
            //abe
            //alert("firstPage_click:" + CONTENTVIEW_GENERAL.contentID );
            COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, 0 );
        
            CONTENTVIEW.playBGMOfContent();
            CONTENTVIEW.playBGMOfPage(0);
    
            CONTENTVIEW_GENERAL.disableAllControl();
    
            $('#divImageLoading').css('display', 'block');
    
            // Clear canvas offscreen
            CONTENTVIEW_GENERAL.clearCanvas(document.getElementById("offscreen"));
    
            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
            	
            		AVWEB.avwGrabContentPageImage(ClientData.userInfo_accountPath(),
                    	 { contentId: CONTENTVIEW_GENERAL.contentID, sid: ClientData.userInfo_sid(), pageNo: 1 },
                     	function (data) {
                    		CONTENTVIEW_GENERAL.pageImages = data;
        					
                         	/* get page Objects */
                    	 	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
                         	CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);
        
                         	$('#divImageLoading').css('display', 'none');
                         
                         	CONTENTVIEW.checkDisableButtonZoom();
                         	var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
                         	tran.flipToPage(0);
        
                     	},
                     	function (xmlHttpRequest, txtStatus, errorThrown) {
                    		CONTENTVIEW.showErrorScreen();
                     	}
                     );
            	
            }
            //START : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
            else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
            	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
                CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);

                $('#divImageLoading').css('display', 'none');
                 //START TRB00097
                 //CONTENTVIEW.userScale = 1;
                 //CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
                 //END TRB00097
                CONTENTVIEW.checkDisableButtonZoom();
                var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
                tran.flipToPage(0);
            }
            //END : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
            
        }                
    }
};

/* event last page */
CONTENTVIEW_EVENTS.lastPage_click = function() {
    if (CONTENTVIEW_GETDATA.getContent().pageIndex != (CONTENTVIEW_GENERAL.totalPage - 1)) {
        
        if(CONTENTVIEW_GETDATA.getContent().pageIndex == CONTENTVIEW_GENERAL.totalPage - 2){
        	CONTENTVIEW_EVENTS.nextPage_click();
        }
        else{
        
            //abe
            //alert("lastPage_click:" + CONTENTVIEW_GENERAL.contentID );
            COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, CONTENTVIEW_GENERAL.totalPage - 1 );
        
            CONTENTVIEW.playBGMOfContent();
            CONTENTVIEW.playBGMOfPage(CONTENTVIEW_GENERAL.totalPage - 1);
    
            CONTENTVIEW_GENERAL.disableAllControl();
    
            $('#divImageLoading').css('display', 'block');
    
            // Clear canvas offscreen
            CONTENTVIEW_GENERAL.clearCanvas(document.getElementById("offscreen"));
    
            //CONTENTVIEW_GENERAL.pageImages = CONTENTVIEW_GETDATA.getURLPageImage("webContentPageImage") + "?contentId=" + CONTENTVIEW_GENERAL.contentID + "&sid=" + CONTENTVIEW.getSessionId() + "&pageNo=" + (CONTENTVIEW_GENERAL.totalPage - 1);
            
            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
            	
            		AVWEB.avwGrabContentPageImage(
            			ClientData.userInfo_accountPath(),
                    	{ contentId: CONTENTVIEW_GENERAL.contentID, sid: ClientData.userInfo_sid(), pageNo: CONTENTVIEW_GENERAL.totalPage },
                    	function (data) {
                    		CONTENTVIEW_GENERAL.pageImages = data;
                        	/* get page Objects */
                    		CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GENERAL.totalPage - 1);
                        	CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);
                        	$('#divImageLoading').css('display', 'none');
                         
                        	CONTENTVIEW.checkDisableButtonZoom();
                        	var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
                        	tran.flipToPage(CONTENTVIEW_GENERAL.totalPage - 1);
        
                     	},
                     	function (xmlHttpRequest, txtStatus, errorThrown) {
                    		CONTENTVIEW.showErrorScreen();
                     	}
                    );
            	
            }
            //START : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
            else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
            	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GENERAL.totalPage - 1);
                 CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);

                 $('#divImageLoading').css('display', 'none');
                 
                 CONTENTVIEW.checkDisableButtonZoom();
                 var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
                 tran.flipToPage(CONTENTVIEW_GENERAL.totalPage - 1);
            }
            //END : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process

        }        
    }

};

CONTENTVIEW_EVENTS.createLockLayout = function(opt){
         
    if(opt == true){       
        if(!$('#locking').size()){
            var $html = $('<div id="locking" style="z-index: 100; position: absolute; height: 100%; width: 100%; background: white; opacity: 0 "></div>');        
              
            $('#wrapper').append($html);
            $html.show();
            
            $('#locking').live('click', function(event){ event.preventDefault(); });
        }
        else{
            $('#locking').show();
        }
               
    }
    else{
       //$('body').append($html);
       if($('#locking').size()){
            $('#locking').hide();
            $('#locking').remove();    
       }   
    }          
};

//START TRB00049 - Editor: Long - Date: 09/26/2013 - Summary : Add short key alt 
/* handle keydown */
$(document).keydown(function (e) {
    /* set fag true when click ctrl */
    if (e.ctrlKey) {
    	CONTENTVIEW_GENERAL.ctrlMode = true;
    }
    
    if(e.altKey){
    	CONTENTVIEW_EVENTS.altMode = true;
    }

    /* set hot key */
    if (CONTENTVIEW_GENERAL.ctrlMode == true && CONTENTVIEW_EVENTS.altMode == false) {
        if (ClientData.IsAddingMarking() == true || CONTENTVIEW_GENERAL.isLoadingObject == true) {
            /* do nothing*/
        } else {
            switch (e.keyCode) {
                /* move page */ 
                case COMMON.ShortKeys.MovePrevious: /* move prev */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                        if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {
                        	CONTENTVIEW_EVENTS.prevPage_click();
                        }
                    }               
                    break;
                case COMMON.ShortKeys.MoveNext: /* move next */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                        if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
                        	CONTENTVIEW_EVENTS.nextPage_click();
                        }
                    }

                    break;

                /* zoom */ 
                case COMMON.ShortKeys.ZoomIn: /* zoomIn */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                        || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    	CONTENTVIEW.zoomIn();
                    }
                    
                    break;
                case COMMON.ShortKeys.ZoomOut: /* zoomOut */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                        || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    	CONTENTVIEW.zoomOut();
                    }
                    
                    break;
                case COMMON.ShortKeys.ZoomFit: /* screenFit*/
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                        || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    	CONTENTVIEW.screenFit();
                    }                   
                    break;

                /* marking && toolbar */ 
                case COMMON.ShortKeys.ShowHideToolbar: /* handle toolbar */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                        || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    	CONTENTVIEW.handleDisplayToolbar();
                    }
                    else{
                        if(CONTENTVIEW.isZoomingContent){
                        	CONTENTVIEW.originalScreenForNotPdfType();
                        }
                        else{
                        	CONTENTVIEW.fullScreenForNotPdfType();
                        }
                    }
                    
                    break;
                case COMMON.ShortKeys.ShowHideMarking: /* hide marking */
                   if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                            || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                	   CONTENTVIEW_EVENTS.imgmarking_click();
                    }
                    
                    break;
            }
        }
    }
    
    if(CONTENTVIEW_EVENTS.altMode == true && CONTENTVIEW_GENERAL.ctrlMode == false){
        if (ClientData.IsAddingMarking() == true || CONTENTVIEW_GENERAL.isLoadingObject == true) {
            /* do nothing*/
        } 
        else {
            switch (e.keyCode) {
                /* zoom */ 
                case COMMON.ShortKeys.ZoomInAlt: /* zoomIn */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                        || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    	CONTENTVIEW.zoomIn();
                    }                    
                    break;
                case COMMON.ShortKeys.ZoomOutAlt: /* zoomOut */
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                        || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    	CONTENTVIEW.zoomOut();
                    }                   
                    break;
                case COMMON.ShortKeys.ZoominAlt_Firefox: /* zoomIn */
                    if(CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox'){
                        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                            || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                        	CONTENTVIEW.zoomIn();
                        } 
                    }                   
                    break;
                case COMMON.ShortKeys.ZoomOutAlt_Firefox: /* zoomOut */
                    if(CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox'){
                        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image
                            || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                        	CONTENTVIEW.zoomOut();
                        }       
                    }            
                    break;
                
            }
        }
    }
});

/* handle keydown */
$(document).keyup(function (e) {
	CONTENTVIEW_GENERAL.ctrlMode = false;
    CONTENTVIEW_EVENTS.altMode = false;
});
//END TRB00049 - Editor: Long - Date: 09/26/2013 - Summary : Add short key alt 

//START TRB - Editor : Long -Date : 10/01/2013 - Summary : Re Assign sid for image 3d
CONTENTVIEW_EVENTS.update3DImagesArr = function(){
    
    if(CONTENTVIEW_GENERAL._object3DImageArr.length > 0){
        var temp3DArr = [];
        CONTENTVIEW_GENERAL._object3DImageArr = []; //ここで初期化？
        for(var i = 0; i < CONTENTVIEW_GENERAL._object3DImageArr; i++){
            var object3D = CONTENTVIEW_GENERAL._object3DImageArr[i];
            var temp3dview = object3d["3dview"];
            var tempCurrX = object3d["_currFrameX"];
            var tempCurrY = object3d["_currFrameY"];
            var tempLastSelectedFrame = object3d["lastSelectedFrame"];
            var tempActionType = object3d["actionType"];
            var tempHeight = object3d["height"];
            var tempHorizonCnt = object3d["horizonCount"];
            var tempId = object3d["id"];
            var tempInitImage = object3d["initImage"];
            var tempMediaType = object3d["mediaType"];
            var tempVerticalCnt = object3d["verticalCount"];
            var tempVisible = object3d["visible"];
            var tempWidth = object3d["width"];
            var tempX = object3d["x"];
            var tempY = object3d["y"];
            
            tempInitImage = AVWEB.getURL("webResourceDownload") + "&sid=" + CONTENTVIEW.getSessionId() + "&resourceId=" + COMMON.getUrlParam('resourceId',tempInitImage);
            for(var j = 0; j< temp3dview.length; j++){
                var url = temp3dview[j];
                var id = COMMON.getUrlParam('resourceId',url);
                temp3dview[j] = AVWEB.getURL("webResourceDownload") + "&sid=" + CONTENTVIEW.getSessionId() + "&resourceId=" + id;
            }
            
            var arr3D = [];       
            arr3D["3dview"] = temp3dview;  
            arr3D["_currFrameX"] = tempCurrX;  
            arr3D["_currFrameY"] = tempCurrY;  
            arr3D["lastSelectedFrame"] = tempLastSelectedFrame;
            arr3D["actionType"] = tempActionType;  
            arr3D["height"] = tempHeight;  
            arr3D["horizonCount"] = tempHorizonCnt;  
            arr3D["id"] = tempId;  
            arr3D["initImage"] = tempInitImage;  
            arr3D["mediaType"] = tempMediaType;  
            arr3D["verticalCount"] = tempVerticalCnt;  
            arr3D["visible"] = tempVisible;
            arr3D["width"] = tempWidth;  
            arr3D["x"] = tempX;  
            arr3D["y"] = tempY;  
            
            temp3DArr.push(arr3D);
        }
        
        CONTENTVIEW_GENERAL._object3DImageArr = temp3DArr;
    }    
};

//END TRB - Editor : Long -Date : 10/01/2013 - Summary : Re Assign sid for image 3d
CONTENTVIEW_EVENTS.onUnlock = function() {
	CONTENTVIEW.removeObject();
	CONTENTVIEW_EVENTS.update3DImagesArr();
	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
    /* handle play BGM of content jump */
    for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
        if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                $('#play_audio_1').attr('src', CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile);
                //document.getElementById("play_audio_1").load();           
                document.getElementById("play_audio_1").play();
                CONTENTVIEW_GENERAL.isPlayBGMUnlock = true;
            } else {
            	CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile, CONTENTVIEW_GENERAL.pageObjects[nIndex].playType);
            }
        }
    }
    
    //Start Function: No.4 - Editor : Long - Date : 08/12/2013 - Summary : ReDraw canvas when has new sid
    CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex());
    CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects).setUpPage(CONTENTVIEW_GETDATA.getPageIndex());
    //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
    CONTENTVIEW_CREATEOBJECT.createPageBGM();
    //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
    if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
    	CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex() + 1);
        CONTENTVIEW_GETDATA.renderNextPage();
    }
  
    if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
    	CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex() - 1);
        CONTENTVIEW_GETDATA.renderPrevPage();
    }  
    
    //End Function: No.4 - Editor : Long - Date : 08/12/2013 - Summary : ReDraw canvas when has new sid
};

CONTENTVIEW_EVENTS.onClick_CanvasMain = function(event) {
	
    event.preventDefault(); 
    
    if(CONTENTVIEW_GENERAL.isLoadingObject){       
        return;
    }
    else{
    	CONTENTVIEW.cancelClick = false;
    }    
    
    if (!CONTENTVIEW.cancelClick) {
        
        //change coordinates 
        var imagePt = CONTENTVIEW.screenToImage(event.pageX, event.pageY);
        var canvasWidth = $('#offscreen').width();
        CONTENTVIEW_GENERAL.posXPopupMemo = event.pageX;
        CONTENTVIEW_GENERAL.posYPopupMemo = event.pageY;

        if ((event.pageX - CONTENTVIEW.marginX) >= CONTENTVIEW.destRect.left && (event.pageX - CONTENTVIEW.marginX) <= CONTENTVIEW.destRect.right) {
            /* click add memo */
            if (ClientData.IsAddingMemo() == true) {
                
                if (!ClientData.memo_copyText()) {
                	CONTENTVIEW_MEMO.AddMemo(CONTENTVIEW_GENERAL.contentID, CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()), $('#divDialogMemo'), event.pageX, event.pageY, function () {
                        //set flag change memo 
                        ClientData.isChangedMemo(true);
                        ClientData.IsAddingMemo(false);

                        /* refresh draw memo */
                        CONTENTVIEW.drawMemoOnScreen();

                        //change image
                        $('#imgaddmemo').removeClass();
                        $('#imgaddmemo').addClass('memoAdd');
                    });
                } else {
                    if (CONTENTVIEW_GENERAL.typeSelectMemo == 1) { /* add new */
                    	CONTENTVIEW_MEMO.AddMemo(CONTENTVIEW_GENERAL.contentID, CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()), $('#divDialogMemo'), CONTENTVIEW_GENERAL.posXPopupMemo, CONTENTVIEW_GENERAL.posYPopupMemo, function () {
                            //set flag change memo 
                            ClientData.isChangedMemo(true);
                            ClientData.IsAddingMemo(false);

                            /* refresh draw memo */
                            CONTENTVIEW.drawMemoOnScreen();

                            //change image	             							
                            $('#imgaddmemo').removeClass();
                            $('#imgaddmemo').addClass('memoAdd');
                        });

                    } else if (CONTENTVIEW_GENERAL.typeSelectMemo == 2) { /* copy */
                    	CONTENTVIEW_MEMO.CopyMemo(ClientData.memo_copyText(), CONTENTVIEW_GENERAL.contentID, CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()), $('#divDialogMemo'), CONTENTVIEW_GENERAL.posXPopupMemo, CONTENTVIEW_GENERAL.posYPopupMemo, function () {
                            //set flag change memo 
                            ClientData.isChangedMemo(true);
                            ClientData.IsAddingMemo(false);

                            /* refresh draw memo */
                            CONTENTVIEW.drawMemoOnScreen();

                            //change image	             							
                            $('#imgaddmemo').removeClass();
                            $('#imgaddmemo').addClass('memoAdd');
                        });
                    }
                }

            } 
            else {

                var isClickMemo = false;

                if (CONTENTVIEW_GENERAL.isOpenPopUpText == true) {
                	CONTENTVIEW_GENERAL.isOpenPopUpText = false;
                	CONTENTVIEW_POPUPTEXT.ClosePopupText();
                }

                if (CONTENTVIEW_GENERAL.isOpenPopUpMemo == true) {
                	CONTENTVIEW_GENERAL.isOpenPopUpMemo = false;
                    $("#pop_up_memo").hide();
                }

                /* click memo edit */
                if (ClientData.IsDisplayMemo() == true) {
                	CONTENTVIEW_GETDATA.getAllMemoOfPage();
                    /* check exist object memo in mouse position */
                    for (var nIndex = 0; nIndex < CONTENTVIEW_CREATEOBJECT.memoObjects.length; nIndex++) {
                        var hitPageObjMemo = CONTENTVIEW_CREATEOBJECT.memoObjects[nIndex];
                        if (hitPageObjMemo.hitTest(imagePt.x, imagePt.y)) {
                            //console.log("PageObject Hit!! Id: " + hitPageObjMemo.id);
                            //hitPageObjMemo.action();

                            /* save object memo */
                        	CONTENTVIEW_GENERAL.objEditMemo = hitPageObjMemo;
                            var posMemoX = event.pageX;
                            var posMemoY = event.pageY;

                            if (imagePt.y > CONTENTVIEW_GENERAL.heightEachPage - $("#pop_up_memo").height()) {
                                posMemoY = posMemoY - $("#pop_up_memo").height();

                            }

                            if (imagePt.x > CONTENTVIEW_GENERAL.widthEachPage - $("#pop_up_memo").width()) {
                                posMemoX = posMemoX - $("#pop_up_memo").width();
                            }

                            /*display pop-up-memo */
                            $("#pop_up_memo").css('top', posMemoY).css('left', posMemoX);
                            $("#pop_up_memo").show();

                            /*set true for flag click memo */
                            isClickMemo = true;
                            CONTENTVIEW_GENERAL.isOpenPopUpMemo = true;

                        }
                    }
                }

                /* click pageObject */
                if (isClickMemo == false) {
                    var isClickLinkList = false;

                    /* check exist object in mouse position */
                    var hitPageObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
                                                                               
                    if (hitPageObj) { 
                        if(!CONTENTVIEW.is3DObject(hitPageObj)){
                            hitPageObj.action();    
                        }
                        else{
                            //event.preventDefault();
                        }                                                                  			                     
                    }
                    else {

                        /* check click link list */
                        for (var nIndex = 0; nIndex < CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects.length; nIndex++) {
                            var hitPageObjLinkList = CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects[nIndex];
                            if (hitPageObjLinkList.hitTest(imagePt.x, imagePt.y)) {
                                //console.log("PageObject Hit!! Id: " + hitPageObjLinkList.id);
                                if(hitPageObjLinkList.pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())){
                                    hitPageObjLinkList.action();

                                    /*set true for flag click memo */
                                    isClickLinkList = true;
                                }                               
                            }
                        }

                        if (isClickLinkList == false && ClientData.IsAddingMarking() == false) {
                            /* area next and prev page */
                            var cwMain = $('#main').width();
                            if (event.pageX > 0 && event.pageX < 300) {
                                if(!CONTENTVIEW_EVENTS.isPreventClick){
                                    //START TRB00097
                                    if(CONTENTVIEW.userScale == 1){
                                    	CONTENTVIEW_EVENTS.prevPage_click(); 
                                    }
                                    //END TRB00097
                                }
                                else{
                                	CONTENTVIEW_EVENTS.isPreventClick = false;
                                }                                                                  
                            } else if (event.pageX > (cwMain - 300) && event.pageX < cwMain) {
                                if(!CONTENTVIEW_EVENTS.isPreventClick){
                                    //START TRB00097
                                    if(CONTENTVIEW.userScale == 1){
                                    	CONTENTVIEW_EVENTS.nextPage_click(); 
                                    } 
                                    //END TRB00097                                  
                                }
                                else{
                                	CONTENTVIEW_EVENTS.isPreventClick = false;
                                }       
                            }
                            
                            if(!CONTENTVIEW_EVENTS.isPreventClick){
                            	//その他のエリア
                            	//console.log("click!!");
                            }
                            
                        }
                    }
                }
            }
        } 
        else {          
            if (ClientData.IsAddingMarking() == false && CONTENTVIEW_GENERAL.isCopyMemo == false) {
                var cwMain = $('#main').width();
                //Start : TRB00005, TRB00006 - Editor : Long - Date: 08/28/2013 - Summary : Prevent click when transit
                if (event.pageX > 0 && event.pageX < 300) {
                    if(!CONTENTVIEW_EVENTS.isPreventClick){                              
                    	CONTENTVIEW_EVENTS.prevPage_click();
                        //CONTENTVIEW_EVENTS.isPreventClick = true;                        
                    }
                    else{
                    	CONTENTVIEW_EVENTS.isPreventClick = false;
                    }
                    
                                                         
                } else if (event.pageX > (cwMain - 300) && event.pageX < cwMain) { 
                    if(!CONTENTVIEW_EVENTS.isPreventClick){      
                    	CONTENTVIEW_EVENTS.nextPage_click();
                    }
                    else{
                    	CONTENTVIEW_EVENTS.isPreventClick = false;
                    }
                }
                //End : TRB00005, TRB00006 - Editor : Long - Date: 08/28/2013 - Summary : Prevent click when transit
            }          
        }
    }
    CONTENTVIEW.cancelClick = false;
};

//#12408 ホイール対応
CONTENTVIEW_EVENTS.mouseWheel_CanvasMain = function(event, detail) {

    //console.log("mouseWheel:" + detail);
    //event.preventDefault(); 

    if(CONTENTVIEW_EVENTS._isTouching){
       return;
    }

    if(ClientData.IsAddingMarking() == true){
        return;  
    }
    
    if(CONTENTVIEW_GENERAL.isLoadingObject){
    	CONTENTVIEW.moveFlag = false;    
    }

    /* base image move when userScale over 1 */
    if ( CONTENTVIEW.userScale != 1) {
        //$('#main').css('cursor', 'pointer');

        //var sx = 1 / CONTENTVIEW.userScale;
        var sy = 1 / CONTENTVIEW.userScale;

        // calc scaling moving distance
        //CONTENTVIEW.moveX = Math.round(detail * sx);
        CONTENTVIEW.moveY = Math.round(detail * sy * 20); //20は感覚的な移動量の補正

        // redraw
        CONTENTVIEW.flip();

        CONTENTVIEW.zoomVideo();

        CONTENTVIEW.closeDialogPopUpText();
    }

};

CONTENTVIEW_EVENTS.mouseMove_CanvasMain = function(event) {
    
    event.preventDefault(); 
    
    //Start Function : No.20 - Editor : Long
    if(CONTENTVIEW_EVENTS._isTouching){
       //CONTENTVIEW_EVENTS._isTouching = false;
       return;
    }
    
    if(ClientData.IsAddingMarking() == true){
        return;  
    }
    
    if(CONTENTVIEW_GENERAL.isLoadingObject){
    	CONTENTVIEW.moveFlag = false;    
    }

    //End Function : No.20 - Editor : Long
    //event.preventDefault(); 
    
    /* base image move when userScale over 1 */
    if (CONTENTVIEW.moveFlag && CONTENTVIEW.userScale != 1) {
        $('#main').css('cursor', 'pointer');
        //START TRB00097
        CONTENTVIEW.cancelClick = true;
        //END TRB00097
        var mx;
        var my;
        // calc mouse moving distance
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
            mx = event.pageX - CONTENTVIEW_GENERAL.px;
            my = event.pageY - CONTENTVIEW_GENERAL.py;
        } else {
            mx = event.targetTouches[0].pageX - CONTENTVIEW_GENERAL.px;
            my = event.targetTouches[0].pageY - CONTENTVIEW_GENERAL.py;
        }

        var sx = 1 / CONTENTVIEW.userScale;
        var sy = 1 / CONTENTVIEW.userScale;

        // calc scaling moving distance
        CONTENTVIEW.moveX = Math.round(-mx * sx);
        CONTENTVIEW.moveY = Math.round(-my * sy);


        // store current mouse point
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
        	CONTENTVIEW_GENERAL.px = event.pageX;
        	CONTENTVIEW_GENERAL.py = event.pageY;
        } else {
            //event.preventDefault();
        	CONTENTVIEW_GENERAL.px = event.targetTouches[0].pageX;
        	CONTENTVIEW_GENERAL.py = event.targetTouches[0].pageY;
        }

        // redraw
        CONTENTVIEW.flip();

        CONTENTVIEW.zoomVideo();

        CONTENTVIEW.closeDialogPopUpText();
    }
    //Start Function : No.20
    else if(CONTENTVIEW.moveFlag && CONTENTVIEW.userScale == 1){

        //Prevent 3d animate when moving
    	CONTENTVIEW_EVENTS.isPageTransition = true;
        
        //Start : TRB00005, TRB00006 - Editor : Long - Date: 08/28/2013 - Summary : Prevent click when transit
    	CONTENTVIEW_EVENTS.isPreventClick = true;
        //End : TRB00005, TRB00006 - Editor : Long - Date: 08/28/2013 - Summary : Prevent click when transit
        
        var x = event.pageX;
        var y = event.pageY;
        var deltaX = x - CONTENTVIEW_GENERAL.px;
        var deltaY= y - CONTENTVIEW_GENERAL.py;
        CONTENTVIEW_GENERAL.px = x;
        CONTENTVIEW_GENERAL.py = y;
        currPos = {x:event.pageX,y:event.pageY};
        // pevious page not exist -> do not move
        
        if(!CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
            
            if(currPos.x >= CONTENTVIEW_GENERAL._clickFirstPos.x){
                return;
            }              
        }
        
        // next page not exist -> do not move
        if(!CONTENTVIEW_GETDATA.getContent().hasNextPage()){
            if(currPos.x <= CONTENTVIEW_GENERAL._clickFirstPos.x){
              return;  
            }              
        }
        
        //examinate direction 
        if(CONTENTVIEW_GENERAL._moveNum==0 &&  deltaX < 0){
        	CONTENTVIEW_GENERAL._moveNum = 2; // go from right to left => next page
        }
        if(CONTENTVIEW_GENERAL._moveNum==2 &&  deltaX > 0){
        	CONTENTVIEW_GENERAL._moveNum = 1; // go from right to left and back to right => no move
        }
        if(CONTENTVIEW_GENERAL._moveNum==1 &&  deltaX < 0){
        	CONTENTVIEW_GENERAL._moveNum = 2; // go from right to left + back to right + go to left  => next page
        }

        if(CONTENTVIEW_GENERAL._moveNum==0 &&  deltaX > 0){
        	CONTENTVIEW_GENERAL._moveNum = -2; // go from  left to right=> priveous page
        }
        if(CONTENTVIEW_GENERAL._moveNum==-2 &&  deltaX < 0){
        	CONTENTVIEW_GENERAL._moveNum = -1; // go from  left to right and back to left => no move
        }
        if(CONTENTVIEW_GENERAL._moveNum==0 &&  deltaX > 0){
        	CONTENTVIEW_GENERAL._moveNum = -2; // go from  left to right + back to left + go to right=> priveous page
        }
        
        if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
            var left = $('#canvasWrapper').css('left').replace("px","");
            left  =  parseInt(left) + deltaX;
    
            $('#canvasWrapper').css('left', left + "px");
        }        
    }
    
    if(CONTENTVIEW.moveFlag == false && CONTENTVIEW_EVENTS._3dAnimate == true){  
        var imagePt = CONTENTVIEW.screenToImage(event.pageX, event.pageY);
        var hitObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
        if(hitObj){
           if(CONTENTVIEW.is3DObject(hitObj)){
        	   CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchMove_MouseMove;            
                hitObj.action(imagePt);  
           }                 
        }
        else{
        	CONTENTVIEW_EVENTS._3dAnimate = false;
        }      
    }
       
    //End Function : No.20
    var cwMain = $('#main').width();
    var chMain = $('#main').height();
    /* handle image prev on canvas */
    if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {
        $('#button_pre_canvas').mousemove(function () {
            if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {

                $(this).css('opacity', '1');
            } else {
                $(this).css('opacity', '0');
            }
        });

        if (event.pageX > 0 && event.pageX < 300) {
            $('#button_pre_canvas').css('opacity', '0.25');
        } else {
            $('#button_pre_canvas').css('opacity', '0');
        }
    } 
    else {
        $('#button_pre_canvas').css('opacity', '0');
    }

    /* handle image next on canvas */
    if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
        $('#button_next_canvas').mousemove(function () {
            if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
                $(this).css('opacity', '1');
            } else {
                $(this).css('opacity', '0');
            }
        });

        if (event.pageX > (cwMain - 300) && event.pageX < cwMain) {
            $('#button_next_canvas').css('opacity', '0.25');
        } else {
            $('#button_next_canvas').css('opacity', '0');
        }
    } else {
        $('#button_next_canvas').css('opacity', '0');
    }
    
};

CONTENTVIEW_EVENTS.mouseDown_CanvasMain = function(event) {

    event.preventDefault();

    //Start Function : No.20 - Editor : Long - Date: 08/17/2013 - Summary : 
    if(CONTENTVIEW_EVENTS._isTouching){
    //   //CONTENTVIEW_EVENTS._isTouching = false;
       return; 
    }
    
    if(ClientData.IsAddingMarking() == true){
        return;  
    }
    
    //End Function : No.20 - Editor : Long - Date: 08/17/2013 - Summary : 
  
    if(!CONTENTVIEW_GENERAL.isLoadingObject){
    	CONTENTVIEW.moveFlag = true;
    }
    else{
    	CONTENTVIEW.moveFlag = false;
    }
    
    //event.preventDefault(); 
       
    $('#main').css('cursor', 'default');
       
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
    	CONTENTVIEW_GENERAL.px = event.pageX;
    	CONTENTVIEW_GENERAL.py = event.pageY;      
                
        //Start Function : No.20
    	CONTENTVIEW_GENERAL._clickFirstPos = {x:event.pageX, y: event.pageY};
    	CONTENTVIEW_GENERAL._clickLastPos = {x:event.pageX, y: event.pageY};
        
        CONTENTVIEW_GENERAL._moveNum = 0; 
        
        if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
            $('#mainPre').css("display",'block');
            $('#mainNext').css("display",'block');
        }             
       
         //End Function : No.20                    
        
        //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary : 
        var imagePt = CONTENTVIEW.screenToImage(CONTENTVIEW_GENERAL.px, CONTENTVIEW_GENERAL.py);
        var hitPageObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
             
        CONTENTVIEW.moveFlag = true;
        CONTENTVIEW_EVENTS._3dAnimate = false;
        
        if(CONTENTVIEW.is3DObject(hitPageObj)){            
            
            //START TRB00090 - Editor: Long - Date : 09/26/2013 - Summary : remove time to detect 3d animate       
            if(!CONTENTVIEW_EVENTS.isPageTransition){
            	CONTENTVIEW_EVENTS._3dAnimate = true;
            	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchStart_MouseDown;
            	CONTENTVIEW_3D._curr3dObject = hitPageObj;
                   hitPageObj.action(imagePt); 
                   CONTENTVIEW.moveFlag = false;                                   
            }
            else{
            	CONTENTVIEW_EVENTS._3dAnimate = false;
                CONTENTVIEW.moveFlag = true;  
            }  
            //END TRB00090 - Editor: Long - Date : 09/26/2013 - Summary : remove time to detect 3d animate                                 
        }                                                   
        else{
        	CONTENTVIEW_EVENTS._3dAnimate = false;
        }
                                                                                                                                                                   
        //End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary:    
    }
    else {
        //event.preventDefault();
    	CONTENTVIEW_GENERAL.px = event.targetTouches[0].pageX;
    	CONTENTVIEW_GENERAL.py = event.targetTouches[0].pageY;               
    }
};

CONTENTVIEW_EVENTS.mouseUp_CanvasMain = function(event) {

    event.preventDefault();
    
    if(ClientData.IsAddingMarking() == true){
        return;  
    }
    
    if(CONTENTVIEW.moveFlag) {
    	CONTENTVIEW.moveFlag = false;
        $('#main').css('cursor', 'default');
        // navigate page
        if(CONTENTVIEW_GENERAL._moveNum == 2){
        	CONTENTVIEW_EVENTS.nextPage_click();
        }else if (CONTENTVIEW_GENERAL._moveNum == -2){
        	CONTENTVIEW_EVENTS.prevPage_click();
        }else {
        	CONTENTVIEW_GETDATA.correctCanvasPosition();
        }
        
        //Check if mouse move is fired to prevent click next/ prev page
        //isInMouseMove = false;
        
    }
    
    if(CONTENTVIEW_EVENTS._3dAnimate == true){
    	CONTENTVIEW_EVENTS._3dAnimate = false;

    	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchEnd_MouseUp;

    	CONTENTVIEW_3D._curr3dObject.action(); 
    }
    
    if(CONTENTVIEW_EVENTS.isPageTransition){
    	CONTENTVIEW_EVENTS.isPageTransition = false;
    }
    
    //End Function : No.20
};

CONTENTVIEW_EVENTS.imgBack_click = function() {
    /* set end log */
    COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
    COMMON.RegisterLog();

    //window.onbeforeunload = null;

    //画面クリア
    CONTENTVIEW_INITOBJECT.clearViewerComponent();
    
    if (ClientData.JumpQueue()) {
    	
        var oldDataBack = ClientData.JumpQueue();
        if (oldDataBack.length > 0) {
        	//AVWEB.avwScreenMove(COMMON.ScreenIds.ContentView);
        	CONTENTVIEW.screenMove();
            ClientData.IsJumpBack(true);
        } else {
            /*check back */
            //if (ClientData.BookmarkScreen()) {
            //	AVWEB.avwScreenMove(ClientData.BookmarkScreen());
            //} else {
            //    window.history.back();
            //}
            
        	//元の画面に戻って画面復帰
        	CONTENTVIEW.screenBack();
        }
    } else {
        /*check back */
        //if (ClientData.BookmarkScreen()) {
        //	AVWEB.avwScreenMove(ClientData.BookmarkScreen());
        //} else {
        //   window.history.back();
        //}
    	
    	//元の画面に戻って画面復帰
    	CONTENTVIEW.screenBack();
    	
    }

};

CONTENTVIEW_EVENTS.imgHome_click = function(e) {
    e.preventDefault();

    /* set end log */
    COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
    COMMON.RegisterLog();

    //window.location.href = COMMON.ScreenIds.Home;
    AVWEB.avwScreenMove(COMMON.ScreenIds.Home);
};

CONTENTVIEW_EVENTS.closePopUpCopyMemo = function() {
    $('#boxAddMemo').hide();
    //ClientData.memo_copyText(null);
    ClientData.IsAddingMemo(false);

    /* unlock dialog overlay */
    $("#overlay").hide();

    //change class
    $('#imgaddmemo').removeClass();
    $('#imgaddmemo').addClass('memoAdd');
};

CONTENTVIEW_EVENTS.click_liAddMemo = function(event) {
	CONTENTVIEW_GENERAL.typeSelectMemo = 1;

    $('#boxAddMemo').hide();
    /* unlock dialog overlay */
    $("#overlay").hide();

    //ClientData.memo_copyText(null);
    //ClientData.IsAddingMemo(false); 
};

CONTENTVIEW_EVENTS.click_liCopyMemo = function() {
	CONTENTVIEW_GENERAL.typeSelectMemo = 2;

    $('#boxAddMemo').hide();
    /* unlock dialog overlay */
    $("#overlay").hide();

    //ClientData.memo_copyText(null);  
    //ClientData.IsAddingMemo(false); 
};

CONTENTVIEW_EVENTS.click_liDeleteMemo = function() {
    $('#boxAddMemo').hide();
    ClientData.memo_copyText(null);
    ClientData.IsAddingMemo(false);

    /* unlock dialog overlay */
    $("#overlay").hide();

    //change class
    $('#imgaddmemo').removeClass();
    $('#imgaddmemo').addClass('memoAdd');
};

//Start Funcion : No.20 - Editor : Long - Date : 08/13/2013 - Summary : Win 8 touch handle

/*
 * reset navi action as point session increase
 */
CONTENTVIEW_EVENTS.resetNaviAction = function(){
	CONTENTVIEW_GENERAL._isPageNaviTouch = true;
    CONTENTVIEW_GENERAL._moveNum = 0;       
    CONTENTVIEW_GENERAL.touchStartedTime = new Date();
    $('#mainPre').css("display",'none');
    $('#mainNext').css("display",'none');
    CONTENTVIEW_GENERAL._touchFirstPos = null;
    CONTENTVIEW_GENERAL._touchLastPos=null;
    //console.log("================correctCanvasPosition==============="); 
    CONTENTVIEW_GETDATA.correctCanvasPosition();

};

CONTENTVIEW_EVENTS.onTouchstart = function(evt){
	
    if(ClientData.IsAddingMarking() == true){
        return;  
    } 
     
    //evt.preventDefault();
	//$('#debug').html("CONTENTVIEW_EVENTS.onTouchstart");
	//CONTENTVIEW_STREAMING.handleDisplayToolbar();
    
    var bContinue = true;

    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
    //    evt.preventDefault();
    //}
    if( CONTENTVIEW_GENERAL._bTouchDeviceEnabled ){
        evt.preventDefault();
        evt.stopPropagation();
    }
    
    if(CONTENTVIEW_GENERAL.isLoadingObject){
        bContinue = false;
    }          
    
    if( evt.pointerType != null ){
        //evt.pointerType は IE以外 undef
        switch (evt.pointerType) {
            case evt.MSPOINTER_TYPE_TOUCH:
            	CONTENTVIEW_EVENTS._isTouching = true;
                break;          
            case evt.MSPOINTER_TYPE_PEN:
                bContinue = false;
                break;
            case evt.MSPOINTER_TYPE_MOUSE:
            	CONTENTVIEW_EVENTS._isTouching = false;
                bContinue = false;
                break;
        }
    } else {
    	CONTENTVIEW_EVENTS._isTouching = true;
    }
    
    if(!bContinue){
        return;  
    }

    CONTENTVIEW_GENERAL._isPageNaviTouch = false;
    CONTENTVIEW_GENERAL._isPageZoomTouch = false;
    
    var touch1 = null;
    var touch2 = null;      
    CONTENTVIEW_GENERAL._touchLastPos = null;
    CONTENTVIEW_GENERAL._touchFirstPos = null;
    
    if(CONTENTVIEW_GENERAL._bWin8TouchEnabled){
    
    	CONTENTVIEW_GENERAL._bufferPoints = [];
        if(CONTENTVIEW_GENERAL._startPoints.length == 0){
            // start navi page case
            touch1 = {clientX: evt.clientX, clientY: evt.clientY,pointerId: evt.pointerId};
            CONTENTVIEW_GENERAL._startPoints.push(touch1);
            if(CONTENTVIEW.userScale != 1){
            	CONTENTVIEW_GENERAL.px = evt.pageX;
            	CONTENTVIEW_GENERAL.py = evt.pageY;
            }
            else{
            	CONTENTVIEW_EVENTS.touchDownFirstPosX = evt.clientX;
            	CONTENTVIEW_EVENTS.touchDownFirstPosY = evt.clientY;
                
                //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary : 
                var imagePt = CONTENTVIEW.screenToImage(evt.pageX, evt.pageY);
                var hitPageObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
                CONTENTVIEW_EVENTS._3dAnimate = false;
               
                if (hitPageObj) {
                     //START TRB00090 - Editor: Long - Date : 09/26/2013 - Summary : remove time to detect 3d animate                               
                    if(CONTENTVIEW.is3DObject(hitPageObj)){                                    
                        if(CONTENTVIEW_EVENTS.isPageTransition){                           
                        	CONTENTVIEW_EVENTS._3dAnimate = false;
                        }
                        else{
                        	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchStart_MouseDown;
                        	CONTENTVIEW_3D._curr3dObject = hitPageObj;
                            hitPageObj.action(imagePt);
                            CONTENTVIEW_EVENTS._3dAnimate = true;                          
                        }
                    }
                    else{
                    	CONTENTVIEW_EVENTS._3dAnimate = false;
                    } 
                     //END TRB00090 - Editor: Long - Date : 09/26/2013 - Summary : remove time to detect 3d animate                                                                                                                                                    
                }
                //End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary:        
            }                                                          
        } 
        else if(CONTENTVIEW_GENERAL._startPoints.length == 1){
            // start zoom page action
            if(CONTENTVIEW_GENERAL._isPageNaviTouch){
                // reset navi page action if exists
            	CONTENTVIEW_EVENTS.resetNaviAction();  
            }  
            
            touch1 = CONTENTVIEW_GENERAL._startPoints[0];
            touch2 = {clientX: evt.clientX, clientY: evt.clientY,pointerId: evt.pointerId};
            CONTENTVIEW_GENERAL._startPoints.push(touch2);
            
            //set last dist
            CONTENTVIEW_GENERAL._lastDist = CONTENTVIEW_EVENTS.getDistance({
                    x: touch1.clientX,
                    y: touch1.clientY
                }, {
                    x: touch2.clientX,
                    y: touch2.clientY
                });
            
            CONTENTVIEW_GENERAL.px = touch1.clientX+touch2.clientX/2;
            CONTENTVIEW_GENERAL.py = touch1.clientY+touch2.clientY/2;
                                  
        } 
        else {
            //when CONTENTVIEW_GENERAL._startPoints.length > 1
            touch1 = {clientX: evt.clientX, clientY: evt.clientY,pointerId: evt.pointerId};
            CONTENTVIEW_GENERAL._startPoints.push(touch1);
            if(CONTENTVIEW_GENERAL._isPageNaviTouch){
            	CONTENTVIEW_EVENTS.resetNaviAction();
            }   
            
            if(CONTENTVIEW_GENERAL._isPageZoomTouch){
            	CONTENTVIEW_EVENTS.resetZoomAction();
            }
        }        
    }
    else{              
        
        // not is win 8 touch event 
        touch1 = evt.touches[0];
        touch2 = evt.touches[1];
        if(touch2 == null){
        	CONTENTVIEW_EVENTS._isClick = true;
            CONTENTVIEW_EVENTS._touchPageX = evt.touches[0].pageX;
            CONTENTVIEW_EVENTS._touchPageY = evt.touches[0].pageY;
            //set touch to move page flag
            if(CONTENTVIEW.userScale == 1){
                
                if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
                    $('#mainPre').css("display",'block');
                    $('#mainNext').css("display",'block');
                }
                
                CONTENTVIEW_GENERAL._isPageNaviTouch = true;
                CONTENTVIEW_GENERAL._moveNum = 0;
                CONTENTVIEW_GENERAL.touchStartedTime = new Date();
                
                // set first and last Pos
                CONTENTVIEW_GENERAL._touchFirstPos = {x:touch1.clientX, y: touch1.clientX};
                CONTENTVIEW_GENERAL._touchLastPos = {x:touch1.clientX, y: touch1.clientX};
                
                //Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary : 
                var imagePt = CONTENTVIEW.screenToImage(touch1.pageX, touch1.pageY);
                var hitPageObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
                
                if (hitPageObj) {                                                       
                    if(CONTENTVIEW.is3DObject(hitPageObj)){                                             
                        //START TRB00090 - Editor: Long - Date : 09/26/2013 - Summary : remove time to detect 3d animate  
                        if(CONTENTVIEW_EVENTS.isPageTransition){
                        	CONTENTVIEW_EVENTS._3dAnimate = false;
                            CONTENTVIEW_EVENTS._isClick = true;
                        }
                        else{             
                        	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchStart_MouseDown;
                        	CONTENTVIEW_3D._curr3dObject = hitPageObj;
                            hitPageObj.action(imagePt);
                            CONTENTVIEW_EVENTS._3dAnimate = true;
                            CONTENTVIEW_EVENTS._isClick = false;
                        }   
                        //END TRB00090 - Editor: Long - Date : 09/26/2013 - Summary : remove time to detect 3d animate                  
                    }
                    else{                       
                    	CONTENTVIEW_EVENTS._3dAnimate = false;
                        CONTENTVIEW_EVENTS._isClick = true;
                    }                                                                                                                                                    
                }
                else{                 
                	CONTENTVIEW_EVENTS._3dAnimate = false;
                    CONTENTVIEW_EVENTS._isClick = true;
                }
                //End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary:                                
            }
            else if(CONTENTVIEW.userScale != 1){
            	CONTENTVIEW_GENERAL._isPageNaviTouch = false;
                //CONTENTVIEW_GENERAL.px = evt.pageX;
                //CONTENTVIEW_GENERAL.py = evt.pageY;
                //試験
                CONTENTVIEW_GENERAL.px = evt.touches[0].pageX;
                CONTENTVIEW_GENERAL.py = evt.touches[0].pageY;
            }
            else {
                //ここにこない
            	CONTENTVIEW_GENERAL._isPageNaviTouch = false;
            }   
                                
        }
               
        //set begin value for zoom
        if(touch1 && touch2) {
        	CONTENTVIEW_GENERAL._lastDist = CONTENTVIEW_EVENTS.getDistance({
                    x: touch1.clientX,
                    y: touch1.clientY
                }, {
                    x: touch2.clientX,
                    y: touch2.clientY
                });
            CONTENTVIEW_GENERAL.px = touch1.clientX+touch2.clientX/2;
            CONTENTVIEW_GENERAL.py = touch1.clientY+touch1.clientY/2;
      
            CONTENTVIEW_GENERAL._isPageNaviTouch = false;
        }           
    }
};

//CONTENTVIEW_EVENTS.TouchmoveCount = 0;

CONTENTVIEW_EVENTS.onTouchmove = function(evt){
	
    if(ClientData.IsAddingMarking() == true){
        return;  
    }
    
    var bContinue = true;
    if(CONTENTVIEW_GENERAL.isLoadingObject){
        bContinue = false;
    }
    
    if( evt.pointerType != null ){
        //evt.pointerType は IE以外 undef
        switch (evt.pointerType) {
            case evt.MSPOINTER_TYPE_TOUCH:
            	CONTENTVIEW_EVENTS._isTouching = true;
                break;          
            case evt.MSPOINTER_TYPE_PEN:
                bContinue = false;
                break;
            case evt.MSPOINTER_TYPE_MOUSE:
            	CONTENTVIEW_EVENTS._isTouching = false;
                bContinue = false;
                break;
        }
    } else {
    	CONTENTVIEW_EVENTS._isTouching = true;
    }
    
    if(!bContinue){
        return;  
    }

    if( CONTENTVIEW_GENERAL._bTouchDeviceEnabled ){
        evt.preventDefault();
        evt.stopPropagation();
    }
    
	//if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
	//	CONTENTVIEW_EVENTS.TouchmoveCount = CONTENTVIEW_EVENTS.TouchmoveCount + 1;
	//}
    
    var touch1 = null;
    var touch2 = null;      
    if(CONTENTVIEW_GENERAL._bWin8TouchEnabled){   
       
        if(CONTENTVIEW_GENERAL._startPoints.length == 1){
            //move page case          
            //when change from zoom mode
            if(CONTENTVIEW.userScale != 1){
            	CONTENTVIEW_GENERAL._isPageNaviTouch = false;
                //START TRB00097
                CONTENTVIEW.cancelClick = true;
                //END TRB00097
                $('#main').css('cursor', 'pointer');        

                var mx;
                var my;
                // calc mouse moving distance
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
                    mx = evt.pageX - CONTENTVIEW_GENERAL.px;
                    my = evt.pageY - CONTENTVIEW_GENERAL.py;

                } else {
                    mx = evt.targetTouches[0].pageX - CONTENTVIEW_GENERAL.px;
                    my = evt.targetTouches[0].pageY - CONTENTVIEW_GENERAL.py;
                }
               
                var sx = 1 / CONTENTVIEW.userScale;
                var sy = 1 / CONTENTVIEW.userScale;
                               
                // calc scaling moving distance
                CONTENTVIEW.moveX = Math.round(-mx * sx);
                CONTENTVIEW.moveY = Math.round(-my * sy);
                
                // store current mouse point
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
                	CONTENTVIEW_GENERAL.px = evt.pageX;
                	CONTENTVIEW_GENERAL.py = evt.pageY;
                } else {
                	CONTENTVIEW_GENERAL.px = evt.targetTouches[0].pageX;
                	CONTENTVIEW_GENERAL.py = evt.targetTouches[0].pageY;
                }
        
                // redraw
                CONTENTVIEW.flip();
                CONTENTVIEW.zoomVideo();
                CONTENTVIEW.closeDialogPopUpText();                              
            }
            else{
                if(CONTENTVIEW_EVENTS._3dAnimate){
                	CONTENTVIEW_GENERAL._isPageNaviTouch = false;   
                    var imagePt = CONTENTVIEW.screenToImage(evt.pageX, evt.pageY);
                    var hitObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
          
                    if(hitObj){            
                    	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchMove_MouseMove;
                        hitObj.action(imagePt);                     
                    }
                }
                else{
                	CONTENTVIEW_GENERAL._isPageNaviTouch = true;
                    
                    //Detect is page transition to prevent 3d object animate
                    var posDiffX = evt.clientX - CONTENTVIEW_EVENTS.touchDownFirstPosX ;
                    var posDiffY = evt.clientY - CONTENTVIEW_EVENTS.touchDownFirstPosY ;
                    
                    if(Math.abs(posDiffX) < CONTENTVIEW_EVENTS.clickLimitArea && Math.abs(posDiffY) < CONTENTVIEW_EVENTS.clickLimitArea){
                    	CONTENTVIEW_EVENTS.isPageTransition = false;
                    	CONTENTVIEW_EVENTS.isPreventClick = false; 
                    }        
                    else{
                    	CONTENTVIEW_EVENTS.isPageTransition = true;
                        
                        //Start : TRB00005, TRB00006 - Editor : Long - Date: 08/28/2013
                        //Prevent CLick when page is being transit
                    	CONTENTVIEW_EVENTS.isPreventClick = true;  
                        //End : TRB00005, TRB00006 - Editor : Long - Date: 08/28/2013   
                    }                          
                                  
                    
                    touch1 = {clientX: evt.clientX, clientY: evt.clientY, pointerId: evt.pointerId};
                    CONTENTVIEW_GENERAL._bufferPoints.push(touch1);  // add to buffer to use for another action if occur. ex: zoom page
                    
                    if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
                        $('#mainPre').css("display",'block');
                        $('#mainNext').css("display",'block');
                    }
        
                    CONTENTVIEW_GENERAL.touchStartedTime = new Date();
                    
                    var temp = CONTENTVIEW_GENERAL._startPoints[0];
                    // set first and last Pos
                    if(CONTENTVIEW_GENERAL._touchFirstPos == null){
                    	CONTENTVIEW_GENERAL._touchFirstPos = {x:temp.clientX, y: temp.clientX};
                        CONTENTVIEW_GENERAL._moveNum = 0;
                    } 
                    if(CONTENTVIEW_GENERAL._touchLastPos==null){
                    	CONTENTVIEW_GENERAL._touchLastPos = {x:temp.clientX, y: temp.clientX};
                    }
                }                                 
            }                                     
        }
        else if(CONTENTVIEW_GENERAL._startPoints.length == 2){

            //zoom page case
        	CONTENTVIEW_GENERAL._isPageZoomTouch = true;
            //rest navi touch if active
            if(CONTENTVIEW_GENERAL._isPageNaviTouch){
            	CONTENTVIEW_EVENTS.resetNaviAction();
            }   
            
            //console.log("zoom page case");
            if(CONTENTVIEW_GENERAL._bufferPoints.length == 0) {
                //first point so that wait to next point
                touch1 = {clientX: evt.clientX, clientY: evt.clientY, pointerId: evt.pointerId};
                CONTENTVIEW_GENERAL._bufferPoints.push(touch1);
                return;
            }else if(CONTENTVIEW_GENERAL._bufferPoints.length == 1) {
                // second point so that get first point and process zoom page
                touch1 = CONTENTVIEW_GENERAL._bufferPoints[0];
                
                // check pointer id
                if(touch1.pointerId == evt.pointerId){
                    // one touch session is identify by one pointerId
                    // in this case do nothing and go to get next pointerId  
                    return;
                }else if(touch1.pointerId > evt.pointerId){
                	CONTENTVIEW_GENERAL._bufferPoints = [];  // reset buffer to get pointerId with correct order from begin
                    return; 
                }
                touch2 = {clientX: evt.clientX, clientY: evt.clientY, pointerId: evt.pointerId};
                
                //console.log("_bufferPoints.length:" + CONTENTVIEW_GENERAL._bufferPoints.length);
                CONTENTVIEW_GENERAL._bufferPoints = [];
            }
        }
        else {
            //reset navi touch if active
            if(CONTENTVIEW_GENERAL._isPageNaviTouch){
            	CONTENTVIEW_EVENTS.resetNaviAction();
            }   

            if(CONTENTVIEW_GENERAL._isPageZoomTouch){
            	CONTENTVIEW_EVENTS.resetZoomAction();
            }
            return;
        }

       //process  
        if(CONTENTVIEW_GENERAL._isPageNaviTouch){
            
            currPos = {x:touch1.clientX, y: touch1.clientY};
            if(!CONTENTVIEW_EVENTS.processNaviPage(currPos)){
                
                // can not move to previous or next page
                return; 
            }
        }
                
        // zoom page case
        if(CONTENTVIEW_GENERAL._isPageZoomTouch) {
        	CONTENTVIEW_EVENTS.processZoomPage(touch1, touch2);
        }       
    }
    else{
    	//CONTENTVIEW_EVENTS._isClick = false; 
        // for android or ipad
        touch1 = evt.touches[0];
        touch2 = evt.touches[1];
        
        if( touch2 != null ){
    		CONTENTVIEW_EVENTS._isClick = false; 
        }
        
        if(CONTENTVIEW_EVENTS._3dAnimate){
                           
            var imagePt = CONTENTVIEW.screenToImage(touch1.pageX, touch1.pageY);
            var hitObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
            //START TRB00090 - Editor: Long - Date 09/30/2013 - Summary: Fix animate 3d object in ipad
            if(hitObj){
                if(CONTENTVIEW.is3DObject(hitObj)){
                	CONTENTVIEW_GENERAL._isPageNaviTouch = false;
                	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchMove_MouseMove;
                    hitObj.action(imagePt);   
                }               
            }
            else{
            	CONTENTVIEW_EVENTS._3dAnimate = false;
                //CONTENTVIEW_GENERAL._isPageNaviTouch = true;
            } 
            //END TRB00090 - Editor: Long - Date 09/30/2013 - Summary: Fix animate 3d object in ipad
        }
        else{
            //update last touch position 
            if(touch2 == null && CONTENTVIEW_GENERAL._isPageNaviTouch){
            	CONTENTVIEW_EVENTS.isPageTransition = true;
                currPos = {x:touch1.clientX, y: touch1.clientY};
                
                if(!CONTENTVIEW_EVENTS._transitionObject.processNaviPage(currPos)){
                    // can not move to previous or next page
                    return; 
                }
            }
            else{
                //when change from zoom mode
                if(CONTENTVIEW.userScale != 1){
    
                    $('#main').css('cursor', 'pointer');        
    
                    var mx;
                    var my;
                  
                    mx = evt.targetTouches[0].pageX - CONTENTVIEW_GENERAL.px;
                    my = evt.targetTouches[0].pageY - CONTENTVIEW_GENERAL.py;
                           
                    var sx = 1 / CONTENTVIEW.userScale;
                    var sy = 1 / CONTENTVIEW.userScale;
                                   
                    // calc scaling moving distance
                    CONTENTVIEW.moveX = Math.round(-mx * sx);
                    CONTENTVIEW.moveY = Math.round(-my * sy);
                    
                    //移動量調整
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
                        CONTENTVIEW.moveX = CONTENTVIEW.moveX * 10;
                        CONTENTVIEW.moveY = CONTENTVIEW.moveY * 10;
                    }
                    
                    CONTENTVIEW_GENERAL.px = evt.targetTouches[0].pageX;
                    CONTENTVIEW_GENERAL.py = evt.targetTouches[0].pageY;
                    
                	// redraw
                	CONTENTVIEW.flip();
                	CONTENTVIEW.zoomVideo();
                	CONTENTVIEW.closeDialogPopUpText();                              
                    
                }
            }
                        
            // zoom page case
            if(touch1 && touch2) {
            	CONTENTVIEW_EVENTS.processZoomPage(touch1, touch2);
            } 
        }                     
    }
};

CONTENTVIEW_EVENTS.onTouchend = function(evt){
    
    if(ClientData.IsAddingMarking() == true){
        return;  
    }
    
    var bContinue = true;
   
    if(CONTENTVIEW_GENERAL.isLoadingObject){
        bContinue = false;
    }
    
    if( evt.pointerType != null ){
        //evt.pointerType は IE以外 undef
        switch (evt.pointerType) {
            case evt.MSPOINTER_TYPE_TOUCH:
            	CONTENTVIEW_EVENTS._isTouching = true;
                break;          
            case evt.MSPOINTER_TYPE_PEN:
            	CONTENTVIEW_EVENTS._isTouching = false;
                bContinue = false;
                break;
            case evt.MSPOINTER_TYPE_MOUSE:
            	CONTENTVIEW_EVENTS._isTouching = false;
                bContinue = false;
                break;
        }
    } else {
        //タッチ操作終了
    	CONTENTVIEW_EVENTS._isTouching = false;
    }
    
    if(!bContinue){
        return;  
    } 
    
    if( CONTENTVIEW_GENERAL._bTouchDeviceEnabled ){
        evt.preventDefault();
        evt.stopPropagation();
    }
    
    CONTENTVIEW_GENERAL._lastScaleDelta = CONTENTVIEW.userScale -1;

    if(CONTENTVIEW_GENERAL._bWin8TouchEnabled){
        
        // reset all flag
    	CONTENTVIEW_GENERAL._startPoints = [];
    	CONTENTVIEW_GENERAL._bufferPoints = [];
        
        if(CONTENTVIEW_EVENTS._3dAnimate == true){
        	CONTENTVIEW_EVENTS._3dAnimate = false;
        	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchEnd_MouseUp;
        	CONTENTVIEW_3D._curr3dObject.action(); 
        }
        
        if(CONTENTVIEW_EVENTS.isPageTransition){
        	CONTENTVIEW_EVENTS.isPageTransition = false;
            CONTENTVIEW_EVENTS.touchDownFirstPosX = 0;
            CONTENTVIEW_EVENTS.touchDownFirstPosY = 0;
        }    
                  
    }
    
    //move page if enough condition 
    if(CONTENTVIEW_GENERAL._bTransitionEnable){
        if(CONTENTVIEW_GENERAL._isPageNaviTouch){
        	CONTENTVIEW_GENERAL._isPageNaviTouch = false;
            //calculate time period from last time of touchstart event
            var currDate = new Date();
            var period = currDate - CONTENTVIEW_GENERAL.touchStartedTime;

            if(period >= CONTENTVIEW_GENERAL._touchMoveTimePeriod && period < CONTENTVIEW_GENERAL._touchMoveTimePeriodInvalid){
            	CONTENTVIEW_GENERAL.touchStartedTime= 0;
                if(CONTENTVIEW_GENERAL._moveNum == 2){
                	CONTENTVIEW_EVENTS.nextPage_click();
                	//変数後始末
                    CONTENTVIEW.cancelClick = false;
                    CONTENTVIEW_EVENTS._isClick = false;
                	return;
                }else if (CONTENTVIEW_GENERAL._moveNum == -2){
                	CONTENTVIEW_EVENTS.prevPage_click();
                	//変数後始末
                    CONTENTVIEW.cancelClick = false;
                    CONTENTVIEW_EVENTS._isClick = false;
                	return;
                }else {
                	CONTENTVIEW_GETDATA.correctCanvasPosition();
                }
           }
        }
    }

    //Check if click event on ipad
    if(CONTENTVIEW_EVENTS._isClick == true){

        if(CONTENTVIEW_GENERAL.isLoadingObject){ 
        	CONTENTVIEW_EVENTS._isClick = false;      
            return;
        }
        else{
        	CONTENTVIEW.cancelClick = false;
        }
        
        if (!CONTENTVIEW.cancelClick) {
        	
            var imagePt = CONTENTVIEW.screenToImage(CONTENTVIEW_EVENTS._touchPageX, CONTENTVIEW_EVENTS._touchPageY);
            var canvasWidth = $('#offscreen').width();
            CONTENTVIEW_GENERAL.posXPopupMemo = CONTENTVIEW_EVENTS._touchPageX;
            CONTENTVIEW_GENERAL.posYPopupMemo = CONTENTVIEW_EVENTS._touchPageY;
            
            if ((CONTENTVIEW_EVENTS._touchPageX - CONTENTVIEW.marginX) >= CONTENTVIEW.destRect.left && (CONTENTVIEW_EVENTS._touchPageX - CONTENTVIEW.marginX) <= CONTENTVIEW.destRect.right) {
                if (ClientData.IsAddingMemo() == true) {
                    if (!ClientData.memo_copyText()) {
                    	CONTENTVIEW_MEMO.AddMemo(CONTENTVIEW_GENERAL.contentID, CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()), $('#divDialogMemo'), CONTENTVIEW_EVENTS._touchPageX, CONTENTVIEW_EVENTS._touchPageY, function () {
                                //set flag change memo 
                                ClientData.isChangedMemo(true);
                                ClientData.IsAddingMemo(false);
        
                                /* refresh draw memo */
                                CONTENTVIEW.drawMemoOnScreen();
        
                                //change image                                          
                                $('#imgaddmemo').removeClass();
                                $('#imgaddmemo').addClass('memoAdd');
                            });
                    }
                    else {
                        if (CONTENTVIEW_GENERAL.typeSelectMemo == 1) { /* add new */
                        	CONTENTVIEW_MEMO.AddMemo(CONTENTVIEW_GENERAL.contentID, CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()), $('#divDialogMemo'), CONTENTVIEW_GENERAL.posXPopupMemo, CONTENTVIEW_GENERAL.posYPopupMemo, function () {
                                //set flag change memo 
                                ClientData.isChangedMemo(true);
                                ClientData.IsAddingMemo(false);
    
                                /* refresh draw memo */
                                CONTENTVIEW.drawMemoOnScreen();
    
                                //change image                                          
                                $('#imgaddmemo').removeClass();
                                $('#imgaddmemo').addClass('memoAdd');
                            });
    
                        } else if (CONTENTVIEW_GENERAL.typeSelectMemo == 2) { /* copy */
                        	CONTENTVIEW_MEMO.CopyMemo(ClientData.memo_copyText(), CONTENTVIEW_GENERAL.contentID, CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()), $('#divDialogMemo'), CONTENTVIEW_GENERAL.posXPopupMemo, CONTENTVIEW_GENERAL.posYPopupMemo, function () {
                                //set flag change memo 
                                ClientData.isChangedMemo(true);
                                ClientData.IsAddingMemo(false);
    
                                /* refresh draw memo */
                                CONTENTVIEW.drawMemoOnScreen();
    
                                //change image                                          
                                $('#imgaddmemo').removeClass();
                                $('#imgaddmemo').addClass('memoAdd');
                            });
                        }
                    }
                }
                else{
                    var isClickMemo = false;
    
                    if (CONTENTVIEW_GENERAL.isOpenPopUpText == true) {
                    	CONTENTVIEW_GENERAL.isOpenPopUpText = false;
                    	CONTENTVIEW_POPUPTEXT.ClosePopupText();
                    }
    
                    if (CONTENTVIEW_GENERAL.isOpenPopUpMemo == true) {
                    	CONTENTVIEW_GENERAL.isOpenPopUpMemo = false;
                        $("#pop_up_memo").hide();
                    }
                    
                    /* click memo edit */
                    if (ClientData.IsDisplayMemo() == true) {
                    	CONTENTVIEW_GETDATA.getAllMemoOfPage();
                        /* check exist object memo in mouse position */
                        for (var nIndex = 0; nIndex < CONTENTVIEW_CREATEOBJECT.memoObjects.length; nIndex++) {
                            var hitPageObjMemo = CONTENTVIEW_CREATEOBJECT.memoObjects[nIndex];
                            if (hitPageObjMemo.hitTest(imagePt.x, imagePt.y)) {
                                //console.log("PageObject Hit!! Id: " + hitPageObjMemo.id);
                                //hitPageObjMemo.action();
    
                                /* save object memo */
                            	CONTENTVIEW_GENERAL.objEditMemo = hitPageObjMemo;
                                var posMemoX = CONTENTVIEW_EVENTS._touchPageX;
                                var posMemoY = CONTENTVIEW_EVENTS._touchPageY;
    
                                if (imagePt.y > CONTENTVIEW_GENERAL.heightEachPage - $("#pop_up_memo").height()) {
                                    posMemoY = posMemoY - $("#pop_up_memo").height();
    
                                }
    
                                if (imagePt.x > CONTENTVIEW_GENERAL.widthEachPage - $("#pop_up_memo").width()) {
                                    posMemoX = posMemoX - $("#pop_up_memo").width();
                                }
    
                                /*display pop-up-memo */
                                $("#pop_up_memo").css('top', posMemoY).css('left', posMemoX);
                                $("#pop_up_memo").show();
    
                                /*set true for flag click memo */
                                isClickMemo = true;
                                CONTENTVIEW_GENERAL.isOpenPopUpMemo = true;
    
                            }
                        }
                    }
                    
                    /* click pageObject */
                    if (isClickMemo == false) {
                        var isClickLinkList = false;
    
                        /* check exist object in mouse position */
                        var hitPageObj = CONTENTVIEW_GETDATA.getContent().currentPage.hitTest(imagePt.x, imagePt.y);
                                                                                   
                        if (hitPageObj) { 
                            if(!CONTENTVIEW.is3DObject(hitPageObj)){
                                hitPageObj.action();    
                            }
                        }
                        else {
    
                            /* check click link list */
                            for (var nIndex = 0; nIndex < CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects.length; nIndex++) {
                                var hitPageObjLinkList = CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects[nIndex];
                                if (hitPageObjLinkList.hitTest(imagePt.x, imagePt.y)) {
    
                                    if(hitPageObjLinkList.pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())){
                                        hitPageObjLinkList.action();
                                        /*set true for flag click memo */
                                        isClickLinkList = true;
                                    }                                
                                }
                            }
    
                            if (isClickLinkList == false && ClientData.IsAddingMarking() == false) {
                            	
                                //Androidは遅いのでタッチエンドで描画
                                //if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
                                //	// redraw
                                //	CONTENTVIEW.flip();
                                //	CONTENTVIEW.zoomVideo();
                                //	CONTENTVIEW.closeDialogPopUpText();                              
                                //}
                            	
                                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
	                                /* area next and prev page */
	                                var cwMain = $('#main').width();
	                                if (CONTENTVIEW_EVENTS._touchPageX > 0 && CONTENTVIEW_EVENTS._touchPageX < 300) {
	                                	CONTENTVIEW_EVENTS.prevPage_click();
	                                } else if (CONTENTVIEW_EVENTS._touchPageX > (cwMain - 300) && CONTENTVIEW_EVENTS._touchPageX < cwMain) {
	                                	CONTENTVIEW_EVENTS.nextPage_click();
	                                }
                                }
                                
                                //CONTENTVIEW_STREAMING.debugLog("CONTENTVIEW_EVENTS.onTouchEnd");
                            	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile()) {
                            		CONTENTVIEW.handleDisplayMobileToolbar();
                            	}
                            }
                        }
                    }
                }       
            }
            else {
                if (ClientData.IsAddingMarking() == false && CONTENTVIEW_GENERAL.isCopyMemo == false) {
                	
                    //Androidは遅いのでタッチエンドで描画
                    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
                    //	// redraw
                    //	CONTENTVIEW.flip();
                    //	CONTENTVIEW.zoomVideo();
                    //	CONTENTVIEW.closeDialogPopUpText();                              
                    //}
                	
                	
                    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
	                    var cwMain = $('#main').width();
	                    if (CONTENTVIEW_EVENTS._touchPageX > 0 && CONTENTVIEW_EVENTS._touchPageX < 300) {
	                    	CONTENTVIEW_EVENTS.prevPage_click();
	                    } else if (CONTENTVIEW_EVENTS._touchPageX > (cwMain - 300) && CONTENTVIEW_EVENTS._touchPageX < cwMain) {
	                    	CONTENTVIEW_EVENTS.nextPage_click();
	                    }
                    //}
                }
            }
        }
        CONTENTVIEW.cancelClick = false;
        CONTENTVIEW_EVENTS._isClick = false;
    }
    else{
        //Do nothing
        if(CONTENTVIEW_EVENTS._3dAnimate == true){
        	CONTENTVIEW_EVENTS._3dAnimate = false;
        	CONTENTVIEW_3D._3dAction = CONTENTVIEW_3D._3dActionType.TouchEnd_MouseUp;
        	CONTENTVIEW_3D._curr3dObject.action(); 
        }
        
        if(CONTENTVIEW_EVENTS.isPageTransition){
        	CONTENTVIEW_EVENTS.isPageTransition = false;
        }  
    }
};

CONTENTVIEW_EVENTS.processZoomPage = function(touch1, touch2){
    
    var dist = CONTENTVIEW_EVENTS.getDistance({
            x: touch1.clientX,
            y: touch1.clientY
        }, {
            x: touch2.clientX,
            y: touch2.clientY
        });
    
    
    if(CONTENTVIEW_GENERAL._lastDist != dist) {
        if(dist > CONTENTVIEW_GENERAL._lastDist){               
        	CONTENTVIEW.userScale += 0.05;
             if (CONTENTVIEW.userScale > 4) {
            	 CONTENTVIEW.userScale = 4;
            	 CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
             }else {
            	 CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
                
                CONTENTVIEW.flip();
                //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
                
                if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
                    //START TRB00097
                    //CONTENTVIEW.flip(1);
                    //END TRB00097
                }
                
                if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
                    //START TRB00097
                    //CONTENTVIEW.flip(2);
                    //END TRB00097
                }
                //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
                
                 /* zoom video */
                CONTENTVIEW.zoomVideo();
             }
             CONTENTVIEW_GENERAL._lastDist = dist;
        }
        else if (dist < CONTENTVIEW_GENERAL._lastDist)
        {
        	CONTENTVIEW.userScale -= 0.05;
             if (CONTENTVIEW.userScale < 1) {
            	 CONTENTVIEW.userScale = 1;
            	 CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
             }else{
            	 CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
            	 CONTENTVIEW.flip();
                //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
                if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
                    //START TRB00097
                    //CONTENTVIEW.flip(1);
                    //END TRB00097
                }
                
                if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
                    //START TRB00097
                    //CONTENTVIEW.flip(2);
                    //END TRB00097
                }
                //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
                /* zoom video */
                CONTENTVIEW.zoomVideo();
             }
        }
    }
    
    CONTENTVIEW.checkDisableButtonZoom();    
};

/*
 * Process navi page after touch event
 */
CONTENTVIEW_EVENTS.processNaviPage = function(currPos){
    if(!CONTENTVIEW_GENERAL._bTransitionEnable){
        
        return;
    }
        
    // get moved delta period
    var lMoveX = currPos.x - CONTENTVIEW_GENERAL._touchLastPos.x;
    
    // pevious page not exist -> do not move
    if(!CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        if(currPos.x >= CONTENTVIEW_GENERAL._touchFirstPos.x){
            return false;
        }           
    }

    // next page not exist -> do not move
    if(!CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        if(currPos.x <= CONTENTVIEW_GENERAL._touchFirstPos.x){
           return false; 
        }           
    }
    
    //examinate direction 
    if(CONTENTVIEW_GENERAL._moveNum==0 &&  lMoveX  < 0){
    	CONTENTVIEW_GENERAL._moveNum = 2; // go from right to left => next page
    }
    if(CONTENTVIEW_GENERAL._moveNum==2 &&  lMoveX  > 0){
    	CONTENTVIEW_GENERAL._moveNum = 1; // go from right to left and back to right => no move
    }
    if(CONTENTVIEW_GENERAL._moveNum==1 &&  lMoveX  < 0){
    	CONTENTVIEW_GENERAL._moveNum = 2; // go from right to left + back to right + go to left  => next page
    }

    if(CONTENTVIEW_GENERAL._moveNum==0 &&  lMoveX  > 0){
    	CONTENTVIEW_GENERAL._moveNum = -2; // go from  left to right=> priveous page
    }
    if(CONTENTVIEW_GENERAL._moveNum==-2 &&  lMoveX  < 0){
    	CONTENTVIEW_GENERAL._moveNum = -1; // go from  left to right and back to left => no move
    }
    if(CONTENTVIEW_GENERAL._moveNum==0 &&  lMoveX  > 0){
    	CONTENTVIEW_GENERAL._moveNum = -2; // go from  left to right + back to left + go to right=> priveous page
    }
    //console.log("_moveNum:" +CONTENTVIEW_GENERAL._moveNum);
    
    if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
        var left = $('#canvasWrapper').css('left').replace("px","");
        left  =  parseInt(left) + lMoveX ;
        $('#canvasWrapper').css('left', left + "px");
    }
    CONTENTVIEW_GENERAL._touchLastPos = {x:currPos.x, y: currPos.y};
    
    return true;
}; 

/*
 * reset zoom  action as point session increase
 */
CONTENTVIEW_EVENTS.resetZoomAction = function (){
    //CONTENTVIEW_GENERAL._isPageZoomTouch = false;
};

CONTENTVIEW_EVENTS.getDistance = function(p1, p2) {
    return Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow((p2.y - p1.y), 2));
};

var TransitionObject = function () {
};

TransitionObject.prototype.processNaviPage = function (currPos) {
    if(!CONTENTVIEW_GENERAL._bTransitionEnable)
        return;
    // get moved delta period
    var lMoveX = currPos.x - CONTENTVIEW_GENERAL._touchLastPos.x;
    
    // pevious page not exist -> do not move
    if(!CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
        if(currPos.x >= CONTENTVIEW_GENERAL._touchFirstPos.x)
            return false;
    }

    // next page not exist -> do not move
    if(!CONTENTVIEW_GETDATA.getContent().hasNextPage()){
        if(currPos.x <= CONTENTVIEW_GENERAL._touchFirstPos.x)
            return false;
    }
    //examinate direction 
    if(CONTENTVIEW_GENERAL._moveNum==0 &&  lMoveX  < 0){
    	CONTENTVIEW_GENERAL._moveNum = 2; // go from right to left => next page
    }
    if(CONTENTVIEW_GENERAL._moveNum==2 &&  lMoveX  > 0){
    	CONTENTVIEW_GENERAL._moveNum = 1; // go from right to left and back to right => no move
    }
    if(CONTENTVIEW_GENERAL._moveNum==1 &&  lMoveX  < 0){
    	CONTENTVIEW_GENERAL._moveNum = 2; // go from right to left + back to right + go to left  => next page
    }

    if(CONTENTVIEW_GENERAL._moveNum==0 &&  lMoveX  > 0){
    	CONTENTVIEW_GENERAL._moveNum = -2; // go from  left to right=> priveous page
    }
    if(CONTENTVIEW_GENERAL._moveNum==-2 &&  lMoveX  < 0){
    	CONTENTVIEW_GENERAL._moveNum = -1; // go from  left to right and back to left => no move
    }
    if(CONTENTVIEW_GENERAL._moveNum==0 &&  lMoveX  > 0){
    	CONTENTVIEW_GENERAL._moveNum = -2; // go from  left to right + back to left + go to right=> priveous page
    }
    //console.log("_moveNum:" +CONTENTVIEW_GENERAL._moveNum);
    
    if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
        var left = $('#canvasWrapper').css('left').replace("px","");
        left  =  parseInt(left) + lMoveX ;
        $('#canvasWrapper').css('left', left + "px");
    }
    CONTENTVIEW_GENERAL._touchLastPos = {x:currPos.x, y: currPos.y};
    
    return true;    
};

CONTENTVIEW_EVENTS._transitionObject = new TransitionObject();

$(function () {
	//CONTENTVIEW_EVENTS.ready();
});

CONTENTVIEW_EVENTS.ready = function(){
	
	CONTENTVIEW_EVENTS.altMode = false; 

	//limit area to detech if it is click(on win8)
	CONTENTVIEW_EVENTS.clickLimitArea = 20;
	//touch position 
	CONTENTVIEW_EVENTS.touchDownFirstPosX = 0;
	CONTENTVIEW_EVENTS.touchDownFirstPosY = 0;
	//position for click event on touch device
	CONTENTVIEW_EVENTS._touchPageX = 0;
	CONTENTVIEW_EVENTS._touchPageY = 0;
	//Detect touch
	CONTENTVIEW_EVENTS._isTouching = false;
	//Detect click on touch device
	CONTENTVIEW_EVENTS._isClick = false;
	//Detech if page is being transition
	CONTENTVIEW_EVENTS.isPageTransition = false;
	//Is 3d animating
	CONTENTVIEW_EVENTS._3dAnimate = false;
	//is prevent click event
	CONTENTVIEW_EVENTS.isPreventClick = false;
	
};

