/// コンテンツ詳細画面

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

$(document).mouseup(function (e) {
    if (e.which == 1){
    	CONTENTVIEW_GENERAL.isPressLeftMouse = false;
    }
});

/* change size */
CONTENTVIEW.sizingScreen = function() {

    var w = $(window).width();
    var h = $(window).height();

    if (COMMON.isTouchDevice() == true) {
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
            var tempRatio = document.documentElement.clientWidth / window.innerWidth;
            if (tempRatio <= 1) {
                w = window.innerWidth;
                h = window.innerHeight;
            }
            else {
                w = $(window).width();
                h = $(window).height();
            }
        }
    }

    // Adjust the size of the View
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
    	CONTENTVIEW.sizingFullSize(w, h);
    } else {
    	CONTENTVIEW.sizingNotFull(w, h);
    }

};

/* memo */
CONTENTVIEW.handleMemo = function() {
    $('#pop_up_memo').hide();

    if (ClientData.IsDisplayMemo() == true) {
        ClientData.IsDisplayMemo(false);
        CONTENTVIEW_GENERAL.isCopyMemo = false;

        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

        //change class
        $('#imgmemo').removeClass();
        if (COMMON.isTouchDevice() == true) {
            $('#imgmemo').addClass('memoDisplay_device');
        } else {
            $('#imgmemo').addClass('memoDisplay');
        }

        /*handle image add memo */
        ClientData.IsAddingMemo(false);

        //change class
        $('#imgaddmemo').removeClass();
        if (COMMON.isTouchDevice() == true) {
            $('#imgaddmemo').addClass('memoAdd_device');
        } else {
            $('#imgaddmemo').addClass('memoAdd');
        }

    }
    else {
        ClientData.IsDisplayMemo(true);
        CONTENTVIEW_GENERAL.isCopyMemo = false;

        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');

    }
};


/* display canvas draw*/
CONTENTVIEW.displayCanvasDraw = function() {
    /*set flag no image */
	CONTENTVIEW_GENERAL.isDrawing = false;

    /* clear canvas */
	CONTENTVIEW_GENERAL.context_draw.clearRect(0, 0, CONTENTVIEW_GENERAL.canvas_draw.width, CONTENTVIEW_GENERAL.canvas_draw.height);

	CONTENTVIEW_GENERAL.context_draw.save();

    /* set draw image if exist */
    var dataMarking = ClientData.MarkingData();

    for (var nIndex = 0; nIndex < dataMarking.length; nIndex++) {
        if (dataMarking[nIndex].contentid == CONTENTVIEW_GENERAL.contentID
        && dataMarking[nIndex].pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())) {
            var img = new Image();
            img.onload = function () {

            	CONTENTVIEW_GENERAL.context_draw.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.canvas_draw.width, CONTENTVIEW_GENERAL.canvas_draw.height);

                /*set flag has image */
                CONTENTVIEW_GENERAL.isDrawing = true;
            };
            img.src = dataMarking[nIndex].content;
        }
    }

    CONTENTVIEW_GENERAL.context_draw.restore();

    /* visible canvas using for draw */
    $('#draw_canvas').css('display', 'block');
};


/* handle draw canvas */
CONTENTVIEW.handleDrawCanvas = function() {
	CONTENTVIEW_MARKING.disableButtonMarking();
    if (ClientData.IsAddingMarking() == true) {
        if (ClientData.IsHideToolbar() == true) {
            ClientData.IsAddingMarking(true);
            ClientData.IsDisplayMarking(true);
            ClientData.IsHideToolbar(false);
            CONTENTVIEW_MARKING.ShowMarking();

            $('#imgmarking').removeClass();
            $('#imgmarking').addClass('marking_off');
        }
    }
    else {
        ClientData.IsAddingMarking(true);
        ClientData.IsDisplayMarking(true);
        ClientData.IsHideToolbar(false);

        /* fit page */
        CONTENTVIEW.screenFit();

        /* show marking */
        CONTENTVIEW_MARKING.ShowMarking();

        /* display fullscreen */
        CONTENTVIEW.handleDisplayToolbar();

        /* invisible button fullscreen */
        $('#footer_toolbar_2').hide();
        $('#control_screen_2').hide();


        //START TRB00032 - EDITOR : Long - DATE: 09/10/2013 - Summary : For Content Type None
        /* draw again */
        //CONTENTVIEW.drawCanvas();
        //END TRB00032 - EDITOR : Long - DATE: 09/10/2013 - Summary : For Content Type None

        CONTENTVIEW.displayCanvasDraw();
        CONTENTVIEW_GENERAL.disableAllControl();
    }

    /* get data from local */
    CONTENTVIEW_GETDATA.getDataClientStorage();

};

/* bookmark page */
CONTENTVIEW.bookmarkPage = function() {
    ClientData.isChangedBookmark(true);
    var nBookmarkId = CONTENTVIEW.isExistBookmark();
    if (nBookmarkId == -1) {
        //case not exist
        var enBookmark = new BookMarkEntity();
        enBookmark.contentid = CONTENTVIEW_GENERAL.contentID;
        enBookmark.pageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex());
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image){
            enBookmark.contentTitle = CONTENTVIEW_GENERAL.imageTypeData.contentName;
            enBookmark.contentTitleKana = CONTENTVIEW_GENERAL.imageTypeData.contentNameKana;
        }
        else{
            enBookmark.contentTitle = CONTENTVIEW_GENERAL.dataWebContentPage.contentTitle;
            enBookmark.contentTitleKana = CONTENTVIEW_GENERAL.dataWebContentPage.contentTitleKana;
        }

        //=== Start Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time and UUID when create new bookmark.
        enBookmark.bookmarkid = COMMON.getUUID();
        enBookmark.registerDate = new Date();
        //=== Start Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time and UUID when create new bookmark.
        var listBM = [];

        if (ClientData.BookMarkData().length > 0) {
            listBM = ClientData.BookMarkData();
        }
        listBM.push(enBookmark);
        ClientData.BookMarkData(listBM);

        //change class
        $('#imgbookmark').removeClass();
        $('#imgbookmark').addClass('bmAdd_hover');

    } else {
        //delete bookmark page
        var listBM = [];
        listBM = ClientData.BookMarkData();
        listBM.splice(nBookmarkId, 1);
        ClientData.BookMarkData(listBM);

        //change class
        $('#imgbookmark').removeClass();
        if (COMMON.isTouchDevice() == true) {
            $('#imgbookmark').addClass('bmAdd_device');
        } else {
            $('#imgbookmark').addClass('bmAdd');
        }

    }
};

/* function changePage Index->pageno */
CONTENTVIEW.changePageIndex = function(page_index) {
    //Start: Function No.12
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image){
        return 1;
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
        return page_index + 1;
    }
    //End: Function No.12
    else{
    	//最後のページのメモを削除するとエラーになる暫定対応
    	if( CONTENTVIEW_GENERAL.dataWebContentPage.pages[page_index] ){
    		return CONTENTVIEW_GENERAL.dataWebContentPage.pages[page_index].pageNo;
    	} else {
            return page_index - 1;
    	}
    }
};

/* function change PageNo -> pageIndex */
CONTENTVIEW.changePageNo = function(page_no) {

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        var dataContent = CONTENTVIEW_GENERAL.dataWebContentPage.pages;
        for (var nIndex = 0; nIndex < dataContent.length; nIndex++) {
            if (dataContent[nIndex].pageNo == page_no) {
                return nIndex;
            }
        }
    }
    //START : TRB00032 - Editor : Long - Date : 09/10/2013 - Summary : Process Type None
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
        page_no = page_no - 1;
        return page_no;
    }
   //END : TRB00032 - Editor : Long - Date : 09/10/2013 - Summary : Process Type None
    return -1;

};

/* check page had bookmark */
CONTENTVIEW.isExistBookmark = function() {
    var nIndexBookmark = -1;
    var listBM = [];
    if (ClientData.BookMarkData().length > 0) {
        //get list bookmark
        listBM = ClientData.BookMarkData();

        for (var nIndex = 0; nIndex < listBM.length; nIndex++) {
            //check bookmark belong contentID
            if (listBM[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listBM[nIndex].pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())) {
                return nIndex;
            }
        }
    }
    return nIndexBookmark;
};

/*get API WebContentPage */
CONTENTVIEW.handleAPIWebContentPage = function(dataJson, pos) {
    var bmList = [];
    bmList = CONTENTVIEW_GETDATA.getBookMarkListByContentID();
    var dataStored = CONTENTVIEW_GENERAL.arrThumbnailsLoaded;

    var sPageNo = [];
    var nIndexBookMark = -1;
    var lstPageNoBookMark = [];

    $('#bookmarkBoxHdBM').children().remove();
    $('#bookmarkBoxHdBM').html('<a id="bookmarkClosing" class="delete" > </a>');
    //$("#bookmarkClosing").click(CONTENTVIEW_EVENTS.closeBookmarkBox);
    $("#bookmarkClosing").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_EVENTS.closeBookmarkBox(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });

    $('#bookmarkBoxHdBM').append(I18N.i18nText('txtShioriCtnLs'));

    $('#boxBookMark').css('z-index', '101');
    $('#boxBookMark').css('display', 'block');
    $('#boxBookMark').draggable({ handle: "h1" });
    $("#boxBookMark").offset({ left: pos[0], top: pos[1] });
    $("#divListBookmark").show();
    $("#divListBookmark").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdBM').height()) });
    $('#divListBookmark').children().remove();


    //Start Function : No.4 - Editor : Long - Date : 08/20/2013
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
            nIndexBookMark = -1;
            var contentPage = dataJson.pages;

            for (var nIndexJson = 0; nIndexJson < contentPage.length; nIndexJson++) {
                if (contentPage[nIndexJson].pageNo == bmList[nIndex].pageNo) {
                    nIndexBookMark = nIndexJson;
                    break;
                }
            }

            if (nIndexBookMark != -1) { /* page exist */
                var nStored = CONTENTVIEW.checkDataLoaded(bmList[nIndex].pageNo, dataStored);
                if (nStored != -1) { /* data loaded */
                    $('#divListBookmark').append(
                        '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
                        '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="' + COMMON.formatStringBase64(dataStored[nStored].pageThumbnail) + '"/>' +
                        '       <span class="mdltext">' +
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + 1) + '<br /> ' +
                                    COMMON.truncate(COMMON.htmlEncode(contentPage[nIndexBookMark].pageText), 20) +
                        '       </span>' +
                        '   </li>'
                        );

                    //Resize Image
                    var imgTemp = new Image();

                    imgTemp.onload = function () {

                        if (imgTemp.width > imgTemp.height) {

                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };

                    imgTemp.src = COMMON.formatStringBase64(dataStored[nStored].pageThumbnail);

                }
                else { /* data not loaded*/
                    $('#divListBookmark').append(
                        '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
                        '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="img/view_loading.gif" />' +
                        '       <span class="mdltext">' +
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + 1) + '<br /> ' +
                                    COMMON.truncate(COMMON.htmlEncode(contentPage[nIndexBookMark].pageText), 20) +
                        '       </span>' +
                        '   </li>'
                        );

                    //Resize Image
                    var imgTemp = new Image();

                    imgTemp.onload = function () {

                        if (imgTemp.width > imgTemp.height) {

                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };

                    imgTemp.src = "img/view_loading.gif";

                    lstPageNoBookMark.push(bmList[nIndex].pageNo);
                }


            }
            else { /* page deleted */
                $('#divListBookmark').append(
                        '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
                        '       <span class="mdltext">' +

                        '           <span>' + I18N.i18nText('txtPage') + bmList[nIndex].pageNo + '</span> <br /> ' +
                        '       </span>' +
                        '   </li>' +
                        '   <li>' +
                        '       <span class="mdltext">' +
                        '           <span class="error">' + I18N.i18nText('msgShioriDeleted') + '</span>' +
                        '       </span>' +
                        '   </li>'
                    );
            }
        }
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image ){

        for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
            nIndexBookMark = -1;
            var contentPage = CONTENTVIEW_GENERAL.imageTypeData;


            if (contentPage.pageNo == bmList[nIndex].pageNo) {
                nIndexBookMark = nIndexJson;
            }

            if (nIndexBookMark != -1) { /* page exist */

                    $('#divListBookmark').append(
                        '   <li id="' + 0 + '">' +
                        '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="img/view_loading.gif" />' +
                        '       <span class="mdltext">' +
                                    I18N.i18nText('txtPage') + 1 + '<br /> ' +
                                    COMMON.truncate(COMMON.htmlEncode(contentPage.contentName), 20) +
                        '       </span>' +
                        '   </li>'
                        );

                    //Resize Image
                    var imgTemp = new Image();
                    var imageContent = new Image();
                    var imageUrl = CONTENTVIEW.downloadResourceById(CONTENTVIEW_GENERAL.contentID);

                    imgTemp.onload = function () {

                        if (imgTemp.width > imgTemp.height) {

                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }

                        imageContent.onload = function(){
                            $("img.imgbox").attr('src', imageUrl);
                        };

                        imageContent.src = imageUrl;
                    };

                    imgTemp.src = "img/view_loading.gif";

                    lstPageNoBookMark.push(bmList[nIndex].pageNo);

            }
            else { /* page deleted */
                $('#divListBookmark').append(
                        '   <li id="' + 0 + '">' +
                        '       <span class="mdltext">' +

                        '           <span>' + I18N.i18nText('txtPage') + bmList[nIndex].pageNo + '</span> <br /> ' +
                        '       </span>' +
                        '   </li>' +
                        '   <li>' +
                        '       <span class="mdltext">' +
                        '           <span class="error">' + I18N.i18nText('msgShioriDeleted') + '</span>' +
                        '       </span>' +
                        '   </li>'
                    );
            }
        }
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
        for (var nIndex = 0; nIndex < bmList.length; nIndex++) {

            $('#divListBookmark').append(
                '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
                '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="img/view_loading.gif" />' +
                '       <span class="mdltext">' +
                            I18N.i18nText('txtPage') + bmList[nIndex].pageNo + '<br /> ' +
                            //COMMON.truncate(COMMON.htmlEncode(contentPage.contentName), 20) +
                '       </span>' +
                '   </li>'
            );

            //Resize Image
            var imgTemp = new Image();
            var imageContent = new Image();
            var imageUrl = CONTENTVIEW_GENERAL.pageImages;
            imgTemp.onload = function () {

                if (imgTemp.width > imgTemp.height) {

                    $("img.imgbox").attr('height', '');
                    $("img.imgbox").removeAttr('height');
                    $("img.imgbox").attr('width', '43');
                }
                else {
                    $("img.imgbox").attr('width', '');
                    $("img.imgbox").removeAttr('width');
                    $("img.imgbox").attr('height', '43');
                }

                imageContent.onload = function(){
                    $("img.imgbox").attr('src', imageUrl);
                };

                imageContent.src = imageUrl;
            };

            imgTemp.src = "img/view_loading.gif";

            lstPageNoBookMark.push(bmList[nIndex].pageNo);

        }
    }


    //End Function : No.4 - Editor : Long - Date : 08/20/2013
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        if (lstPageNoBookMark.length > 0) {
        	CONTENTVIEW_GENERAL.isSendingData = true;
        	CONTENTVIEW_CALLAPI.loadDataBookmark(lstPageNoBookMark);
        }
    }
};

/* check data has load */
CONTENTVIEW.checkDataLoaded = function(nPageNo, arrData) {
    var nIndex = -1;
    for (var n = 0; n < arrData.length; n++) {
        if (arrData[n].pageNo == nPageNo) {
            nIndex = n;
            break;
        }
    }
    return nIndex;
};

/* sort list bookmark */
CONTENTVIEW.sortBookmarkList = function() {
    var bmList = [];
    bmList = ClientData.BookMarkData();
    bmList.sort(function (a, b) {
        var a1 = a.pageNo, b1 = b.pageNo;
        if (a1 == b1) return 0;
        return a1 > b1 ? 1 : -1;
    });
    ClientData.BookMarkData(bmList);
};

/* create child node for list page index */
CONTENTVIEW.AddChidrenNode = function(nodeParent, data) {
    var dataChild = [];
    $.each(data, function (index, value) {
        if (data[index].parentID == nodeParent.id) {
            dataChild.push(data[index]);
        }
    });

    $.each(dataChild, function (i, value) {
        //add child node
        var item = new TreeNode();
        item.IsCategory = false;
        //item.Text = COMMON.htmlEncode(COMMON.truncateByBytes(dataChild[i].title,30));
        /* check data text */
        if (COMMON.getBytes(dataChild[i].title) > 30) {
            item.Text = COMMON.htmlEncode(COMMON.truncateByBytes(dataChild[i].title, 30)) + '...';
        } else {
            item.Text = COMMON.htmlEncode(dataChild[i].title);
        }
        item.id = dataChild[i].ID;
        item.Value = dataChild[i].destPageNumber;

        for (var nIndex = 0; nIndex < data.length; nIndex++) {
            if (data[nIndex].parentID == item.id) {
                item.IsCategory = true;
                break;
            }
        }

        CONTENTVIEW.AddChidrenNode(item, data);
        nodeParent.ChildNodes.push(item);

    });
};

CONTENTVIEW.copyText = function() {
    var w = window.open('contentview_textcopy.html');
};

/* handle data copy text */
CONTENTVIEW.handleCopyTextData = function(data, pos) {
    /* init var page text */
    var sPageText = '';
    var w = $("#wrapper").width() / 2 - $('#boxCopyText').width() / 2;
    var h = $("#wrapper").height() / 2 - $('#boxCopyText').height() / 2;

    for (var nIndex = 0; nIndex < data.length; nIndex++) {
        /* get text of current page */
        if (data[nIndex].pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())) {
            sPageText = COMMON.htmlEncode(data[nIndex].pageText);
            break;
        }
    }

    if (sPageText == '') {
        /* create data on dialog */
        $('#divCopyText').children().remove();
        $('#divCopyText').append('<li class="last">' + I18N.i18nText('txtNoTextCopy') + '</li>');

        //title start
        $('#bookmarkBoxHdCT').children().remove();
        $('#bookmarkBoxHdCT').html('<a id="copyTextClosing" class="delete" style="padding-top:0px;"> </a>');
        //$("#copyTextClosing").click(CONTENTVIEW_EVENTS.closeCopyTextBox);
        $("#copyTextClosing").on({
        	'click touchend': function(ev){
        		CONTENTVIEW_EVENTS.closeCopyTextBox(ev);
        		return false;
        	},
        	'touchstart touchmove': function(){
        		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
        		return false;
        	}
        });

        $('#bookmarkBoxHdCT').append(I18N.i18nText('txtTextCopy'));
        //title end

        //COMMON.lockLayout();
        $('#boxCopyText').css('z-index', '101');
        $('#boxCopyText').css('display', 'block');
        $('#boxCopyText').draggable({ handle: "h1" });
        $("#boxCopyText").offset({ left: w, top: h });
        $("#divCopyText").show();

    } else {
        /* create data on dialog */
        $('#divCopyText').children().remove();

        var strPattern = "\n";
        var strTemp = sPageText;
        strTemp = strTemp.replaceAll(strPattern, "<br/>");
        strTemp += "<br/>";

        $('#divCopyText').append('<div class="last" id="txtTextCopy" style="word-wrap:break-word;line-height: 20px">' + strTemp + '</div>');

        //title start
        $('#bookmarkBoxHdCT').children().remove();
        $('#bookmarkBoxHdCT').html('<a id="copyTextClosing" class="delete" style="padding-top:0px;"> </a>');
        //$("#copyTextClosing").click(CONTENTVIEW_EVENTS.closeCopyTextBox);
        $("#copyTextClosing").on({
        	'click touchend': function(ev){
        		CONTENTVIEW_EVENTS.closeCopyTextBox(ev);
        		return false;
        	},
        	'touchstart touchmove': function(){
        		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
        		return false;
        	}
        });

        $('#bookmarkBoxHdCT').append(I18N.i18nText('txtTextCopy'));
        //title end

        //COMMON.lockLayout();
        $('#boxCopyText').css('z-index', '101');
        $('#boxCopyText').css('display', 'block');
        //$('#boxCopyText').draggable({ handle: "h1" });
        $("#boxCopyText").offset({ left: w, top: h });
        $("#divCopyText").show();

        if (COMMON.isTouchDevice() == true) {
            document.getElementById('bookmarkBoxHdCT').addEventListener('touchstart', CONTENTVIEW.eventStart_CopyText, false);
            document.getElementById('bookmarkBoxHdCT').addEventListener('touchend', CONTENTVIEW.eventEnd_CopyText, false);
        } else {
            document.getElementById('bookmarkBoxHdCT').addEventListener('mousedown', CONTENTVIEW.eventStart_CopyText, false);
            document.getElementById('bookmarkBoxHdCT').addEventListener('mouseup', CONTENTVIEW.eventEnd_CopyText, false);
        }
    }
};

/* event touch start header copytext */
CONTENTVIEW.eventStart_CopyText = function(e) {
    e.preventDefault();
    $('#boxCopyText').draggable({ handle: "h1" });
};

/* event touch end header copytext */
CONTENTVIEW.eventEnd_CopyText = function(e) {
    e.preventDefault();
    $("#boxCopyText").draggable("destroy");

};

/* search content */
CONTENTVIEW.searchHandle = function() {
    var w = $("#main").width() - $(".hdRcolumn").width();

    var pos = [w, CONTENTVIEW.marginY];
    if ($('#txtSearch').val() != '') {
        var dataStored = CONTENTVIEW_GENERAL.arrThumbnailsLoaded;
        var contentPage = CONTENTVIEW_GENERAL.dataWebContentPage.pages;
        var myRegExp = new RegExp($('#txtSearch').val());
        var sPageNo = [];
        var lstPageNo = [];
        var isExistData = false;

        for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
            if (myRegExp.test(contentPage[nIndex].pageText)) {
                //searchResult.push(contentPage[nIndex]);
                sPageNo.push(contentPage[nIndex]);
            }
        }

        if (sPageNo.length > 0) {
            //title start
            $('#bookmarkBoxHdSearching').children().remove();
            $('#bookmarkBoxHdSearching').html('<a id="searchingResultClosing" class="delete" > </a>');
            $("#searchingResultClosing").click(CONTENTVIEW_EVENTS.closeSearchingBox);
            $('#bookmarkBoxHdSearching').append(I18N.i18nText('txtSearchResult'));
            //title end

            //COMMON.lockLayout();
            $('#boxSearching').css('z-index', '101');
            $('#boxSearching').css('display', 'block');
            $('#boxSearching').draggable({ handle: "h1" });
            $("#boxSearching").offset({ left: pos[0], top: pos[1] });
            $("#divSearchResult").show();
            $("#divSearchResult").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdSearching').height() - 2) });

            $('#divSearchResult').children().remove();

            for (var i = 0; i < sPageNo.length; i++) {
                var nStored = CONTENTVIEW.checkDataLoaded(sPageNo[i].pageNo, dataStored);
                if (nStored != -1) { /* data loaded */
                    $('#divSearchResult').append(
                        '   <li id="' + CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + '">' +
                        '       <img id="img_search_' + sPageNo[i].pageNo + '" class="imgbox" src="' + COMMON.formatStringBase64(dataStored[nStored].pageThumbnail) + '"/>' +
                        '       <span class="mdltext">' +
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + 1) + '<br /> ' +
                                    COMMON.htmlEncode(COMMON.truncate(sPageNo[i].pageText, 20)) +
                        '       </span>' +
                        '   </li>'
                    );

                    //Resize Image
                    var imgTemp = new Image();

                    imgTemp.onload = function () {
                        if (imgTemp.width > imgTemp.height) {
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };

                    imgTemp.src = COMMON.formatStringBase64(dataStored[nStored].pageThumbnail);
                } else {
                    $('#divSearchResult').append(
                        '   <li id="' + CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + '">' +
                        '       <img id="img_search_' + sPageNo[i].pageNo + '" class="imgbox" src="img/view_loading.gif"/>' +
                        '       <span class="mdltext">' +
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + 1) + '<br /> ' +
                                    COMMON.htmlEncode(COMMON.truncate(sPageNo[i].pageText, 20)) +
                        '       </span>' +
                        '   </li>'
                    );

                    //Resize Image
                    var imgTemp = new Image();

                    imgTemp.onload = function () {
                        if (imgTemp.width > imgTemp.height) {
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };

                    imgTemp.src = "img/view_loading.gif";

                    lstPageNo.push(sPageNo[i].pageNo);
                }
            }

            if (lstPageNo.length > 0) {
            	CONTENTVIEW_GENERAL.isSendingData = true;
            	CONTENTVIEW_CALLAPI.loadDataSearch(lstPageNo);
            }
        } else {
            $('#divSearchResult').children().remove();
            $('#divSearchResult').append('<span class="last">' + I18N.i18nText('txtNoSearchResult') + '</span>');

            //title start
            $('#bookmarkBoxHdSearching').children().remove();
            $('#bookmarkBoxHdSearching').html('<a id="searchingResultClosing" class="delete" > </a>');
            $("#searchingResultClosing").click(CONTENTVIEW_EVENTS.closeSearchingBox);
            $('#bookmarkBoxHdSearching').append(I18N.i18nText('txtSearchResult'));
            //title end

            //COMMON.lockLayout();
            $('#boxSearching').css('z-index', '101');
            $('#boxSearching').css('display', 'block');
            $('#boxSearching').draggable({ handle: "h1" });
            $("#boxSearching").offset({ left: pos[0], top: pos[1] });
            $("#divSearchResult").show();
            $("#divSearchResult").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdSearching').height() - 2) });
        }
    }
};

CONTENTVIEW.playBGMOfPage = function(page_index_bg) {
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
        if ($('#playaudiopage').children().length > 0) {
            $('#playaudiopage').children().remove();
        }
        CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, page_index_bg);
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '2') {
            	CONTENTVIEW.stopAllAudio();
            	CONTENTVIEW.TypeAudio2 = CONTENTVIEW_GENERAL.pageObjects[nIndex].playType;
                CONTENTVIEW.srcAudioType2 = CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile;

                if (ClientData.userOpt_musicMode() == "1") {
                    $('#playaudiopage').html(
                             '  <audio  id="play_audio_2" loop="loop" >' +
                             '       <source src="' + CONTENTVIEW.srcAudioType2 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                             '  </audio>'
                         );
                } else {

                    $('#playaudiopage').html(
                         '  <audio  id="play_audio_2"  >' +
                         '       <source src="' + CONTENTVIEW.srcAudioType2 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                         '  </audio>'
                     );
                }
                document.getElementById('play_audio_2').load();
                document.getElementById('play_audio_2').play();
                document.getElementById("play_audio_2").pause();
            }
        }
    }
};

CONTENTVIEW.playBGMOfContent = function() {
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() && CONTENTVIEW_GENERAL.isJumpNotFromFirstPage == true) {
    	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = false;
    	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
            	CONTENTVIEW.stopAllAudio();
            	CONTENTVIEW.TypeAudio1 = CONTENTVIEW_GENERAL.pageObjects[nIndex].playType;
                CONTENTVIEW.srcAudioType1 = CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile;

                if (ClientData.userOpt_musicMode() == "1") {
                    $('#playaudioallpage').html(
                         '  <audio  id="play_audio_1" loop="loop"   >' +
                         '       <source src="' + CONTENTVIEW.srcAudioType1 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                         '  </audio>'
                     );
                } else {

                    $('#playaudioallpage').html(
                     '  <audio  id="play_audio_1" >' +
                     '       <source src="' + CONTENTVIEW.srcAudioType1 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                     '  </audio>'
                 );
                }
                document.getElementById('play_audio_1').load();
                document.getElementById('play_audio_1').play();
                document.getElementById("play_audio_1").pause();
            }
        }
    }
};

/* display error screen*/
CONTENTVIEW.showErrorScreen = function() {

    // エラーメッセージの表示
    var errMes = I18N.i18nText('msgPageImgErr');
    $('#divImageLoading').css('display', 'none');
    COMMON.lockLayout();
    /* show error messages */
    $().toastmessage({ position: 'middle-center' });
    $().toastmessage('showToast', {
        type: 'error',
        sticky: true,
        text: errMes,
        close: function () { isShowErrorMessage = false; }
    });
    $('.toast-type-error').css('height', '100px');
    $('.toast-type-error > p').css('padding-top', '35px');

	//オーサリングプレビュー対応
	if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
		$('.toast-item-close').live('click', function(){
			window.open('', '_self', '');
			window.close();
		});
	} else {
		$('.toast-item-close').live('click', CONTENTVIEW_EVENTS.imgBack_click);
	}

};

/* display alert screen*/
CONTENTVIEW.showAlertScreen = function(errMes, scrMove) {

    // アラートメッセージの表示
    if( errMes == undefined || errMes == "" ){
        errMes = "message."; //I18N.i18nText('msgPageImgErr');
    }
    $('#divImageLoading').css('display', 'none');
    COMMON.lockLayout();
    /* show error messages */
    $().toastmessage({ position: 'middle-center' });
    $().toastmessage('showToast', {
        type: 'error',
        sticky: true,
        text: errMes,
        close: function () {}
    });
    $('.toast-type-error').css('height', '100px');
    $('.toast-type-error > p').css('padding-top', '35px');
    $('.toast-item-close').live('click',
        function () {
            COMMON.unlockLayout();
            if( scrMove ){
            	AVWEB.avwScreenMove(scrMove);
            }
        }
    );
};

/* move to page ?? */
CONTENTVIEW.changePage = function(page_index) {

    //abe スライダーのページ移動
    //console.log("changePage:" + page_index);

    // Make sure page_index is number
    page_index = Number(page_index);
	if( page_index < 0 ){
		page_index = 0;
	}

    if (page_index != CONTENTVIEW_GETDATA.getContent().pageIndex) {

    	CONTENTVIEW.playBGMOfContent();
        CONTENTVIEW.playBGMOfPage(page_index);

        CONTENTVIEW_GENERAL.disableAllControl();

        $('#divImageLoading').css('display', 'block');
        //Start Function : No.4 - Editor : Long - Date : 08/19/2013
        if(page_index == CONTENTVIEW_GETDATA.getContent().pageIndex + 1){
        	CONTENTVIEW_EVENTS.nextPage_click();
        }
        else if(page_index == CONTENTVIEW_GETDATA.getContent().pageIndex - 1){
        	CONTENTVIEW_EVENTS.prevPage_click();
        }
        //End Function : No.4 - Editor : Long - Date : 08/19/2013
        else{

            //ページ閲覧ログセット
            COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, page_index);

            // Clear canvas offscreen
            CONTENTVIEW_GENERAL.clearCanvas(document.getElementById("offscreen"));

            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){

            	//console.log("CONTENTVIEW.changePage");
            	AVWEB.avwGrabContentPageImage(ClientData.userInfo_accountPath(),
                     { contentId: CONTENTVIEW_GENERAL.contentID, sid: CONTENTVIEW.getSessionId(), pageNo: page_index + 1 },
                     function (data) {
                    	 CONTENTVIEW_GENERAL.pageImages = data;

                         /* get page Objects */
                    	 CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, page_index);
                         CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages)
                                     .setPageObjects(CONTENTVIEW_GENERAL.pageObjects);


                         //$('#divImageLoading').css('display', 'none');

                         var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
                         tran.flipToPage(page_index);

                     },
                     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){
                 /* get page Objects */
        	   CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, page_index);
                 CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages)
                             .setPageObjects(CONTENTVIEW_GENERAL.pageObjects);


                 $('#divImageLoading').css('display', 'none');

                var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
                tran.flipToPage(page_index);
            }
            //END : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
        }
    } else if (ClientData.IsJumpBack() == true
       || ClientData.common_prePageNo()) {
        CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages)
                                    .setPageObjects(CONTENTVIEW_GENERAL.pageObjects)
                                    .setUpPage(0);
       //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
    }
};

/* add event draw on canvas */
CONTENTVIEW.drawOnCanvas = function() {
	CONTENTVIEW_GENERAL.tool = new CONTENTVIEW.tool_drawing();
    if (COMMON.isTouchDevice() == true) {
    	CONTENTVIEW_PAINT.initializeCanvas(document.getElementById('draw_canvas'));
    	CONTENTVIEW_PAINT.initializeCanvas(document.getElementById('marker_canvas'));

        //iOSかAndroid以外ならmarkerではmouseも発火させる
        if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false){
            //draw_canvas
        	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
        	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
        	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
        	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
            //marker_canvas
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
        }

    }
    else {
        // Attach the mousedown, mousemove and mouseup event listeners.
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchstart', CONTENTVIEW.ev_canvas, false);
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchmove', CONTENTVIEW.ev_canvas, false);
    	CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchend', CONTENTVIEW.ev_canvas, false);

        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);

    }
};

CONTENTVIEW.drawMouseMove = function(contextDraw, ev) {
    if (CONTENTVIEW_GENERAL.tool.started && CONTENTVIEW_GENERAL.isPressLeftMouse == true) {

        if (CONTENTVIEW_GENERAL.isMoveOutDrawCanvas == true) {
            contextDraw.moveTo(ev._x, ev._y);
            CONTENTVIEW_GENERAL.sx = ev._x;
            CONTENTVIEW_GENERAL.sy = ev._y;
            CONTENTVIEW_GENERAL.isMoveOutDrawCanvas = false;
        }

        if (CONTENTVIEW_GENERAL.markingType == 'eraser') {
            //context.clearRect(ev._x, ev._y, ClientData.erase_size(), ClientData.erase_size());
            contextDraw.globalCompositeOperation = 'destination-out';
            contextDraw.lineWidth = CONTENTVIEW_GENERAL.eraseSize;
            contextDraw.lineJoin = 'round';
            contextDraw.lineCap = 'round';
            contextDraw.lineTo(CONTENTVIEW_GENERAL.sx, CONTENTVIEW_GENERAL.sy);
            contextDraw.stroke();
            contextDraw.globalCompositeOperation = 'source-over';
        }
        else if (CONTENTVIEW_GENERAL.markingType == 'pen') {
            contextDraw.lineCap = "round";
            contextDraw.lineJoin = "bevel";
            contextDraw.lineWidth = CONTENTVIEW_GENERAL.penSize;
            contextDraw.strokeStyle = "#" + CONTENTVIEW_GENERAL.penColor;
            contextDraw.lineTo(ev._x, ev._y);
            contextDraw.stroke();
        }
        else if (CONTENTVIEW_GENERAL.markingType == 'maker') {

            contextDraw.beginPath();

            var halfSize = CONTENTVIEW_GENERAL.makerSize / 2;
            var quotSize = CONTENTVIEW_GENERAL.makerSize / 4;

            var ptStart = [
                        { x: CONTENTVIEW_GENERAL.sx - quotSize, y: CONTENTVIEW_GENERAL.sy - halfSize },
                        { x: CONTENTVIEW_GENERAL.sx + quotSize, y: CONTENTVIEW_GENERAL.sy - halfSize },
                        { x: CONTENTVIEW_GENERAL.sx + quotSize, y: CONTENTVIEW_GENERAL.sy + halfSize },
                        { x: CONTENTVIEW_GENERAL.sx - quotSize, y: CONTENTVIEW_GENERAL.sy + halfSize }
                  ];
            var ptEnd = [
                        { x: ev._x - quotSize, y: ev._y - halfSize },
                        { x: ev._x + quotSize, y: ev._y - halfSize },
                        { x: ev._x + quotSize, y: ev._y + halfSize },
                        { x: ev._x - quotSize, y: ev._y + halfSize }
                ];
            if (CONTENTVIEW_GENERAL.sx > ev._x) {
                if (CONTENTVIEW_GENERAL.sy > ev._y) {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.closePath();
                } else if (CONTENTVIEW_GENERAL.sy < ev._y) {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.closePath();
                } else {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.closePath();
                }
            } else if (CONTENTVIEW_GENERAL.sx < ev._x) {
                if (CONTENTVIEW_GENERAL.sy > ev._y) {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.closePath();
                } else if (CONTENTVIEW_GENERAL.sy < ev._y) {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();

                    //
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.closePath();
                } else {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.closePath();
                }
            } else {
                if (CONTENTVIEW_GENERAL.sy > ev._y) {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.closePath();
                } else if (CONTENTVIEW_GENERAL.sy < ev._y) {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.closePath();
                } else {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
                    //
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.closePath();
                }
            }
            contextDraw.lineJoin = 'bevel';
            contextDraw.lineCap = 'butt';
            contextDraw.globalAlpha = 0.4;   // Opacity 20%
            contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
            contextDraw.fill();

            contextDraw.globalAlpha = 1;   // Opacity 100%
        }

        contextDraw.globalCompositeOperation = 'source-over';

        CONTENTVIEW_GENERAL.sx = ev._x;
        CONTENTVIEW_GENERAL.sy = ev._y;

    }
};


/* event mouse using for canvas */
CONTENTVIEW.tool_drawing = function() {
    var tool = this;
    this.started = false;

    this.mousedown = function (ev) {
        ev.preventDefault();

        /* set value sx,sy */
        CONTENTVIEW_GENERAL.sx = ev._x;
        CONTENTVIEW_GENERAL.sy = ev._y;

        if ($("#marker_canvas").is(":hidden")) {
        	CONTENTVIEW_GENERAL.context_draw.beginPath();
        	CONTENTVIEW_GENERAL.context_draw.moveTo(ev._x, ev._y);
        } else {
        	CONTENTVIEW_GENERAL.context_marker.beginPath();
        	CONTENTVIEW_GENERAL.context_marker.moveTo(ev._x, ev._y);
        }

        if (CONTENTVIEW_GENERAL.isAddingMarking == true) {
            /* begin draw*/
        	CONTENTVIEW_GENERAL.isClearDrawing = false;

            if ($("#marker_canvas").is(":hidden")) {
                if (CONTENTVIEW_GENERAL.markingType == 'eraser') {
                	CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'destination-out';
                	CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.eraseSize;
                	CONTENTVIEW_GENERAL.context_draw.lineJoin = 'round';
                	CONTENTVIEW_GENERAL.context_draw.lineCap = 'round';
                	CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x + 0.001, ev._y + 0.001);
                	CONTENTVIEW_GENERAL.context_draw.stroke();
                	CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'source-over';
                }
                else if (CONTENTVIEW_GENERAL.markingType == 'pen') {
                    /* set flag */
                	CONTENTVIEW_GENERAL.isDrawing = true;

                	CONTENTVIEW_GENERAL.context_draw.lineCap = "round";
                	CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.penSize;
                	CONTENTVIEW_GENERAL.context_draw.strokeStyle = "#" + CONTENTVIEW_GENERAL.penColor;
                	CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x + 0.001, ev._y + 0.001);
                	CONTENTVIEW_GENERAL.context_draw.stroke();
                }
                else if (CONTENTVIEW_GENERAL.markingType == 'maker') {
                    /* set flag */
                	CONTENTVIEW_GENERAL.isDrawing = true;

                	CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'destination-out';
                	CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                	CONTENTVIEW_GENERAL.context_draw.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                	CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x, ev._y + 0.001);
                	CONTENTVIEW_GENERAL.context_draw.lineCap = 'square';
                	CONTENTVIEW_GENERAL.context_draw.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                	CONTENTVIEW_GENERAL.context_draw.stroke();
                	CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'lighter';

                	CONTENTVIEW_GENERAL.context_draw.lineCap = "square";
                	CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                	CONTENTVIEW_GENERAL.context_draw.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                	CONTENTVIEW_GENERAL.context_draw.globalAlpha = 0.4;
                	CONTENTVIEW_GENERAL.context_draw.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                	CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x, ev._y + 0.001);
                	CONTENTVIEW_GENERAL.context_draw.stroke();
                	CONTENTVIEW_GENERAL.context_draw.globalAlpha = 1;
                }
            } else {
                if (CONTENTVIEW_GENERAL.markingType == 'eraser') {
                	CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'destination-out';
                	CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.eraseSize;
                	CONTENTVIEW_GENERAL.context_marker.lineJoin = 'round';
                	CONTENTVIEW_GENERAL.context_marker.lineCap = 'round';
                	CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x + 0.001, ev._y + 0.001);
                	CONTENTVIEW_GENERAL.context_marker.stroke();
                	CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'source-over';
                }
                else if (CONTENTVIEW_GENERAL.markingType == 'pen') {
                    /* set flag */
                	CONTENTVIEW_GENERAL.isDrawing = true;

                    CONTENTVIEW_GENERAL.context_marker.lineCap = "round";
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.penSize;
                    CONTENTVIEW_GENERAL.context_marker.strokeStyle = "#" + CONTENTVIEW_GENERAL.penColor;
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x + 0.001, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.stroke();
                }
                else if (CONTENTVIEW_GENERAL.markingType == 'maker') {
                    /* set flag */
                	CONTENTVIEW_GENERAL.isDrawing = true;

                    CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'destination-out';
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.lineCap = 'square';
                    CONTENTVIEW_GENERAL.context_marker.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    CONTENTVIEW_GENERAL.context_marker.stroke();
                    CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'lighter';

                    CONTENTVIEW_GENERAL.context_marker.lineCap = "square";
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.globalAlpha = 0.4;
                    CONTENTVIEW_GENERAL.context_marker.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.stroke();
                    CONTENTVIEW_GENERAL.context_marker.globalAlpha = 1;
                }
            }
            tool.started = true;

            if (ev.which == 1) { CONTENTVIEW_GENERAL.isPressLeftMouse = true; }
        }

        //CONTENTVIEW_GENERAL.context_draw.closePath();
    };

    this.mousemove = function (ev) {
        ev.preventDefault();
        if (CONTENTVIEW_GENERAL.isAddingMarking == true) {
            if ($("#marker_canvas").is(":hidden")) {
            	CONTENTVIEW.drawMouseMove(CONTENTVIEW_GENERAL.context_draw, ev);
            } else {
            	CONTENTVIEW.drawMouseMove(CONTENTVIEW_GENERAL.context_marker, ev);
            }

        }
    };

    this.mouseup = function (ev) {
        if (tool.started) {
            //tool.mousemove(ev);
            tool.started = false;
            //CONTENTVIEW_GENERAL.context_draw.closePath();
            //CONTENTVIEW_GENERAL.isPressLeftMouse = false;
        }
    };

    this.mouseout = function (ev) {

        if (tool.started) {
            //tool.mousemove(ev);
            //tool.started = false;
            //CONTENTVIEW_GENERAL.context_draw.closePath();
        	CONTENTVIEW_GENERAL.isMoveOutDrawCanvas = true;
        }

        /*if(CONTENTVIEW_GENERAL.isPressLeftMouse == true){
        CONTENTVIEW_GENERAL.isMoveOutDrawCanvas = true;
        }else{
        tool.started = false;
        }*/
    };

    /*tablet [start]*/
    this.touchstart = function (ev) {
        /*ev.preventDefault();
        tool.mousedown(ev);*/
        var touches = ev.changedTouches, first = touches[0], type = "";

        switch (ev.type) {
            case "touchstart": type = "mousedown"; break;
            case "touchmove": type = "mousemove"; break;
            case "touchend": type = "mouseup"; break;
            default: return;
        }

        var simulatedEvent = document.createEvent("MouseEvent");

        simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
        first.target.dispatchEvent(simulatedEvent);

        ev.preventDefault();

    };

    this.touchmove = function (ev) {
        /*ev.preventDefault();
        tool.mousemove(ev);*/
        var touches = ev.changedTouches, first = touches[0], type = "";

        switch (ev.type) {
            case "touchstart": type = "mousedown"; break;
            case "touchmove": type = "mousemove"; break;
            case "touchend": type = "mouseup"; break;
            default: return;
        }

        var simulatedEvent = document.createEvent("MouseEvent");

        simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
        first.target.dispatchEvent(simulatedEvent);

        ev.preventDefault();

    };

    this.touchend = function (ev) {
        /*ev.preventDefault();
        tool.mouseup(ev);*/
        var touches = ev.changedTouches, first = touches[0], type = "";

        switch (ev.type) {
            case "touchstart": type = "mousedown"; break;
            case "touchmove": type = "mousemove"; break;
            case "touchend": type = "mouseup"; break;
            default: return;
        }

        var simulatedEvent = document.createEvent("MouseEvent");

        simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
        first.target.dispatchEvent(simulatedEvent);
        ev.preventDefault();


    };
    /* tablet [end]*/

};

CONTENTVIEW.ev_canvas = function(ev) {
    if (ev.offsetX || ev.offsetX == 0) { // Opera
        ev._x = ev.offsetX;
        ev._y = ev.offsetY;
    } else if (ev.layerX || ev.layerX == 0) { // Firefox
        ev._x = ev.layerX;
        ev._y = ev.layerY;
    }

    // Call the event handler of the tool.
    //var func = tool[ev.type];
    var func = CONTENTVIEW_GENERAL.tool[ev.type]; // CONTENTVIEW_GENERAL.toolで良いか？
    if (func) {
        func(ev);
    }
};

/* handle display page from book mark page */
CONTENTVIEW.handleFromBookMarkPage = function() {

	//CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
    /* check exist pageno */
    if (ClientData.bookmark_pageNo()) {
    	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
    	CONTENTVIEW.changePageWithoutSlide(CONTENTVIEW.changePageNo(ClientData.bookmark_pageNo()));
        ClientData.bookmark_pageNo(null)
    }
};

/* handle display page from actiontype=10 mediaType =1 :jump to content */
CONTENTVIEW.handleFromJumpContent = function() {

	//CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
    /* check exist pageno */
    if (ClientData.common_prePageNo()) {
    	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
    	CONTENTVIEW.changePageWithoutSlide(CONTENTVIEW.changePageNo(ClientData.common_prePageNo()));
        ClientData.common_prePageNo(null)
    }
};

/* handle button back */
CONTENTVIEW.oldContent_Back = function() {

	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;

    var oldDataBack = ClientData.JumpQueue();
    var oldContent = oldDataBack[oldDataBack.length - 1];

    /*move to page */
    //CONTENTVIEW.changePage(oldContent.oldPageIndex);
    CONTENTVIEW.changePageWithoutSlide(oldContent.oldPageIndex);

    /*remove*/
    oldDataBack.splice(oldDataBack.length - 1, 1);
    ClientData.JumpQueue(oldDataBack);
    ClientData.IsJumpBack(false);


};

/* handle display or hide toolbar */
CONTENTVIEW.handleDisplayToolbar = function() {

	//console.log("CONTENTVIEW_GENERAL.isLoadingObject:" + CONTENTVIEW_GENERAL.isLoadingObject);

    if (CONTENTVIEW_GENERAL.isLoadingObject == false) {
        /* save marking */
        var canvas = document.getElementById('draw_canvas');
        var context = canvas.getContext('2d');

        if (ClientData.IsAddingMarking() == true) {
        	CONTENTVIEW_GENERAL.imgDrawingTemp = canvas.toDataURL("image/png");
        	CONTENTVIEW_GENERAL.imgMarkerTemp = CONTENTVIEW_GENERAL.canvas_marker.toDataURL("image/png;")
        }

        var w = $("#wrapper").width();
        var h = $("#wrapper").height();

        if ($("#header_toolbar").is(":hidden")) {

        	CONTENTVIEW_GENERAL.isFullScreen = false;

            $('#footer_toolbar_1').show();
            $('#footer_toolbar_2').hide();
            $('#control_screen_2').hide();
            $('#header_toolbar').show();
            CONTENTVIEW.sizingNotFull(w, h);
            CONTENTVIEW.drawCanvas();

            //edit
            if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
            	CONTENTVIEW.drawCanvas(2);
            }

            if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
            	CONTENTVIEW.drawCanvas(1);
            }

        }
        else {

        	CONTENTVIEW_GENERAL.isFullScreen = true;

            $('#header_toolbar').hide();
            //START TRB00097
            //$('#footer_toolbar_2').show();
            //END TRB00097
            $('#control_screen_2').show();
            $('#footer_toolbar_1').hide();
            CONTENTVIEW.sizingFullSize(w, h);

            CONTENTVIEW.drawCanvas();

            if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
            	CONTENTVIEW.drawCanvas(2);
            }

            if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
            	CONTENTVIEW.drawCanvas(1);
            }

        }
        /* init image had draw */
        //CONTENTVIEW_INITOBJECT.initDisplayMarking();
        CONTENTVIEW.resizeCanvasDraw();

        if (ClientData.IsAddingMarking() == true) {
            var img = new Image();
            img.onload = function () {
                context.drawImage(img, 0, 0, canvas.width, canvas.height);
            };
            img.src = CONTENTVIEW_GENERAL.imgDrawingTemp;

            var imgMarker = new Image();
            imgMarker.onload = function () {
            	CONTENTVIEW_GENERAL.context_marker.drawImage(imgMarker, 0, 0, CONTENTVIEW_GENERAL.canvas_marker.width, CONTENTVIEW_GENERAL.canvas_marker.height);
            };
            img.src = CONTENTVIEW_GENERAL.imgMarkerTemp;

        }
    }

    CONTENTVIEW.closeDialogPopUpText();
};

/* resizing canvas draw */
CONTENTVIEW.resizeCanvasDraw = function() {
	CONTENTVIEW.flip();
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
        $("#draw_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);

        $("#marker_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);

    } else {
        $("#draw_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);
        $("#marker_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);

    }
};

/* handle slider bar */
CONTENTVIEW.handleSliderBar = function() {

    $("#slider_page").slider({
        range: "max",
        min: 1,
        max: CONTENTVIEW_GENERAL.totalPage,
        value: CONTENTVIEW_GETDATA.getPageIndex() + 1,
        slide: function (event, ui) {
            $("#txtSlider").val(ui.value);
            //CONTENTVIEW.changePage(ui.value - 1);
        },
        stop: function (event, ui) {
        	CONTENTVIEW.changePage(ui.value - 1);
        }

    });


    $("#txtSlider").val($("#slider_page").slider("value"));

    /* event change txtProcess */
    $('#txtSlider').keydown(function (event) {
        if (event.keyCode == 13) {

        	var pageNo = parseInt($('#txtSlider').val());
        	if(isNaN(pageNo)){
        		pageNo = 1;
        	}
        	if(pageNo == 0){
        		pageNo = 1;
        	}

            if (pageNo <= 0) {
                $('#txtSlider').val('1');
            } else if (pageNo > CONTENTVIEW_GENERAL.totalPage) {
                $('#txtSlider').val(CONTENTVIEW_GENERAL.totalPage);
            } else if (/\D/g.test($('#txtSlider').val())) {
                $('#txtSlider').val('1');
            } else {
                $('#txtSlider').val(pageNo);
            }

            if (parseInt($('#txtSlider').val()) - 1 != CONTENTVIEW_GETDATA.getPageIndex()) {
                $("#slider_page").slider("value", $('#txtSlider').val());
                CONTENTVIEW.changePage($('#txtSlider').val() - 1);
            }
        }
        else {

        }
    });
};

/* event when change page */
CONTENTVIEW.changeSlider = function(page_index) {
    $("#slider_page").slider("value", page_index + 1);
    $("#txtSlider").val(page_index + 1);
};

/* handle display value tooltip */
CONTENTVIEW.handleTooltip = function() {
    /*$('#imgHome').attr('title', I18N.i18nText('dspHome'));
    $('#imgBack').attr('title', I18N.i18nText('txtTooltipBack'));
    $('#listbookmark').attr('title', I18N.i18nText('txtShioriCtnLs'));
    $('#imgbookmark').attr('title', I18N.i18nText('txtTooltipBookmark'));
    $('#listindex').attr('title', I18N.i18nText('txtIndex'));
    $('#copytext').attr('title', I18N.i18nText('txtTextCopy'));
    $('#imgmemo').attr('title', I18N.i18nText('txtTooltipShowMemo'));
    $('#imgaddmemo').attr('title', I18N.i18nText('txtTooltipAddMemo'));
    $('#imgmarking').attr('title', I18N.i18nText('txtTooltipShowMarking'));
    $('#imgmarkingtoolbar').attr('title', I18N.i18nText('txtTooltipShowMarkingTool'));       */
};

CONTENTVIEW.StartTimerUpdateLog = function() {
    /* set end log */
    COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
    setTimeout("CONTENTVIEW.StartTimerUpdateLog();", 1000);
};

/* check status image show toolbar marking */
CONTENTVIEW.checkStatusImageMarking = function() {
    if (ClientData.serviceOpt_marking() == 'Y') {
        $('#imgmarkingtoolbar').bind('click', CONTENTVIEW.handleDrawCanvas);
    } else {
        $('#imgmarkingtoolbar').unbind('click');
    }
};

CONTENTVIEW.resizeScreen = function() {
    /* save marking */
    var canvas = document.getElementById('draw_canvas');
    var context = canvas.getContext('2d');

    if (ClientData.IsAddingMarking() == true) {
    	CONTENTVIEW_GENERAL.imgDrawingTemp = canvas.toDataURL("image/png");
    	CONTENTVIEW_GENERAL.imgMarkerTemp = CONTENTVIEW_GENERAL.canvas_marker.toDataURL("image/png"); ;
    }

    CONTENTVIEW.sizingScreen();
    CONTENTVIEW.resizeCanvasDraw();
    CONTENTVIEW.drawCanvas();

    if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
    	CONTENTVIEW.drawCanvas(2);
    }

    if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
    	CONTENTVIEW.drawCanvas(1);
    }

    if (ClientData.IsAddingMarking() == true) {
        var img = new Image();
        img.onload = function () {
            context.drawImage(img, 0, 0, canvas.width, canvas.height);
        };
        img.src = CONTENTVIEW_GENERAL.imgDrawingTemp;

        var imgMarker = new Image();
        imgMarker.onload = function () {
        	CONTENTVIEW_GENERAL.context_marker.drawImage(imgMarker, 0, 0, CONTENTVIEW_GENERAL.canvas_marker.width, CONTENTVIEW_GENERAL.canvas_marker.height);
        };
        imgMarker.src = CONTENTVIEW_GENERAL.imgMarkerTemp;

    }

    // resize anket
    CONTENTVIEW_ANKET.resizeAnket();
};


CONTENTVIEW.changePageWithoutSlide = function(pageMove) {

    //abe コンテンツリンクで移動時
    //console.log("changePageWithoutSlide:" + pageMove);
    //ページ閲覧ログセット
    COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, pageMove);

    CONTENTVIEW_GENERAL.disableAllControl();
    var isExistBGMPageContent = false;
    CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove);
    for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
        if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '2') {
            isExistBGMPageContent = true;
        }
    }

    if (isExistBGMPageContent == false) {
    	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
            	CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile, CONTENTVIEW_GENERAL.pageObjects[nIndex].playType);
            }
        }
    }
    //START TRB00069
    else{
    	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
            	CONTENTVIEW.isPendingContentBGM = true;
                if(pageMove > 0){
                	CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile, CONTENTVIEW_GENERAL.pageObjects[nIndex].playType);
                }
            }
        }
    }
    //END TRB00069

    $('#divImageLoading').css('display', 'block');

    // Clear canvas offscreen
    CONTENTVIEW_GENERAL.clearCanvas(document.getElementById("offscreen"));

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){

    	//console.log("CONTENTVIEW.changePageWithoutSlide");
    	AVWEB.avwGrabContentPageImage(ClientData.userInfo_accountPath(),
             { contentId: CONTENTVIEW_GENERAL.contentID, sid: CONTENTVIEW.getSessionId(), pageNo: pageMove + 1 },
             function (data) {
            	 CONTENTVIEW_GENERAL.pageImages = data;

                 /* get page Objects */
            	 CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove);
                 CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);

                 $('#divImageLoading').css('display', 'none');

                 CONTENTVIEW_GENERAL.isFirstLoad = true;
                 // CONTENTVIEW.screenFit();

                 CONTENTVIEW_GETDATA.getContent().toPage(pageMove);

                 //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

                 //Start FUnciton: No.4 - Editor : Long - Date : 08/12/2013 - Summary : Handle jump from bookmark page
                 if(pageMove > 0){
                     //START TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
                	 CONTENTVIEW_GENERAL.prevContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
                     //END TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
                	 CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove - 1);
                     CONTENTVIEW_GETDATA.renderPrevPage();
                 }

                 if(pageMove < CONTENTVIEW_GENERAL.totalPage - 1){
                     //START TRB00056
                	 CONTENTVIEW_GENERAL.nextContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
                     //END TRB00056
                	 CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove + 1);
                     CONTENTVIEW_GETDATA.renderNextPage();
                 }

                 //End Function : No.4 - Editor : Long - Date: 08/12/2013 - Summary : Handle jump form bookmark page

                 /* handle slider bar */
                 CONTENTVIEW.handleSliderBar();

                 if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove]) {
                     if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove] != '') {
                         document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[pageMove] + ' | ' + I18N.i18nText('sysAppTitle');
                     } else {
                         document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                     }
                 } else {
                     document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                 }

             },
             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){
        /* get page Objects */
    	CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove);
         CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);

         $('#divImageLoading').css('display', 'none');

         CONTENTVIEW_GENERAL.isFirstLoad = true;
         // CONTENTVIEW.screenFit();

         CONTENTVIEW_GETDATA.getContent().toPage(pageMove);
         //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

         //Start FUnciton: No.4 - Editor : Long - Date : 08/12/2013 - Summary : Handle jump from bookmark page
         if(pageMove > 0){

             //START TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
        	 CONTENTVIEW_GENERAL.prevContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
             //END TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
        	 CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove - 1);
             CONTENTVIEW_GETDATA.renderPrevPage();
         }

         if(pageMove < CONTENTVIEW_GENERAL.totalPage - 1){

             //START TRB00056
        	 CONTENTVIEW_GENERAL.nextContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
             //END TRB00056

        	 CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove + 1);
             CONTENTVIEW_GETDATA.renderNextPage();
         }

         //End Function : No.4 - Editor : Long - Date: 08/12/2013 - Summary : Handle jump form bookmark page

         /* handle slider bar */
         CONTENTVIEW.handleSliderBar();

         if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove]) {
             if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove] != '') {
                 document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[pageMove] + ' | ' + I18N.i18nText('sysAppTitle');
             } else {
                 document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
             }
         } else {
             document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
         }
    }
    //END : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
};

/* set position model when resize*/
CONTENTVIEW.changePosDialog = function() {
    $("#divDialogMemo").center();
    /*$("#divDialogMemo").css('position', 'absolute');*/
    $("#boxBookMark").center();
    $("#boxIndex").center();
    $("#boxCopyText").center();
    $("#boxSearching").center();
    $("#boxAddMemo").center();
    $('#dlgPen').center();
    $('#dlgMaker').center();
    $('#dlgGomu').center();
    $('#dlgMarking').center();
    $('#bgmConfirm').center();
    $("#bgmConfirm_page").center();
};

CONTENTVIEW.closeDialogResize = function() {
	CONTENTVIEW.closeDialogPopUpText();

    $('#pop_up_memo').hide();
};

//Start Function : No.12

//START TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog
CONTENTVIEW.displayOverlayForHtmlAndMediaType = function(){
    var $overlay = $('#overlay');
    var $header = $('header');
    var $footer = $('footer');

    $header.css('position', 'absolute');
    $header.css('width', '100%');
    $header.css('z-index', '102');
    $footer.css('z-index', '102');
    $overlay.show();

    //START TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog
    document.getElementById('overlay').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
    document.getElementById('overlay').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
    document.getElementById('overlay').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);
    //END TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog

};
//END TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog

//Display overlay dialog for specify content type
CONTENTVIEW.displayOverlayForSpecifyContentType = function( resourceUrl ){

    var contentId = ClientData.contentInfo_contentId();
    if( resourceUrl == null ){
    	resourceUrl = CONTENTVIEW.downloadResourceById(contentId);
    }

    //CONTENTVIEW_GENERAL.contentType = COMMON.ContentTypeKeys.Type_Html;
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music){
    	CONTENTVIEW.handleForContentTypeMusic(resourceUrl);
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){
    	CONTENTVIEW.handleForContentTypeVideo(resourceUrl);
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){

        //DHカスタム
        var linkUrlTmp = resourceUrl;
        //DHカスタム
        if( ClientData.serviceOpt_daihatsu() == 'Y'){
            var apiUrl = AVWEB.getApiUrl(ClientData.userInfo_accountPath());
            linkUrlTmp = linkUrlTmp + "?sid=" + CONTENTVIEW.getSessionId() + "&apiurl=" + apiUrl ;
        }
        CONTENTVIEW.handleForContentTypeHTML(linkUrlTmp);
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam){
    	CONTENTVIEW.handleForContentTypeExam(resourceUrl);
    } else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Enquete){
    	CONTENTVIEW.handleForContentTypeEnquete(resourceUrl);
    }
    if (COMMON.isTouchDevice() == true) {
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
        	CONTENTVIEW_GENERAL.standardRatio = document.documentElement.clientWidth / window.innerWidth;
            ZOOM_DETECTOR.startDetectZoom({ time: 500,
                callbackFunction: function (oldRatio, newRatio, oldW, oldH, newW, newH) {
                	CONTENTVIEW_GENERAL.currentRatio = newRatio;

                }
            });
            var top = window.innerHeight - $("#footer_toolbar_1").height();
            $("#wrapper").css("width", window.innerWidth);
            $("#wrapper").css("height", window.innerHeight);
            $("#footer_toolbar_1").css("top", top + "px");
            $("#footer_toolbar_2").css("top", top + "px");
            CONTENTVIEW.sizingScreen();
        }

    }

    //Start : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.
    CONTENTVIEW.setViewportForWin8();
    //End : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.

    //Start : TRB00075 - Editor : Long - Date : 09/25/2013 - Summary : prevent moving page
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
    	CONTENTVIEW.displayOverlayForHtmlAndMediaType();
    }
    //End : TRB00075 - Editor : Long - Date : 09/25/2013 - Summary : prevent moving page
    /* window resize event */
    $(window).resize(function () {

        //CONTENTVIEW.sizingScreen();
        //START : TRB00034 - DATE : 09/11/2013 - Editor : Long  - Summary : Fix for center loading image
    	CONTENTVIEW_INITOBJECT.setLoadingSize();
        //END : TRB00034 - DATE : 09/11/2013 - Editor : Long  - Summary : Fix for center loading image
        if (COMMON.isTouchDevice() == true) {
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
                var tempRatio = document.documentElement.clientWidth / window.innerWidth;
                if (tempRatio <= 1) {
                    // Adjust position for toolbar and footer bar
                    var top = window.innerHeight - $("#footer_toolbar_1").height();
                    $("#wrapper").css("width", window.innerWidth);
                    $("#wrapper").css("height", window.innerHeight);
                    $("#footer_toolbar_1").css("top", top + "px");
                    $("#footer_toolbar_2").css("top", top + "px");
                }
                else {
                    var top = $(window).height() - $("#footer_toolbar_1").height();
                    $("#wrapper").css("width", $(window).width());
                    $("#wrapper").css("height", $(window).height());
                    $("#footer_toolbar_1").css("top", top + "px");
                    $("#footer_toolbar_2").css("top", top + "px");
                }
            }
        }
        CONTENTVIEW.sizingScreen();

        //Start : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.
        CONTENTVIEW.setViewportForWin8();
        //End : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.

        CONTENTVIEW_GENERAL.isChangeSizeScreen = false;

        /* change position dialog */
        CONTENTVIEW.changePosDialog();

        /* close dialog popuptext */
        CONTENTVIEW.closeDialogResize();

        //START TRB00091 - Editor : LOng - Date : 09/26/2013 - Summary : Dialog at center when rotate
        $("#contentVideoConfirm").center();
        $("#contentAudioConfirm").center();
        //END TRB00091 - Editor : LOng - Date : 09/26/2013 - Summary : Dialog at center when rotate

    });
};

//handle for content type = video
CONTENTVIEW.handleForContentTypeVideo = function(resourceUrl){

    //Create Dialog overlay
    var $container = $('#dialog');

    $container.html('');

    if (ClientData.userOpt_musicMode() == "1") {
            $container.html('<video id="content_video" autoplay="true" loop="true" controls="controls" style="position: absolute; width: 100%; height: 100%;">'
            + '     <source src="' + resourceUrl + '" type="video/mp4"> '
            + '</video>'
            );
    }
    else {
        $container.html('<video id="content_video" autoplay="true" controls="controls" style="position: absolute; width: 100%; height: 100%;">'
        + '     <source src="' + resourceUrl + '" type="video/mp4"> '
        + '</video>'
        );
    }

    //START TRB00068
    // Check to play Video on ipad
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
        // Show confim message to play background music
        $("#contentVideoConfirm").css('z-index', 999);
        $("#contentVideoConfirm_OK").unbind('click');
        $("#contentVideoConfirm_OK").click(function () {

            var myVideo=document.getElementById("content_video");
            if (myVideo.paused)
            {
                myVideo.play();
            }

            $container.show();
            $("#contentVideoConfirm").hide();
            CONTENTVIEW.isShowVideoContent = true;
        });
        $("#contentVideoConfirm").show();
        $("#contentVideoConfirm").center();
    }
    else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
        // Show confim message to play background music
        $("#contentVideoConfirm").css('z-index', 999);
        $("#contentVideoConfirm_OK").unbind('click');
        $container.show();
        $("#contentVideoConfirm_OK").click(function () {

            var myVideo=document.getElementById("content_video");
            if (myVideo.paused)
            {
            	myVideo.play();
            }

            $("#contentVideoConfirm").hide();
            CONTENTVIEW.isShowVideoContent = true;
        });
        $("#contentVideoConfirm").show();
        $("#contentVideoConfirm").center();
    }
    else{
        $container.show();
    }
    //END TRB00068
};

//handle for content type = music
CONTENTVIEW.handleForContentTypeMusic = function(resourceUrl){

    //Create Dialog overlay
    var $container = $('#dialog');
    $container.html('');

    //START FIX CSS
    //$container.css('background', 'url(./img/iPad_music.png) center center no-repeat');
    //$container.css('background-color', 'white');
    $container.addClass('dialog-content-music');
    //END FIX CSS

    if (ClientData.userOpt_musicMode() == "1") {
        $container.html('<audio autoplay="true" loop="true" controls="controls" style="position: absolute; width: 100%; bottom: 1%;">'
        + '     <source src="' + resourceUrl + '" type="audio/mpeg"> '
        + '</audio>'
        );
    }
    else {
        $container.html('<audio autoplay="true" controls="controls" style="position: absolute; width: 100%; bottom: 1%;">'
        + '     <source src="' + resourceUrl + '" type="audio/mpeg"> '
        + '</audio>'
        );
    }

    if(CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox'){
        $container.find('audio').css('height', '30px');
    }

    $container.show();

    //START TRB00068
    // Check to play BGM on ipad
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
        // Show confim message to play background music
        $("#contentAudioConfirm").css('z-index', 999);
        $("#contentAudioConfirm_OK").unbind('click');
        $("#contentAudioConfirm_OK").click(function () {

            $("#contentAudioConfirm").hide();
            $("#dialog").find('audio').load();
            $("#dialog").find('audio').play();
        });
        $("#contentAudioConfirm").show();
        $("#contentAudioConfirm").center();
    }
    //END TRB00068
};

//handle for content type = html
CONTENTVIEW.handleForContentTypeHTML = function(resourceUrl){
     //Create Dialog overlay
    var $container = $('#dialog');

    $container.html('');
    $container.css('left','0%');
    $container.css('width','100%');
    $container.css('background-color','white');

    //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

       $container.css('overflow', 'scroll');
       $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else{
        $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
         $container.css('overflow', 'hidden');
    }
    //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
    $container.show();
};

CONTENTVIEW.handleForContentTypeExam = function(resourceUrl){
    //Create Dialog overlay
   var $container = $('#dialog');

   $container.html('');
   $container.css('left','0%');
   $container.css('width','100%');
   $container.css('background-color','white');

   //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
      $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

      $container.css('overflow', 'scroll');
      $container.css('-webkit-overflow-scrolling', 'touch');
   }
   else{
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
       $container.css('overflow', 'hidden');
   }
   //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   $container.show();
};

CONTENTVIEW.handleForContentTypeEnquete = function(resourceUrl){
    //Create Dialog overlay
   var $container = $('#dialog');

   $container.html('');
   $container.css('left','0%');
   $container.css('width','100%');
   $container.css('background-color','white');

   //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
      $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

      $container.css('overflow', 'scroll');
      $container.css('-webkit-overflow-scrolling', 'touch');
   }
   else{
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
       $container.css('overflow', 'hidden');
   }
   //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   $container.show();
};

//Check type of content
CONTENTVIEW.isMediaAndHTMLContent = function(){
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video ||
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){
        return true;
    }
    else{
        return false;
    }
};

//Enable Specify Control
CONTENTVIEW.enableSpecifyControl = function(){

    //Disable All control
	CONTENTVIEW_GENERAL.disableAllControl();

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music ||
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){

    	CONTENTVIEW.enableControlForMediaAndHtmlType();
    }
};

//Enable Control for video, audio, html type.
CONTENTVIEW.enableControlForMediaAndHtmlType = function(){
    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'pointer');
    $("#imgBack").css('cursor', 'pointer');

    $("#control_screen").removeClass();
    $("#control_screen_2").removeClass();

    $('#imgHome').bind('click', CONTENTVIEW_EVENTS.imgHome_click);
    $('#imgHome').removeClass();

    $('#imgBack').bind('click', CONTENTVIEW_EVENTS.imgBack_click);
    $('#imgBack').removeClass();

    $("#control_screen").bind('click', CONTENTVIEW.fullScreenForNotPdfType);
    $("#control_screen_2").bind('click', CONTENTVIEW.originalScreenForNotPdfType);

    if (COMMON.isTouchDevice() == true) {/* set css for device */
        $('#imgHome').addClass('home_device');
        $('#imgBack').addClass('back_device');

        $("#control_screen").addClass('toolbar_device');
        //$("#control_screen_2").addClass('toolbar_device');
        $("#control_screen_2").addClass('toolbar_close_device');

    } else { /* set css for PC */
        $('#imgHome').addClass('home');
        $('#imgBack').addClass('back');

        $("#control_screen").addClass('toolbar');
        $("#control_screen_2").addClass('toolbar_close');
    }

    //getits対応
    if( ClientData.isGetitsMode() == true ){
        $('#imgHome').unbind('click');
        $('#imgHome').removeClass();
        $('#imgHome').addClass('home_off');

        /* back button */
        $('#imgBack').unbind('click');
        $('#imgBack').removeClass();
        $('#imgBack').addClass('back_off');
    }

};

//Full screen function for not pdf type
CONTENTVIEW.fullScreenForNotPdfType = function(){

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){
        if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
            $('#content_video').removeAttr('controls');
        }
    }

    var $container = $('#dialog');

    $('#header_toolbar').hide();
    //START TRB00097
    //$('#footer_toolbar_2').show();
    //END TRB00097
    $('#control_screen_2').show();
    $('#footer_toolbar_2').css('z-index', '999');
    $('#control_screen_2').css('z-index', '999');
    $('#footer_toolbar_1').hide();

    $container.css('top', '0%')
              .css('left', '0%')
              .css('height', '100%')
              .css('width', '100%');
    //$container.attr('style', 'top: 0; left: 0; height: 100%; width: 100%;');

    CONTENTVIEW.isZoomingContent = true;
    CONTENTVIEW_GENERAL.isFullScreen = true;
};

//Original screen for not pdf type
CONTENTVIEW.originalScreenForNotPdfType = function(){
    $('#footer_toolbar_2').css('z-index', '');
    $('#control_screen_2').css('z-index', '');
    $('#footer_toolbar_1').show();
    $('#footer_toolbar_2').hide();
    $('#control_screen_2').hide();
    $('#header_toolbar').show();

    var $container = $('#dialog');
    $container.removeAttr('style');

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music){
        $container.css('background', 'url(./img/iPad_music.png) center no-repeat');
        $container.css('background-color', 'white');
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){
        $container.css('left','0%');
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Enquete){
    	$container.css('left','0%');
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam){
    	$container.css('left','0%');
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
    }

    //START TRB00068
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){
            $('#content_video').attr('controls', 'controls');

            if(CONTENTVIEW.isShowVideoContent){
                $container.show();
            }
            else{

            }
        }
        else{
            $container.show();
        }
    }
    else{
        $container.show();
    }
    //END TRB00068

    CONTENTVIEW.isZoomingContent = false;
    CONTENTVIEW_GENERAL.isFullScreen = false;
};

//Get resource Id of content
CONTENTVIEW.downloadResourceById = function(contentId){
    var params = {
        sid: CONTENTVIEW.getSessionId(),
        contentId: contentId,
        getType: '2',
        isStreaming: ClientData.isStreamingMode()
    };

    var resourceUrl;
    CONTENTVIEW_CALLAPI.abapi('webGetContent', params, 'GET', function (data) {
        var resourceId;
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){
            resourceUrl = data.contentDataSub[0].resourceUrl;
        }
        else{
            $.each(data.contentData , function(i, n){
                if(typeof n == "object"){
                    resourceId = n.resourceId;
                }
            });
           //Get resource
           resourceUrl = CONTENTVIEW_GETDATA.getResourceByIdFromAPI(resourceId);
        }

    });

    return resourceUrl;
};

CONTENTVIEW.getVideoContentResourceId = function(contentId){

	if(CONTENTVIEW_GENERAL.contentType != COMMON.ContentTypeKeys.Type_Video){
		return null;
	}

	var params = {
		sid: ClientData.userInfo_sid(),
		contentId: contentId,
		getType: '2'
	};
	var resourceId;
	CONTENTVIEW_CALLAPI.abapi('webGetContent', params, 'GET', function (data) {
		$.each(data.contentData , function(i, n){
			if(typeof n == "object"){
				resourceId = n.resourceId;
			}
		});
		//Get resource
	});

	return resourceId;

};

//Start : TRB00015 - Editor : Long - Date : 08/28/2013 - Summary : For win 8 rotate handling.
CONTENTVIEW.setViewportForWin8 = function(){
    if (window.navigator.msPointerEnabled) {
        //Landscape
        if($(window).width() > $(window).height()){

            var msViewportStyle = document.createElement("style");
            msViewportStyle.appendChild(
              document.createTextNode("@-ms-viewport{width: device-width;!important}")
            );
            document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
        }
        //Portrait
        else{
            var msViewportStyle = document.createElement("style");
            msViewportStyle.appendChild(
              document.createTextNode("@-ms-viewport{width: device-height;!important}")
            );
            document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
        }
    }
};
//End : TRB00015 - Editor : Long - Date : 08/28/2013 - Summary : For win 8 rotate handling.

//Start : TRB00022 - Editor : Long - Date : 08/28/2013 - Summary : For ipad rotate handling.
CONTENTVIEW.setViewportForTouchDevice = function(maximumScale){
    if (COMMON.isTouchDevice()) {
        if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
            var viewportmeta = document.querySelector('meta[name="viewport"]');
            if (viewportmeta) {
                viewportmeta.content = 'minimum-scale=0.75, maximum-scale=' + maximumScale;
            }
        }
    }
};
//End : TRB00022 - Editor : Long - Date : 08/28/2013 - Summary : For ipad rotate handling.


/* ========================================================================================================== */

/**
* CurrentPage Class Definition
*/
/* constructor */
CONTENTVIEW.ContentPage = function (pageNum, pageImageUrl) {

    this.pageNumber = 0;
    this.pageImageUrl = pageImageUrl;
    this.bInitialized = false;

    /* init screen image */
    this.image = null;

    /* array page objects */
    this.pageObjects = new Array();
};

/* Load page */
CONTENTVIEW.ContentPage.prototype.load = function (onCompletedFunc) {

    /* load image  */
    this.image = new Image();
    this.image.onerror = function () {

    };
    this.image.onload = function (context) {
        /* load complete */
        if (onCompletedFunc) {
            onCompletedFunc();
        }
    };

    this.image.src = this.pageImageUrl;
};

/* add 1 page to pageObject */
CONTENTVIEW.ContentPage.prototype.addPageObject = function (pageObject) {
    this.pageObjects.push(pageObject);
};

/* init Json object using for init pages */
CONTENTVIEW.ContentPage.prototype.addPageObjects = function (pageObjects) {
    for (var i = 0; i < pageObjects.length; i++) {
        var obj = pageObjects[i];

        var pageObj = null;
        switch (obj.mediaType) {
            case 1:
                //mediaType = 1
                if (obj.actionType == 0) {
                    pageObj = new CONTENTVIEW_CREATEOBJECT.imageNoAction(     /* no action */
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.objectId
                                );
                } else if (obj.actionType == 1) {   /* play video */
                    pageObj = new CONTENTVIEW_CREATEOBJECT.videoType1(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.mediaFile,
                                    obj.media,
                                    obj.mediaResourceId,
                                    obj.objectId
                                );
                } else if (obj.actionType == 2) {
                    pageObj = new CONTENTVIEW_CREATEOBJECT.audioType1(    /* play audio */
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.audioFile,
                                    obj.audio,
                                    obj.audioResourceId,
                                    obj.objectId
                                );
                } else if (obj.actionType == 3) { /*open new url */
                    pageObj = new CONTENTVIEW_CREATEOBJECT.linkURL(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.action,
                                    obj.linkUrl,
                                    obj.browserType,
                                    obj.objectId
                                );
                } else if (obj.actionType == 4) { /*image preview */
                    pageObj = new CONTENTVIEW_CREATEOBJECT.imagePreview(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.imagePreview,
                                    obj.imagePreviewResourceIds,
                                    obj.objectId
                                );
                } else if (obj.actionType == 5) {  /*jump page */
                    pageObj = new CONTENTVIEW_CREATEOBJECT.jumpPage(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.jumpPage,
                                    obj.objectId
                                );
                } else if (obj.actionType == 6) { /*send mail */

                    pageObj = new CONTENTVIEW_CREATEOBJECT.sendMail(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.emailSubject,
                                    obj.emailAddress,
                                    obj.objectId
                                );
                } else if (obj.actionType == 8) { /* show popup */
                    pageObj = new CONTENTVIEW_CREATEOBJECT.openPopUp(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.content,
                                    obj.objectId
                                );
                } else if (obj.actionType == 10) { /* move to another content */
                    pageObj = new CONTENTVIEW_CREATEOBJECT.moveToContent(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.contentId,
                                    obj.pageNo,
                                    obj.objectId
                                );
                //Start Function : No.9 - Editor : Long - Summary :
                }else if(obj.actionType == 11){
                    pageObj = new CONTENTVIEW_CREATEOBJECT.htmlLinkButton(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.resourceUrl,
                                    obj.objectId
                                );
                }else if(obj.actionType == 12){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.anket(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.questionNo,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }else if(obj.actionType == 14){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.exam(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.showResult,
                                    obj.sendResult,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
                //End Function : No.9 - Editor : Long - Summary :
                else if(obj.actionType == 15){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.quiz(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
                break;
            case 2:
                pageObj = new CONTENTVIEW_CREATEOBJECT.videoType2(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.mediaFile,
                                    obj.media,
                                    obj.embed,
                                    obj.objectId
                                );
                break;
            case 3:
                pageObj = new CONTENTVIEW_CREATEOBJECT.audioType3(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.audioFile,
                                    obj.audioResourceId,
                                    obj.playType,
                                    obj.objectId
                                );
                break;
            case 4:
                // mediaType = 4
            	CONTENTVIEW.objType4_5.push(obj);
                pageObj = new CONTENTVIEW_CREATEOBJECT.listImage(
                                    obj.mediaType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.dataObjects,
                                    obj.triggerType,
                                    obj.objectId
                                );
                break;
            case 5:
                // mediaType = 5
            	CONTENTVIEW.objType4_5.push(obj);
                pageObj = new CONTENTVIEW_CREATEOBJECT.listVideo(
                                    obj.mediaType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.dataObjects,
                                    obj.objectId
                                );
                break;
            case 6:
                // mediaType = 6
                pageObj = new CONTENTVIEW_CREATEOBJECT.trigger(
                                        obj.mediaType,
                                        obj.actionType,
                                        obj.id,
                                        obj.imageUrl,
                                        obj.x,
                                        obj.y,
                                        obj.width,
                                        obj.height,
                                        obj.index,
                                        obj.target,
                                        obj.visible,
                                        obj.action,
                                        obj.objectId
                                    );
                break;
            case 7:
                // mediaType = 7
                pageObj = new CONTENTVIEW_CREATEOBJECT.text(
                                        obj.mediaType,
                                        obj.actionType,
                                        obj.id,
                                        obj.x,
                                        obj.y,
                                        obj.width,
                                        obj.height,
                                        obj.visible,
                                        obj.action,
                                        obj.content,
                                        obj.objectId
                                    );
                break;
            //Start Function : No.9 - Editor : Long - Date : 08/15/2013 - Summary : 3d object
            case 8:
                //mediaType = 9
                //obj["_3dLastId"] = CONTENTVIEW_GETDATA.convNumTo2Char(Math.round(obj.verticalCount/2)) +"-"+ CONTENTVIEW_GETDATA.convNumTo2Char(Math.round(obj.horizonCount/2));
                obj["_currFrameX"] = Math.round(obj.horizonCount/2);
                obj["_currFrameY"] = Math.round(obj.verticalCount/2);
                obj["_lastSelectedFrame"] = Object();
                obj["arrFrame"] = CONTENTVIEW_3D.createMatrixPoints(obj.width, obj.height, obj.verticalCount,
                     obj.horizonCount, Math.round(obj.horizonCount/2), Math.round(obj.verticalCount/2));

                CONTENTVIEW_GENERAL._object3DImageArr.push(obj);
                pageObj = new CONTENTVIEW_CREATEOBJECT.object3d(
                                        obj.mediaType,
                                        obj.actionType,
                                        obj.id,
                                        obj.initImage,
                                        obj.x,
                                        obj.y,
                                        obj.width,
                                        obj.height,
                                        obj.horizonCount,
                                        obj.verticalCount,
                                        obj.visible,
                                        obj['3dview'],
                                        obj.objectId
                                    );
                break;
            case 9:
                //mediaType = 9
                if(obj.actionType == 11){
                    pageObj = new CONTENTVIEW_CREATEOBJECT.htmlLinkButton(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.resourceUrl,
                                    obj.objectId
                                );
                }
                break;
            case 11:
                //mediaType = 11
                if(obj.actionType == 12){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.anket(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.questionNo,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
                break;
            case 12:
                //mediaType = 12
                if(obj.actionType == 14){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.exam(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.showResult,
                                    obj.sendResult,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
            case 13:
                //mediaType = 13
                if(obj.actionType == 15){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.quiz(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
                break;
            //Start Function : No.9 - Editor : Long - Date : 08/15/2013 - Summary : 3d object
            default:
                // default Object
                pageObj = new CONTENTVIEW_CREATEOBJECT.PageObject();
                pageObj.setup(
                            obj.mediaType,
                            obj.actionType,
                            obj.id,
                            obj.imageUrl,
                            obj.x,
                            obj.y,
                            obj.width,
                            obj.height,
                            obj.visible,
                            obj.action,
                            null,
                            obj.objectId
                        );
        }
        if( pageObj != null ){
        	// add pageObject
        	this.addPageObject(pageObj);
        }
    }
};
//Start Function: No.4 - Editor : Long - Date : 08/09/2013 - Summary: Edit function to draw on multi canvas
/* drawing for current page */
CONTENTVIEW.ContentPage.prototype.drawPage = function (context, opt) {

	if( opt == undefined || opt == null){
		opt = 0;
	}
	//console.log("CONTENTVIEW.ContentPage.prototype.drawPage:" + opt);

    /*set status is loading page */
	CONTENTVIEW_GENERAL.isLoadingObject = true;
    /* lock all controls in page */
	CONTENTVIEW_GENERAL.disableAllControl();
    /* init array image */
    CONTENTVIEW_GENERAL.arrImage = [];
    CONTENTVIEW_GENERAL.nCountObjectLoad[opt] = 0;
    $('#divImageLoading').css('display', 'block');

    //var width = this.image.width;
    //var height = this.image.height;

    //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        if(opt == null || opt == 0){
        	CONTENTVIEW_CALLAPI.getPageSizeByPageNo(CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()));
            //#11478
            //CONTENTVIEW_GENERAL.widthEachPage = CONTENTVIEW_GENERAL.widthContentImage;
            //CONTENTVIEW_GENERAL.heightEachPage = CONTENTVIEW_GENERAL.heightContentImage;
            CONTENTVIEW_GENERAL.widthEachPageApi = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachPageApi = CONTENTVIEW_GENERAL.heightContentImage;
        }
        else if(opt == 1){
        	CONTENTVIEW_CALLAPI.getPageSizeByPageNo(CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() + 1));
            CONTENTVIEW_GENERAL.widthEachNextPage = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachNextPage = CONTENTVIEW_GENERAL.heightContentImage;
            //#11478
            CONTENTVIEW_GENERAL.widthEachNextPageApi = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachNextPageApi = CONTENTVIEW_GENERAL.heightContentImage;
        }
        else if(opt == 2){
        	CONTENTVIEW_CALLAPI.getPageSizeByPageNo(CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() - 1));
            CONTENTVIEW_GENERAL.widthEachPrevPage = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachPrevPage = CONTENTVIEW_GENERAL.heightContentImage;
            //#11478
            CONTENTVIEW_GENERAL.widthEachPrevPageApi = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachPrevPageApi = CONTENTVIEW_GENERAL.heightContentImage;
        }
    }
    else{
    	CONTENTVIEW_GENERAL.widthEachPage = CONTENTVIEW_GENERAL.widthContentImage;
        CONTENTVIEW_GENERAL.heightEachPage = CONTENTVIEW_GENERAL.heightContentImage;
        //#11478
        CONTENTVIEW_GENERAL.widthEachPageApi = CONTENTVIEW_GENERAL.widthContentImage;
        CONTENTVIEW_GENERAL.heightEachPageApi = CONTENTVIEW_GENERAL.heightContentImage;
        CONTENTVIEW_GENERAL.widthEachNextPageApi = CONTENTVIEW_GENERAL.widthContentImage;
        CONTENTVIEW_GENERAL.heightEachNextPageApi = CONTENTVIEW_GENERAL.heightContentImage;
        CONTENTVIEW_GENERAL.widthEachPrevPageApi = CONTENTVIEW_GENERAL.widthContentImage;
        CONTENTVIEW_GENERAL.heightEachPrevPageApi = CONTENTVIEW_GENERAL.heightContentImage;
    }

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        //
    }
    else{
        if(opt == null || opt == 0){
            $("#offscreen").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
            $("#offscreen").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
        }
        else if(opt == 1){
            $("#offscreenNext").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
            $("#offscreenNext").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
        }
        else if(opt == 2){
            $("#offscreenPre").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
            $("#offscreenPre").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
        }
    }

    //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content

    var objPageTemp = this.pageObjects;
    var img = new Image();
    img.onload = function () {
        //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
            if(opt == null || opt == 0){
                //#11478
            	CONTENTVIEW_GENERAL.heightEachPage = img.naturalHeight;
                CONTENTVIEW_GENERAL.widthEachPage = img.naturalWidth;
                $("#offscreen").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
                $("#offscreen").attr('width', CONTENTVIEW_GENERAL.widthEachPage);

                context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachPage, CONTENTVIEW_GENERAL.heightEachPage);
            }
            else if(opt == 1){
                //#11478
            	CONTENTVIEW_GENERAL.heightEachNextPage = img.naturalHeight;
                CONTENTVIEW_GENERAL.widthEachNextPage = img.naturalWidth;
                $("#offscreenNext").attr('height', CONTENTVIEW_GENERAL.heightEachNextPage);
                $("#offscreenNext").attr('width', CONTENTVIEW_GENERAL.widthEachNextPage);

                context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachNextPage, CONTENTVIEW_GENERAL.heightEachNextPage);
            }
            else if(opt == 2){
                //#11478
            	CONTENTVIEW_GENERAL.heightEachPrevPage = img.naturalHeight;
                CONTENTVIEW_GENERAL.widthEachPrevPage = img.naturalWidth;
                $("#offscreenPre").attr('height', CONTENTVIEW_GENERAL.heightEachPrevPage);
                $("#offscreenPre").attr('width', CONTENTVIEW_GENERAL.widthEachPrevPage);

                context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachPrevPage, CONTENTVIEW_GENERAL.heightEachPrevPage);
            }
        }
        else{
            context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachPage, CONTENTVIEW_GENERAL.heightEachPage);
        }

        //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content

        CONTENTVIEW.flip(opt);
        //Start Function: No.12
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
            /* draw linkList */
        	CONTENTVIEW.drawGetWebContent4(context, opt);
        }
        //Start Function: No.12

        if (objPageTemp.length > 0) {
            // draw object
            for (var i = 0; i < objPageTemp.length; i++) {
                if (objPageTemp[i].imageUrl != null) {
                    objPageTemp[i].drawPageObject(context, opt);
                }
                else {
                	CONTENTVIEW_GENERAL.nCountObjectLoad[opt]++;

                    if (CONTENTVIEW_GENERAL.nCountObjectLoad[opt] == objPageTemp.length) {
                        /* draw marking */
                    	CONTENTVIEW.drawMarkingOnScreen(opt);

                        /*set status is loading page */
                       if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                            if(CONTENTVIEW_GENERAL.totalPage > 1){
                                if(opt != 0 && opt != null){
                                	CONTENTVIEW_GENERAL.isLoadingObject = false;
                                }
                            }
                            else{
                            	CONTENTVIEW_GENERAL.isLoadingObject = false;
                            }
                       }
                       else{
                    	   CONTENTVIEW_GENERAL.isLoadingObject = false;
                       }

                        /* enable controls in page */
                        if (ClientData.IsAddingMarking() == true) {
                        	CONTENTVIEW_GENERAL.disableAllControl();
                        	CONTENTVIEW_MARKING.enableButtonMarking();
                        } else {
                            //Start Function : No.4 - Summary : make sure next or prev page is loaded
                            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                                if(CONTENTVIEW_GENERAL.totalPage > 1){
                                    if(opt != 0 && opt != null){
                                    	CONTENTVIEW_GENERAL.enableAllControl();
                                    }
                                }
                                else{
                                	CONTENTVIEW_GENERAL.enableAllControl();
                                }
                            }
                            else{
                            	CONTENTVIEW_GENERAL.enableAllControl();
                            }
                            //End Function : No.4 - Summary : make sure next or prev page is loaded
                        }
                        /*finish loading */
                       //Start Function : No.4 - Summary : make sure next or prev page is loaded
                        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                            if(CONTENTVIEW_GENERAL.totalPage > 1){
                                if(opt != 0 && opt != null){
                                   $('#divImageLoading').css('display', 'none');
                                }
                            }
                            else{
                                $('#divImageLoading').css('display', 'none');
                            }
                        }
                        else{
                            $('#divImageLoading').css('display', 'none');
                        }
                        //End Function : No.4 - Summary : make sure next or prev page is loaded
                        /* set pos video */
                        CONTENTVIEW.zoomVideo();
                    }

                }
            }
        }
        else {
            /* draw marking */
        	CONTENTVIEW.drawMarkingOnScreen(opt);

            /*set status is loading page */
            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                if(CONTENTVIEW_GENERAL.totalPage > 1){
                   if(opt != 0 && opt != null){
                	   CONTENTVIEW_GENERAL.isLoadingObject = false;
                   }
                }
                else{
                	CONTENTVIEW_GENERAL.isLoadingObject = false;
                }
            }
            else{
            	CONTENTVIEW_GENERAL.isLoadingObject = false;
            }
            /* enable controls in page */
            if (ClientData.IsAddingMarking() == true) {
            	CONTENTVIEW_GENERAL.disableAllControl();
            	CONTENTVIEW_MARKING.enableButtonMarking()
            }
            else {
                //Start Function : No.4 - Summary : make sure next or prev page is loaded
                if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    if(CONTENTVIEW_GENERAL.totalPage > 1){
                        if(opt != 0 && opt != null){
                        	CONTENTVIEW_GENERAL.enableAllControl();
                        }
                    }
                    else{
                    	CONTENTVIEW_GENERAL.enableAllControl();
                    }
                }
                else{
                	CONTENTVIEW_GENERAL.enableAllControl();
                }
                //End Function : No.4 - Summary : make sure next or prev page is loaded
            }

            /*finish loading */
            //Start Function : No.4 - Summary : make sure next or prev page is loaded

            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                if(CONTENTVIEW_GENERAL.totalPage > 1){
                    if(opt != 0 && opt != null){
                        $('#divImageLoading').css('display', 'none');
                    }
                }
                else{
                    $('#divImageLoading').css('display', 'none');
                }
            }
            else{
                 $('#divImageLoading').css('display', 'none');
            }
            //End Function : No.4 - Summary : make sure next or prev page is loaded

            /* set pos video */
            CONTENTVIEW.zoomVideo();
        }

    };
    img.src = this.image.src;
};
//End Function: No.4 - Editor : Long - Date : 08/09/2013 - Summary: Edit function to draw on multi canvas


/* If have hitTest on the objects within the page and return PageObject */
CONTENTVIEW.ContentPage.prototype.hitTest = function (px, py) {
    for (var i = 0; i < this.pageObjects.length; i++) {
        if (this.pageObjects[i].hitTest(px, py)) {
            return this.pageObjects[i];
        }
    }
    return null;
};

/* search by Object ID */
CONTENTVIEW.ContentPage.prototype.findById = function (id) {
    for (var i = 0; i < this.pageObjects.length; i++) {
        if (this.pageObjects[i].id == id) {
            return this.pageObjects[i];
        }
    }
    return null;
};


/* check status button move page when change page */
CONTENTVIEW.checkExistNextPrePage = function() {
    //check next page
    if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
        //$('#nextpage').show();
        //COMMON.enable('#nextpage');
        $('#nextpage').unbind('click');
        $('#nextpage').bind('click', CONTENTVIEW_EVENTS.nextPage_click);

        $('#lastpage').unbind('click');
        $('#lastpage').bind('click', CONTENTVIEW_EVENTS.lastPage_click);

        if (COMMON.isTouchDevice() == true) {
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next_device');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last_device');
        } else {
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last');
        }
    } else {
        //$('#nextpage').hide();
        //COMMON.disable('#nextpage');
        $('#nextpage').unbind('click');
        $('#lastpage').unbind('click');

        if (COMMON.isTouchDevice() == true) {
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next_off');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last_off');
        } else {
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next_off');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last_off');
        }
        $('#button_next_canvas').css('opacity', '0');
    }

    //check prev page
    if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {
        //$('#prevpage').show();
        //COMMON.enable('#prevpage');
        $('#prevpage').unbind('click');
        $('#prevpage').bind('click', CONTENTVIEW_EVENTS.prevPage_click);

        $('#firstpage').unbind('click');
        $('#firstpage').bind('click', CONTENTVIEW_EVENTS.firstPage_click);

        if (COMMON.isTouchDevice() == true) {
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev_device');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin_device');
        } else {
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin');
        }
    } else {
        //$('#prevpage').hide();
        //COMMON.disable('#prevpage');
        $('#prevpage').unbind('click');
        $('#firstpage').unbind('click');

        if (COMMON.isTouchDevice() == true) {
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev_off');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin_off');
        } else {
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev_off');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin_off');
        }
        $('#button_pre_canvas').css('opacity', '0');

    }

};


/* Point objects */
CONTENTVIEW.Point = function (x, y) {
    this.x = x;
    this.y = y;
};


/* remove all object when change page */
CONTENTVIEW.removeObject = function() {
    $('#text').children().remove();

    /* close dialog */
    if (CONTENTVIEW_GENERAL.isOpenPopUpText == true) {
    	CONTENTVIEW_GENERAL.isOpenPopUpText = false;
    	CONTENTVIEW_POPUPTEXT.ClosePopupText();
    }

    $("#bgmConfirm").hide();
    $("#bgmConfirm_page").hide();
    $("#boxCopyText").hide();
    $("#boxSearching").hide();
    $("#boxIndex").hide();
    $("#boxBookMark").hide();
    $('#pop_up_memo').hide();
    CONTENTVIEW_GENERAL.isSendingData = false;

    CONTENTVIEW_GENERAL.isDisplayBookMarkList = false;
    CONTENTVIEW_GENERAL.isDisplayCopyText = false;
    CONTENTVIEW_GENERAL.isDisplayListIndex = false;

    if ($('#playvideo').children().length > 0) {
        $('#playvideo').children().remove();
    }

    if ($('#playaudio').children().length > 0) {
        $('#playaudio').children().remove();
    }
    if ($('#playaudiopage').children().length > 0) {
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false) {
            $('#playaudiopage').children().remove();
        }
    }

    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
    	CONTENTVIEW.srcAudioType0 = '';
    	CONTENTVIEW.TypeAudio0 = '';
    	CONTENTVIEW.srcAudioType2 = '';
    	CONTENTVIEW.TypeAudio2 = '';
    } else {
        /* do nothing */
    }


    //Start Function : No.12 - Editor :Long - Date: 08/12/2013 - Summary : prevent close dialog if content is not pdf
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
    	CONTENTVIEW_GENERAL.hideDialog();
    }
    //End Function : No.12 - Editor :Long - Date: 08/12/2013 - Summary : prevent close dialog if content is not pdf

    /* play background audio */
    CONTENTVIEW.playAllAudio();

    /* mediaType = 4 */
    CONTENTVIEW_GENERAL.mediaType4_changeImage = 0;
};

/* View Component setDefaultEvent */
CONTENTVIEW.setDefaultEvent = function() {

	CONTENTVIEW_GENERAL._bTouchDeviceEnabled = COMMON.isTouchDevice();

    var canvasPre = document.getElementById('mainPre');
    var canvasNext = document.getElementById('mainNext');
    //mouse event
    // add event for wrap

    //remove wrapper event
    canvasPre.removeEventListener('mousedown',function(){},false);
    canvasPre.removeEventListener('mousemove',function(){},false);
    canvasPre.removeEventListener('mouseup',function(){},false);
    canvasPre.removeEventListener('mouseout',function(){},false);

    canvasNext.removeEventListener('mousedown',function(){},false);
    canvasNext.removeEventListener('mousemove',function(){},false);
    canvasNext.removeEventListener('mouseup',function(){},false);
    canvasNext.removeEventListener('mouseout',function(){},false);

    document.getElementById('main').addEventListener('click', CONTENTVIEW_EVENTS.onClick_CanvasMain, false);
    if ($('#divCheckExistMarking').length) {
    	document.getElementById('divCheckExistMarking').addEventListener('click', CONTENTVIEW_EVENTS.onClick_CanvasMain, false);
    }
    if ($('#divCheckExistMemo').length) {
    	document.getElementById('divCheckExistMemo').addEventListener('click', CONTENTVIEW_EVENTS.onClick_CanvasMain, false);
    }
    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false){

        document.getElementById('main').addEventListener('mousedown', CONTENTVIEW_EVENTS.mouseDown_CanvasMain, false);
        document.getElementById('main').addEventListener('mousemove', CONTENTVIEW_EVENTS.mouseMove_CanvasMain, false);
        document.getElementById('main').addEventListener('mouseup', CONTENTVIEW_EVENTS.mouseUp_CanvasMain, false);

        //#12408 ホイール対応
        // MouseScrollEvent に対応している（FireFox 専用）
        if(window.MouseScrollEvent){
        	//console.log("addEventListener DOMMouseScroll");
            document.getElementById('main').addEventListener('DOMMouseScroll', function(event){
            	CONTENTVIEW_EVENTS.mouseWheel_CanvasMain(event, event.detail);
            }, false);
        // FireFox 以外の主要ブラウザの場合
        }else{
        	//console.log("addEventListener mousewheel");
            var mousewheelevent = 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll';
            document.getElementById('main').addEventListener(mousewheelevent, function(e){
            	CONTENTVIEW_EVENTS.mouseWheel_CanvasMain(event, -(e.wheelDelta / 40));
            }, false);
        }

        if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'msie') {
        	//IEかつタッチ対応のデバイスか判定追加
        	if(navigator.msMaxTouchPoints && navigator.msMaxTouchPoints > 1) {
        		//console.log("navigator.msMaxTouchPoints:" + navigator.msMaxTouchPoints)
        		CONTENTVIEW_GENERAL._bWin8TouchEnabled = window.navigator.msPointerEnabled;
        	}
        } else {
            if( CONTENTVIEW_GENERAL._bTouchDeviceEnabled ){
                document.getElementById('main').addEventListener('touchstart', CONTENTVIEW_EVENTS.onTouchstart, false);
                document.getElementById('main').addEventListener('touchmove', CONTENTVIEW_EVENTS.onTouchmove, false);
                document.getElementById('main').addEventListener('touchend', CONTENTVIEW_EVENTS.onTouchend, false);
                //iPad&Andの実装から
                document.getElementById('canvasWrapper').addEventListener('touchstart', function(event){event.preventDefault();}, false);
                document.getElementById('canvasWrapper').addEventListener('touchmove', function(event){event.preventDefault();}, false);
                document.getElementById('canvasWrapper').addEventListener('touchend', function(event){event.preventDefault();}, false);
                document.getElementById('overlay').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
                document.getElementById('overlay').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
                document.getElementById('overlay').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);
                //デフォルトのD&Dが効いてしまう問題回避
                document.getElementById('button_next_canvas').addEventListener('touchstart', function(event){event.preventDefault();}, false);
                document.getElementById('button_next_canvas').addEventListener('touchmove', function(event){event.preventDefault();}, false);
                document.getElementById('button_next_canvas').addEventListener('touchend', function(event){event.preventDefault();}, false);
                document.getElementById('button_pre_canvas').addEventListener('touchstart', function(event){event.preventDefault();}, false);
                document.getElementById('button_pre_canvas').addEventListener('touchmove', function(event){event.preventDefault();}, false);
                document.getElementById('button_pre_canvas').addEventListener('touchend', function(event){event.preventDefault();}, false);

            }
        }

        if(CONTENTVIEW_GENERAL._bWin8TouchEnabled){
            document.getElementById('main').addEventListener('MSPointerDown', CONTENTVIEW_EVENTS.onTouchstart, false);
            document.getElementById('main').addEventListener('MSPointerMove', CONTENTVIEW_EVENTS.onTouchmove, false);
            document.getElementById('main').addEventListener('MSPointerUp', CONTENTVIEW_EVENTS.onTouchend, false);
        }
    }
    else if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()){
        document.getElementById('main').removeEventListener('click', function(){}, false);
        document.getElementById('main').addEventListener('touchstart', CONTENTVIEW_EVENTS.onTouchstart, false);
        document.getElementById('main').addEventListener('touchmove', CONTENTVIEW_EVENTS.onTouchmove, false);
        document.getElementById('main').addEventListener('touchend', CONTENTVIEW_EVENTS.onTouchend, false);
        document.getElementById('canvasWrapper').addEventListener('touchstart', function(event){event.preventDefault();}, false);
        document.getElementById('canvasWrapper').addEventListener('touchmove', function(event){event.preventDefault();}, false);
        document.getElementById('canvasWrapper').addEventListener('touchend', function(event){event.preventDefault();}, false);
        document.getElementById('overlay').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
        document.getElementById('overlay').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
        document.getElementById('overlay').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);

        //document.getElementById('contentVideoConfirm').addEventListener('click', function(event){event.preventDefault(); return false;}, false);
        //document.getElementById('contentVideoConfirm').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
        //document.getElementById('contentVideoConfirm').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
        //document.getElementById('contentVideoConfirm').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);

    }

    $('#main').mouseout(function (event) {
        if (CONTENTVIEW.moveFlag) {
        	CONTENTVIEW.moveFlag = false;
        }

        $('#button_pre_canvas').css('opacity', '0');
        $('#button_next_canvas').css('opacity', '0');
    });

	//オーサリングプレビュー対応
	if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
		$('#close_screen').click(function(){
			window.open('', '_self', '');
			window.close();
		});
	}

};

/*disable all control when click copy memo */
CONTENTVIEW.disableControlsCopyMemo = function() {
    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'default');
    $("#imgBack").css('cursor', 'default');
    $("#listbookmark").css('cursor', 'default');
    $("#imgbookmark").css('cursor', 'default');
    $("#listindex").css('cursor', 'default');
    $("#copytext").css('cursor', 'default');
    $("#imgmemo").css('cursor', 'default');
    $("#imgaddmemo").css('cursor', 'default');
    $("#imgmarking").css('cursor', 'default');
    $("#imgmarkingtoolbar").css('cursor', 'default');
    $("#firstpage").css('cursor', 'default');
    $("#prevpage").css('cursor', 'default');
    $("#nextpage").css('cursor', 'default');
    $("#lastpage").css('cursor', 'default');

    $('#imgHome').unbind('click');
    $('#imgHome').removeClass();
    $('#imgHome').addClass('home_off');

    /* back button */
    $('#imgBack').unbind('click');
    $('#imgBack').removeClass();
    $('#imgBack').addClass('back_off');

    /*list bookmark */
    $('#listbookmark').unbind('click');
    $('#listbookmark').removeClass();
    $('#listbookmark').addClass('bmList_off');

    $('#imgbookmark').unbind('click');
    $('#imgbookmark').removeClass();
    $('#imgbookmark').addClass('bmAdd_off');

    $('#listindex').unbind('click');
    $('#listindex').removeClass();
    $('#listindex').addClass('index_off');

    $('#copytext').unbind('click');
    $('#copytext').removeClass();
    $('#copytext').addClass('copy_off');

    /* imgage display memo */
    $('#imgmemo').unbind('click');
    $('#imgmemo').removeClass();
    $('#imgmemo').addClass('memoDisplay_off');

    /* image add memo */
    $('#imgaddmemo').unbind('click');
    $('#imgaddmemo').removeClass();
    $('#imgaddmemo').addClass('memoAdd_off');

    $('#imgmarking').unbind('click');
    $('#imgmarking').removeClass();
    $('#imgmarking').addClass('marking_off');

    /* check is loading page */
    $('#imgmarkingtoolbar').unbind('click');
    $('#imgmarkingtoolbar').removeClass();
    $('#imgmarkingtoolbar').addClass('markingToolbar_off');

    $('#firstpage').unbind('click');
    $('#firstpage').removeClass();
    $('#firstpage').addClass('begin_off');
    $('#prevpage').unbind('click');
    $('#prevpage').removeClass();
    $('#prevpage').addClass('prev_off');
    $('#nextpage').unbind('click');
    $('#nextpage').removeClass();
    $('#nextpage').addClass('next_off');
    $('#lastpage').unbind('click');
    $('#lastpage').removeClass();
    $('#lastpage').addClass('last_off');

    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
        $("#slider_page").slider("option", "disabled", true);
    }
    COMMON.disable('#txtSearch', '#txtSlider');

    $('#button_next_canvas').css('display', 'none');
    $('#button_pre_canvas').css('display', 'none');
};

/*enable all control when finish copy memo */
CONTENTVIEW.enableControlsCopyMemo = function() {
	CONTENTVIEW.disableControlsCopyMemo();

    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'pointer');
    $("#imgBack").css('cursor', 'pointer');
    $("#listbookmark").css('cursor', 'pointer');
    $("#imgbookmark").css('cursor', 'pointer');
    $("#listindex").css('cursor', 'pointer');
    $("#copytext").css('cursor', 'pointer');
    $("#imgmemo").css('cursor', 'pointer');
    $("#imgaddmemo").css('cursor', 'pointer');
    $("#imgmarking").css('cursor', 'pointer');
    $("#imgmarkingtoolbar").css('cursor', 'pointer');
    $("#firstpage").css('cursor', 'pointer');
    $("#prevpage").css('cursor', 'pointer');
    $("#nextpage").css('cursor', 'pointer');
    $("#lastpage").css('cursor', 'pointer');

    $("#control_screen").removeClass();
    $("#control_screen_2").removeClass();

    $('#imgHome').bind('click', CONTENTVIEW_EVENTS.imgHome_click);
    $('#imgHome').removeClass();

    $('#imgBack').bind('click', CONTENTVIEW_EVENTS.imgBack_click);
    $('#imgBack').removeClass();

    /*list bookmark */
    $('#listbookmark').bind('click', CONTENTVIEW_EVENTS.showListBookMark);
    $('#listbookmark').removeClass();

    $('#imgbookmark').bind('click', CONTENTVIEW.bookmarkPage);
    $('#imgbookmark').removeClass();

    //Start Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary :
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        $('#listindex').bind('click', CONTENTVIEW_EVENTS.showListPageIndex);
        $('#listindex').removeClass();
        if(ClientData.serviceOpt_copy_text() == 'Y') {
        	$('#copytext').bind('click', CONTENTVIEW_EVENTS.showCopyText);
            $('#copytext').removeClass();
        } else {
        	$('#copytext').unbind('click');
        	$('#copytext').removeClass();
            $('#copytext').addClass('copy_off');
        }
        //sessionStorage.removeItem('copy_text');
    }
    //Start Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary :

    /* image memo */
    $('#imgmemo').bind('click', CONTENTVIEW.handleMemo);
    $('#imgmemo').removeClass();

    /* image add memo */
    $('#imgaddmemo').bind('click', CONTENTVIEW_EVENTS.handleAddMemo);
    $('#imgaddmemo').removeClass();

    $('#imgmarking').bind('click', CONTENTVIEW_EVENTS.imgmarking_click);
    $('#imgmarking').removeClass();

    if (ClientData.serviceOpt_marking() == 'Y') {
        $('#imgmarkingtoolbar').bind('click', CONTENTVIEW.handleDrawCanvas);
        $('#imgmarkingtoolbar').removeClass();
    }

    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        $("#slider_page").slider("option", "disabled", false);
        COMMON.enable('#txtSearch', '#txtSlider');
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
        $("#slider_page").slider("option", "disabled", false);
        COMMON.enable('#txtSlider');
    }


    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
        $('#button_next_canvas').css('display', 'block');
        $('#button_pre_canvas').css('display', 'block');
    }

    if (COMMON.isTouchDevice() == true) {/* set css for device */
        $('#imgHome').addClass('home_device');
        $('#imgBack').addClass('back_device');
        /*$('#firstpage').addClass('begin_device');
        $('#prevpage').addClass('prev_device');
        $('#nextpage').addClass('next_device');
        $('#lastpage').addClass('last_device');*/
        $("#control_screen").addClass('toolbar_device');
        //$("#control_screen_2").addClass('toolbar_device');
        $("#control_screen_2").addClass('toolbar_close_device');

        var nBookmarkId = CONTENTVIEW.isExistBookmark();
        if (nBookmarkId == -1) {
            $('#imgbookmark').addClass('bmAdd_device');
        } else {
            $('#imgbookmark').addClass('bmAdd_hover');
        }

        if (CONTENTVIEW_GENERAL.isDisplayBookMarkList == true) {
            $('#listbookmark').addClass('bmList_hover');
        } else {
            $('#listbookmark').addClass('bmList_device');
        }

        if (CONTENTVIEW_GENERAL.isDisplayCopyText == true) {
            $('#copytext').addClass('copy_hover');
        } else {
            $('#copytext').addClass('copy_device');
        }

        if (CONTENTVIEW_GENERAL.isDisplayListIndex == true) {
            $('#listindex').addClass('index_hover');
        } else {
            $('#listindex').addClass('index_device');
        }

        if (ClientData.IsDisplayMemo() == true) {
            $('#imgmemo').addClass('memoDisplay_hover');
        } else {
            $('#imgmemo').addClass('memoDisplay_device');
        }

        if (ClientData.IsAddingMemo() == true) {
            $('#imgaddmemo').addClass('memoAdd_hover');
        } else {
            $('#imgaddmemo').addClass('memoAdd_device');
        }

        if (ClientData.IsDisplayMarking() == true) {
            $('#imgmarking').addClass('marking_hover');
        } else {
            $('#imgmarking').addClass('marking_device');
        }
        if (ClientData.serviceOpt_marking() == 'Y') {
            if (ClientData.IsAddingMarking() == true) {
                $('#imgmarkingtoolbar').addClass('markingToolbar_hover');
            } else {
                $('#imgmarkingtoolbar').addClass('markingToolbar_device');
            }
        }
    } else { /* set css for PC */
        $('#imgHome').addClass('home');
        $('#imgBack').addClass('back');
        /*$('#firstpage').addClass('begin');
        $('#prevpage').addClass('prev');
        $('#nextpage').addClass('next');
        $('#lastpage').addClass('last');*/
        $("#control_screen").addClass('toolbar');
        $("#control_screen_2").addClass('toolbar_close');

        var nBookmarkId = CONTENTVIEW.isExistBookmark();
        if (nBookmarkId == -1) {
            $('#imgbookmark').addClass('bmAdd');
        } else {
            $('#imgbookmark').addClass('bmAdd_hover');
        }

        if (CONTENTVIEW_GENERAL.isDisplayBookMarkList == true) {
            $('#listbookmark').addClass('bmList_hover');
        } else {
            $('#listbookmark').addClass('bmList');
        }

        if (CONTENTVIEW_GENERAL.isDisplayCopyText == true) {
            $('#copytext').addClass('copy_hover');
        } else {
            $('#copytext').addClass('copy');
        }

        if (CONTENTVIEW_GENERAL.isDisplayListIndex == true) {
            $('#listindex').addClass('index_hover');
        } else {
            $('#listindex').addClass('index');
        }

        if (ClientData.IsDisplayMemo() == true) {
            $('#imgmemo').addClass('memoDisplay_hover');
        } else {
            $('#imgmemo').addClass('memoDisplay');
        }

        if (ClientData.IsAddingMemo() == true) {
            $('#imgaddmemo').addClass('memoAdd_hover');
        } else {
            $('#imgaddmemo').addClass('memoAdd');
        }

        if (ClientData.IsDisplayMarking() == true) {
            $('#imgmarking').addClass('marking_hover');
        } else {
            $('#imgmarking').addClass('marking');
        }
        if (ClientData.serviceOpt_marking() == 'Y') {
            if (ClientData.IsAddingMarking() == true) {
                $('#imgmarkingtoolbar').addClass('markingToolbar_hover');
            } else {
                $('#imgmarkingtoolbar').addClass('markingToolbar');
            }
        }
    }
    CONTENTVIEW.checkExistNextPrePage();
};

/* Change Coordinate Screen to Image */
CONTENTVIEW.screenToImage = function(x, y) {

    var pt = new CONTENTVIEW.Point(0, 0);

    // get current position of mouse on screen
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
        pt.x = x - CONTENTVIEW.marginX;
        pt.y = y;
    } else {
        pt.x = x - CONTENTVIEW.marginX;
        pt.y = y - CONTENTVIEW.marginY;
    }

    var sx = (CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left) / (CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left);
    var sy = (CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top) / (CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top);

    // change size image correct
    var nx = (pt.x - CONTENTVIEW.destRect.left) / sx;
    var ny = (pt.y - CONTENTVIEW.destRect.top) / sy;
    pt.x = Math.floor(nx + CONTENTVIEW.srcRect.left);
    pt.y = Math.floor(ny + CONTENTVIEW.srcRect.top);

    //console.log('CONTENTVIEW.screenToImage ' + CONTENTVIEW.srcRect.right + ' ' + CONTENTVIEW.srcRect.left + ' ' + CONTENTVIEW.destRect.right + ' ' + CONTENTVIEW.destRect.left + ' ' + x + ' ' + sx + ' ' + nx + ' ' + pt.x + ' ' + srcRect.bottom + ' ' + srcRect.top + ' ' + CONTENTVIEW.destRect.bottom + ' ' + CONTENTVIEW.destRect.top + ' ' + y + ' ' + sy + ' ' + ny + ' ' + pt.y);

    return pt;
};

/* draw Canvas  */
CONTENTVIEW.drawCanvas = function(opt) {

    //Draw on offscreen
    if(opt==null || opt == 0){
        // draw main canvas
        var canvas = document.getElementById('offscreen');
        var context = canvas.getContext('2d');

        context.clearRect(0, 0, canvas.width, canvas.height);

        CONTENTVIEW.draw(context, 0);
    }
    //Draw on next offscreen
    else if (opt==1){
        // draw mainNext canvas
        var canvas = document.getElementById('offscreenNext');
        var context = canvas.getContext('2d');

        context.clearRect(0, 0, canvas.width, canvas.height);

        CONTENTVIEW.draw(context, 1);
    }
    //Draw on previous offscreen
    else if (opt==2){
        // draw mainPre canvas
        var canvas = document.getElementById('offscreenPre');
        var context = canvas.getContext('2d');

        context.clearRect(0, 0, canvas.width, canvas.height);

        CONTENTVIEW.draw(context, 2);
    }
};

/* draw memo */
CONTENTVIEW.drawMemoOnScreen = function(opt) {

    //Start Function : No.4
    var canvas;
    var context;
    //START TRB00097
    var tempPageHeight;
    var tempPageWidth;
    //END TRB00097
    var tempPageNo = 0;

    if(opt == null || opt == 0){
        canvas = document.getElementById('offscreen');
        canvasWidth = $('#offscreen').width();
        canvasHeight = $('#offscreen').height();

        //START TRB00097
        tempPageHeight = CONTENTVIEW_GENERAL.heightEachPage;
        tempPageWidth = CONTENTVIEW_GENERAL.widthEachPage;
        //END TRB00097
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex());
    }
    else if(opt == 1){
        canvas = document.getElementById('offscreenNext');
        canvasWidth = $('#offscreenNext').width();
        canvasHeight = $('#offscreenNext').height();

        //START TRB00097
        tempPageHeight = CONTENTVIEW_GENERAL.heightEachNextPage;
        tempPageWidth = CONTENTVIEW_GENERAL.widthEachNextPage;
        //END TRB00097
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() + 1);
    }
    else if(opt == 2){
        canvas = document.getElementById('offscreenPre');
        canvasWidth = $('#offscreenPre').width();
        canvasHeight = $('#offscreenPre').height();
        //START TRB00097
        tempPageHeight = CONTENTVIEW_GENERAL.heightEachPrevPage;
        tempPageWidth = CONTENTVIEW_GENERAL.widthEachPrevPage;
        //END TRB00097
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() - 1);
    }

    context = canvas.getContext('2d');
    //End Function : No.4

    if (ClientData.IsDisplayMemo() == true) {
    	CONTENTVIEW_CREATEOBJECT.memoObjects = [];

        /*get data memo */
        var memoData = ClientData.MemoData();

        //Start Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
        var tempPosX = 0;
        var tempPosY = 0;
        //End Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo

        for (var nIndex = 0; nIndex < memoData.length; nIndex++) {
            if (memoData[nIndex].contentid == CONTENTVIEW_GENERAL.contentID
            && memoData[nIndex].pageNo == tempPageNo) {
                /* create object of memo */
                var memoObject = null;
                 //START TRB00097
                if (memoData[nIndex].posY > tempPageHeight - 50) {
                    memoData[nIndex].posY = tempPageHeight - 50;
                }

                if (memoData[nIndex].posX > tempPageWidth - 50) {
                    memoData[nIndex].posX = tempPageWidth - 50;
                }
                 //END TRB00097

                //Start Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
                if(memoData[nIndex].posY != tempPosY && memoData[nIndex].posX != tempPosX){
                    tempPosX = memoData[nIndex].posX;
                    tempPosY = memoData[nIndex].posY;

                    memoObject = new CONTENTVIEW_CREATEOBJECT.memo(
                        nIndex,
                        memoData[nIndex].Text,
                        memoData[nIndex].posX,
                        memoData[nIndex].posY,
                        50,
                        50,
                        "img/memo.png"
                    );

                    CONTENTVIEW_CREATEOBJECT.memoObjects.push(memoObject);

                }else{
                    for (var i = CONTENTVIEW_CREATEOBJECT.memoObjects.length - 1; i >= 0; i--) {
                        var tempObj = CONTENTVIEW_CREATEOBJECT.memoObjects[i];

                        if(tempObj.x == tempPosX && tempObj.y == tempPosY){
                        	CONTENTVIEW_CREATEOBJECT.memoObjects.slice(i, 1);
                        }
                    }

                    memoObject = new CONTENTVIEW_CREATEOBJECT.memo(
                        nIndex,
                        memoData[nIndex].Text,
                        memoData[nIndex].posX,
                        memoData[nIndex].posY,
                        50,
                        50,
                        "img/memo.png"
                    );

                    CONTENTVIEW_CREATEOBJECT.memoObjects.push(memoObject);
                }
            }
        }

        for (var nIndex = 0; nIndex < CONTENTVIEW_CREATEOBJECT.memoObjects.length; nIndex++) {
            var tempObj = CONTENTVIEW_CREATEOBJECT.memoObjects[nIndex];
            tempObj.drawMemo(context, opt);
        }

        //End Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
    }
};

/* draw webGetContent4 */
CONTENTVIEW.drawGetWebContent4 = function(context, opt) {
	CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects = [];
    //Start Function : No.4 - Editor : Long - Date: 08/14/2013 - Summary : For lazy loading
    var tempIndex = 0;

    if(opt == 0 || opt == null){
        tempIndex = CONTENTVIEW_GETDATA.getPageIndex();
    }
    else if(opt == 1){
        tempIndex = CONTENTVIEW_GETDATA.getPageIndex() + 1;
    }
    else if(opt == 2){
        tempIndex = CONTENTVIEW_GETDATA.getPageIndex() - 1;
    }

    for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.dataJsonType4.length; nIndex++) {
        /* get data belong current page*/
        var dataLinkList = CONTENTVIEW_GENERAL.dataJsonType4[nIndex].linkList;
        for (var nLinkList = 0; nLinkList < dataLinkList.length; nLinkList++) {
            /* create object webContentTyp4 */
            var dataObject = null;

            dataObject = new CONTENTVIEW_CREATEOBJECT.webContentType4(
                nLinkList,
                dataLinkList[nLinkList].linkLocationX,
                dataLinkList[nLinkList].linkLocationY,
                dataLinkList[nLinkList].linkLocationWidth,
                dataLinkList[nLinkList].linkLocationHeight,
                "img/webGetContent4.png",
                dataLinkList[nLinkList].linkKind,
                dataLinkList[nLinkList].destURI,
                dataLinkList[nLinkList].destPageNumber
            );

            dataObject["pageNo"] = CONTENTVIEW_GENERAL.dataJsonType4[nIndex].page;
            CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects.push(dataObject);

            //Start Fix Bug : Cannot not click on link object - Editor : Long - Date : 08/30/2013
            if (CONTENTVIEW.changePageIndex(tempIndex) == dataObject["pageNo"]) {
                dataObject.drawObject(context, opt);
            }
            //End Fix Bug : Cannot not click on link object - Editor : Long - Date : 08/30/2013
        }
    }
    //End Function : No.4 - Editor : Long - Date: 08/14/2013 - Summary : For lazy loading
};

//Start Function : No.4 - Editor : Long - Date: 08/14/2013 - Summary : For lazy loading
/* draw marking */
CONTENTVIEW.drawMarkingOnScreen = function(opt) {

    var canvas;
    var context;
    var canvasWidth = $('#offscreen').width();
    var canvasHeight = $('#offscreen').height();
    var indexMarking;

    var tempPageNo = 0;

    if(opt == null || opt == 0){
        canvas = document.getElementById('offscreen');
        canvasWidth = $('#offscreen').width();
        canvasHeight = $('#offscreen').height();

        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex());
    }
    else if(opt == 1){
        canvas = document.getElementById('offscreenNext');
        canvasWidth = $('#offscreenNext').width();
        canvasHeight = $('#offscreenNext').height();

        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() + 1);
    }
    else if(opt == 2){
        canvas = document.getElementById('offscreenPre');
        canvasWidth = $('#offscreenPre').width();
        canvasHeight = $('#offscreenPre').height();

        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() - 1);
    }

    context = canvas.getContext('2d');

    if (ClientData.IsAddingMarking() == false && ClientData.IsDisplayMarking() == true) {
    	CONTENTVIEW.isExistDrawing = false;

        /* get data marking on local */
        var dataMarking = ClientData.MarkingData();
        for (var nIndex = 0; nIndex < dataMarking.length; nIndex++) {
            if (dataMarking[nIndex].contentid == CONTENTVIEW_GENERAL.contentID
            && dataMarking[nIndex].pageNo == tempPageNo) {
                /*create image */
                var img = new Image();
                img.onload = function () {
                    //context.drawImage(img,dataMarking[indexMarking].left,0,dataMarking[indexMarking].right - dataMarking[indexMarking].left,dataMarking[indexMarking].bottom - dataMarking[indexMarking].top,0,0,canvasWidth,canvasHeight);
                    context.drawImage(img, 0, 0, canvasWidth, canvasHeight);
                    CONTENTVIEW.flip(opt);
                    /* set flag */
                    CONTENTVIEW.isExistDrawing = true;
                    /* draw memo */
                    CONTENTVIEW.drawMemoOnScreen(opt);
                };
                img.src = dataMarking[nIndex].content;
                indexMarking = nIndex;
            }
        }

        if (CONTENTVIEW.isExistDrawing == false) {
            /* draw memo */
        	CONTENTVIEW.drawMemoOnScreen(opt);
        }
    } else {
        /* draw memo */
    	CONTENTVIEW.drawMemoOnScreen(opt);
    }
};

/*draw canvas*/
CONTENTVIEW.draw = function(context, opt) {
    context.save();

    //Draw on main canvas
    if(opt==null || opt == 0){
        /* draw page objects */
        CONTENTVIEW_GETDATA.getContent().currentPage.drawPage(context);
    }
    //Draw on next canvas
    else if(opt == 1){
    	CONTENTVIEW_GENERAL.getNextContent().currentPage.drawPage(context, 1);
    }
    //Draw on previous canvas
    else if(opt == 2){
    	CONTENTVIEW_GENERAL.getPrevContent().currentPage.drawPage(context, 2);
    }

    context.restore();

    CONTENTVIEW_INITOBJECT.initImageCheckMarking();
    CONTENTVIEW_INITOBJECT.initImageCheckMemo();
};
//End Function : No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw multi canvas


//Start Function : No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw multi canvas
/* display to screen */
CONTENTVIEW.flip = function(opt) {
    var canvas;
    var offscreen;

    if(opt==null || opt == 0){
        canvas = document.getElementById('main');
        offscreen = document.getElementById('offscreen');
    }else if(opt==1){
        canvas = document.getElementById('mainNext');
        offscreen = document.getElementById('offscreenNext');
    }else if(opt==2){
        canvas = document.getElementById('mainPre');
        offscreen = document.getElementById('offscreenPre');
    }

    var context = canvas.getContext('2d');

    //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
    // init rect
    if(opt==null || opt == 0){
        if (CONTENTVIEW.srcRect.width == 0) {
        	CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offscreen.width, offscreen.height);
        }
    }
    else if(opt==1){
    	CONTENTVIEW.srcRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offscreen.width, offscreen.height);
    }
    else if(opt==2){
    	CONTENTVIEW.srcRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offscreen.width, offscreen.height);
    }
    //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content

    if(opt==null || opt==0){

        // display rect
    	CONTENTVIEW.srcRect.add(CONTENTVIEW.moveX, CONTENTVIEW.moveY);

        // fix rect
        if (CONTENTVIEW.srcRect.left < 0) {
        	CONTENTVIEW.srcRect.left = 0;
        	CONTENTVIEW.srcRect.right = CONTENTVIEW.srcRect.left + CONTENTVIEW.srcRect.width;
        } else if (CONTENTVIEW.srcRect.right > offscreen.width) {
        	CONTENTVIEW.srcRect.left = offscreen.width - CONTENTVIEW.srcRect.width;
        	CONTENTVIEW.srcRect.right = offscreen.width
        }
        if (CONTENTVIEW.srcRect.top < 0) {
        	CONTENTVIEW.srcRect.top = 0;
        	CONTENTVIEW.srcRect.bottom = CONTENTVIEW.srcRect.top + CONTENTVIEW.srcRect.height;
        } else if (CONTENTVIEW.srcRect.bottom > offscreen.height) {
        	CONTENTVIEW.srcRect.top = offscreen.height - CONTENTVIEW.srcRect.height;
        	CONTENTVIEW.srcRect.bottom = offscreen.height;
        }

        // target rect
        var width = offscreen.width;
        var height = offscreen.height;
        var aspect = offscreen.width / offscreen.height;

        if (canvas.width > canvas.height) {
            height = canvas.height;
            width = height * aspect;
        } else {
            width = canvas.width;
            height = width / aspect;
        }

        if (height > canvas.height) {
            var size = canvas.height / height;
            height = canvas.height;
            width = width * size;
        }

        if (width > canvas.width) {
            var size = canvas.width / width;
            width = canvas.width;
            height = height * size;
        }

        if (CONTENTVIEW.userScale != 1 && width < canvas.width) {

            width = width * CONTENTVIEW.userScale;
            if (width > canvas.width) {
                width = canvas.width;
            }

        } else if (CONTENTVIEW.userScale != 1 && height < canvas.height) {

            height = height * CONTENTVIEW.userScale;

            if (height > canvas.height) {
                height = canvas.height;
            }
        }

        var destX = 0, destY = 0;
        destX = (canvas.width / 2) - (width / 2);
        destY = (canvas.height / 2) - (height / 2);

        if (destX < 0) {
            destX = 0;
        }
        if (destY < 0) {
            destY = 0;
        }

        if (CONTENTVIEW.srcRect.left < 0) {
        	CONTENTVIEW.srcRect.left = 0;
        }
        if (CONTENTVIEW.srcRect.top < 0) {
        	CONTENTVIEW.srcRect.top = 0;
        }

        CONTENTVIEW.destRect = new CONTENTVIEW_CREATEOBJECT.Rect(destX, destY, width, height);

        /* get position for drawing canvas*/
        if (CONTENTVIEW_GENERAL.isFirstLoad == true) {
        	CONTENTVIEW_GENERAL.nPositionCanvas.left = CONTENTVIEW.destRect.left;
        	CONTENTVIEW_GENERAL.nPositionCanvas.right = CONTENTVIEW.destRect.right;
        	CONTENTVIEW_GENERAL.nPositionCanvas.top = CONTENTVIEW.destRect.top;
        	CONTENTVIEW_GENERAL.nPositionCanvas.bottom = CONTENTVIEW.destRect.bottom;

            $("#draw_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
                  .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
                   .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);

            $("#marker_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
                  .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
                   .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);

            CONTENTVIEW_GENERAL.isFirstLoad = false;
        }

        CONTENTVIEW.leftCanvas = destX;
        CONTENTVIEW.topCanvas = destY;
        // change scale
        CONTENTVIEW.scaleX = offscreen.width / width;
        CONTENTVIEW.scaleY = offscreen.height / height;

        // draw canvas
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.save();

        context.drawImage(offscreen,
        		CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
        		CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
        context.restore();
    }
    else if(opt==1){
        // display rect
        //CONTENTVIEW.srcRectNext.add(CONTENTVIEW.moveX, CONTENTVIEW.moveY);

        // fix rect
        if (CONTENTVIEW.srcRectNext.left < 0) {
        	CONTENTVIEW.srcRectNext.left = 0;
        	CONTENTVIEW.srcRectNext.right = CONTENTVIEW.srcRectNext.left + CONTENTVIEW.srcRectNext.width;
        } else if (CONTENTVIEW.srcRectNext.right > offscreen.width) {
        	CONTENTVIEW.srcRectNext.left = offscreen.width - CONTENTVIEW.srcRectNext.width;
        	CONTENTVIEW.srcRectNext.right = offscreen.width
        }
        if (CONTENTVIEW.srcRectNext.top < 0) {
        	CONTENTVIEW.srcRectNext.top = 0;
        	CONTENTVIEW.srcRectNext.bottom = CONTENTVIEW.srcRectNext.top + CONTENTVIEW.srcRectNext.height;
        } else if (CONTENTVIEW.srcRectNext.bottom > offscreen.height) {
        	CONTENTVIEW.srcRectNext.top = offscreen.height - CONTENTVIEW.srcRectNext.height;
        	CONTENTVIEW.srcRectNext.bottom = offscreen.height;
        }

        // target rect
        var width = offscreen.width;
        var height = offscreen.height;
        var aspect = offscreen.width / offscreen.height;

        if (canvas.width > canvas.height) {
            height = canvas.height;
            width = height * aspect;
        } else {
            width = canvas.width;
            height = width / aspect;
        }

        if (height > canvas.height) {
            var size = canvas.height / height;
            height = canvas.height;
            width = width * size;
        }

        if (width > canvas.width) {
            var size = canvas.width / width;
            width = canvas.width;
            height = height * size;
        }

        if (CONTENTVIEW.userScale != 1 && width < canvas.width)
        {

            width = width * CONTENTVIEW.userScale;
            if (width > canvas.width) {
                width = canvas.width;
            }

        }
        else if (CONTENTVIEW.userScale != 1 && height < canvas.height) {

            height = height * CONTENTVIEW.userScale;

            if (height > canvas.height) {
                height = canvas.height;
            }
        }

        var destX = 0, destY = 0;
        destX = (canvas.width / 2) - (width / 2);
        destY = (canvas.height / 2) - (height / 2);

        if (destX < 0) {
            destX = 0;
        }
        if (destY < 0) {
            destY = 0;
        }

        if (CONTENTVIEW.srcRectNext.left < 0) {
        	CONTENTVIEW.srcRectNext.left = 0;
        }
        if (CONTENTVIEW.srcRectNext.top < 0) {
        	CONTENTVIEW.srcRectNext.top = 0;
        }

        CONTENTVIEW.destRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(destX, destY, width, height);

        /* get position for drawing canvas*/
        if (CONTENTVIEW_GENERAL.isFirstLoad == true) {
        	CONTENTVIEW_GENERAL.nPositionCanvas.left = CONTENTVIEW.destRectNext.left;
        	CONTENTVIEW_GENERAL.nPositionCanvas.right = CONTENTVIEW.destRectNext.right;
        	CONTENTVIEW_GENERAL.nPositionCanvas.top = CONTENTVIEW.destRectNext.top;
        	CONTENTVIEW_GENERAL.nPositionCanvas.bottom = CONTENTVIEW.destRectNext.bottom;

            $("#draw_canvas").attr('height', CONTENTVIEW.destRectNext.bottom - CONTENTVIEW.destRectNext.top)
                  .attr('width', CONTENTVIEW.destRectNext.right - CONTENTVIEW.destRectNext.left)
                   .css('top', CONTENTVIEW.destRectNext.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectNext.left + CONTENTVIEW.marginX);

            $("#marker_canvas").attr('height', CONTENTVIEW.destRectNext.bottom - CONTENTVIEW.destRectNext.top)
                  .attr('width', CONTENTVIEW.destRectNext.right - CONTENTVIEW.destRectNext.left)
                   .css('top', CONTENTVIEW.destRectNext.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectNext.left + CONTENTVIEW.marginX);

            CONTENTVIEW_GENERAL.isFirstLoad = false;
        }

        //CONTENTVIEW.leftCanvas = destX;
        //CONTENTVIEW.topCanvas = destY;
        // change scale
        //CONTENTVIEW.scaleX = offscreen.width / width;
        //CONTENTVIEW.scaleY = offscreen.height / height;

        // draw canvas
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.save();

        context.drawImage(offscreen,
        		CONTENTVIEW.srcRectNext.left, CONTENTVIEW.srcRectNext.top, CONTENTVIEW.srcRectNext.right - CONTENTVIEW.srcRectNext.left, CONTENTVIEW.srcRectNext.bottom - CONTENTVIEW.srcRectNext.top,
        		CONTENTVIEW.destRectNext.left, CONTENTVIEW.destRectNext.top, width, height);
        context.restore();
    }
    else if(opt==2){
        // display rect
        //CONTENTVIEW.srcRectNext.add(CONTENTVIEW.moveX, CONTENTVIEW.moveY);

        // fix rect
        if (CONTENTVIEW.srcRectPrev.left < 0) {
        	CONTENTVIEW.srcRectPrev.left = 0;
        	CONTENTVIEW.srcRectPrev.right = CONTENTVIEW.srcRectPrev.left + CONTENTVIEW.srcRectPrev.width;
        } else if (CONTENTVIEW.srcRectNext.right > offscreen.width) {
        	CONTENTVIEW.srcRectPrev.left = offscreen.width - CONTENTVIEW.srcRectPrev.width;
        	CONTENTVIEW.srcRectPrev.right = offscreen.width
        }
        if (CONTENTVIEW.srcRectPrev.top < 0) {
        	CONTENTVIEW.srcRectPrev.top = 0;
        	CONTENTVIEW.srcRectPrev.bottom = CONTENTVIEW.srcRectPrev.top + CONTENTVIEW.srcRectPrev.height;
        } else if (CONTENTVIEW.srcRectPrev.bottom > offscreen.height) {
        	CONTENTVIEW.srcRectPrev.top = offscreen.height - CONTENTVIEW.srcRectPrev.height;
        	CONTENTVIEW.srcRectPrev.bottom = offscreen.height;
        }

        // target rect
        var width = offscreen.width;
        var height = offscreen.height;
        var aspect = offscreen.width / offscreen.height;

        if (canvas.width > canvas.height) {
            height = canvas.height;
            width = height * aspect;
        } else {
            width = canvas.width;
            height = width / aspect;
        }

        if (height > canvas.height) {
            var size = canvas.height / height;
            height = canvas.height;
            width = width * size;
        }

        if (width > canvas.width) {
            var size = canvas.width / width;
            width = canvas.width;
            height = height * size;
        }

        if (CONTENTVIEW.userScale != 1 && width < canvas.width)
        {

            width = width * CONTENTVIEW.userScale;
            if (width > canvas.width) {
                width = canvas.width;
            }

        }
        else if (CONTENTVIEW.userScale != 1 && height < canvas.height) {

            height = height * CONTENTVIEW.userScale;

            if (height > canvas.height) {
                height = canvas.height;
            }
        }

        var destX = 0, destY = 0;
        destX = (canvas.width / 2) - (width / 2);
        destY = (canvas.height / 2) - (height / 2);

        if (destX < 0) {
            destX = 0;
        }
        if (destY < 0) {
            destY = 0;
        }

        if (CONTENTVIEW.srcRectPrev.left < 0) {
        	CONTENTVIEW.srcRectPrev.left = 0;
        }
        if (CONTENTVIEW.srcRectPrev.top < 0) {
        	CONTENTVIEW.srcRectPrev.top = 0;
        }

        CONTENTVIEW.destRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(destX, destY, width, height);

        /* get position for drawing canvas*/
        if (CONTENTVIEW_GENERAL.isFirstLoad == true) {
        	CONTENTVIEW_GENERAL.nPositionCanvas.left = CONTENTVIEW.destRectPrev.left;
        	CONTENTVIEW_GENERAL.nPositionCanvas.right = CONTENTVIEW.destRectPrev.right;
        	CONTENTVIEW_GENERAL.nPositionCanvas.top = CONTENTVIEW.destRectPrev.top;
        	CONTENTVIEW_GENERAL.nPositionCanvas.bottom = CONTENTVIEW.destRectPrev.bottom;

            $("#draw_canvas").attr('height', CONTENTVIEW.destRectPrev.bottom - CONTENTVIEW.destRectPrev.top)
                  .attr('width', CONTENTVIEW.destRectPrev.right - CONTENTVIEW.destRectPrev.left)
                   .css('top', CONTENTVIEW.destRectPrev.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectPrev.left + CONTENTVIEW.marginX);

            $("#marker_canvas").attr('height', CONTENTVIEW.destRectPrev.bottom - CONTENTVIEW.destRectPrev.top)
                  .attr('width', CONTENTVIEW.destRectPrev.right - CONTENTVIEW.destRectPrev.left)
                   .css('top', CONTENTVIEW.destRectPrev.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectPrev.left + CONTENTVIEW.marginX);

            CONTENTVIEW_GENERAL.isFirstLoad = false;
        }

        // draw canvas
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.save();

        context.drawImage(offscreen,
        		CONTENTVIEW.srcRectPrev.left, CONTENTVIEW.srcRectPrev.top, CONTENTVIEW.srcRectPrev.right - CONTENTVIEW.srcRectPrev.left, CONTENTVIEW.srcRectPrev.bottom - CONTENTVIEW.srcRectPrev.top,
        		CONTENTVIEW.destRectPrev.left, CONTENTVIEW.destRectPrev.top, width, height);
        context.restore();
    }
};
//End Function : No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw multi canvas

/* show video*/
CONTENTVIEW.showVideoObject = function(x, y, width, height, src, isFullscreen) {

    var pt1 = CONTENTVIEW.imageToScreen(x, y);
    var pt2 = CONTENTVIEW.imageToScreen(x + width, y + height);

    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
        pt2.y = pt2.y - CONTENTVIEW.marginY;
        pt1.y = pt1.y - CONTENTVIEW.marginY;
    }

    //CONTENTVIEW_GETDATA.getPosVideo(x, y, (pt2.x - pt1.x), (pt2.y - pt1.y));
    CONTENTVIEW_GETDATA.getPosVideo(x, y, width, height);

    if (isFullscreen === false) {
        $('#playvideo').attr('z-order', '10000');
        $('#playvideo').css('left', pt1.x + 'px');
        $('#playvideo').css('top', pt1.y + 'px');
        $('#playvideo').children().remove();

        if (ClientData.userOpt_videoMode() == "1") {/* loop video */
            $('#playvideo').html('<video class="mov" id="videoOnPage" ' +
                             'width="' + (pt2.x - pt1.x) + '" ' +
                             'height="' + (pt2.y - pt1.y) + '" ' +
                             'autoplay controls loop>' +
                             '   <source src="' + src + '" type="video/mp4"> ' +
                             //'   <source src="' + src + '&key=' + (new Date()).toIdString() + '" type="video/mp4"> ' +
                             //'   <source src="' + src + '&key=' + (new Date()).toIdString() + '" type="video/ogg"> ' +
                             '</video>'
                );

        } else {
            $('#playvideo').html('<video class="mov" id="videoOnPage"' +
                             'width="' + (pt2.x - pt1.x) + '" ' +
                             'height="' + (pt2.y - pt1.y) + '" ' +
                             'autoplay controls>' +
                             //'   <source src="' + src + '&key=' + (new Date()).toIdString() + '" type="video/mp4"> ' +
                             '   <source src="' + src + '" type="video/mp4"> ' +
                             '</video>'
                );
        }
    } else {
        $('#playvideo').attr('z-order', '1000');
        $('#playvideo').html('<video class="mov" id="videoOnPage" src="' + src + '" ' +
                         'autoplay controls></video>');
    }

    //CONTENTVIEW.showControlsVideo($('#videoOnPage'));

};

/* stop all audio on page */
CONTENTVIEW.stopAllAudio = function() {
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
        $('#playaudiopage').children().remove();
        $('#playaudioallpage').children().remove();
        $('#playaudio').children().remove();
    } else {
        if (document.getElementById("play_audio_0") != undefined) {
            if(document.getElementById("play_audio_0").played){
               document.getElementById("play_audio_0").pause();
            }
        }

        if (document.getElementById("play_audio_1") != undefined) {
            if(document.getElementById("play_audio_1").played){
               document.getElementById("play_audio_1").pause();
            }
        }

        if (document.getElementById("play_audio_2") != undefined) {
            document.getElementById("play_audio_2").pause();

            if(document.getElementById("play_audio_2").played){
               document.getElementById("play_audio_2").pause();
            }
        }
    }
};

/* play all audio on page */
CONTENTVIEW.playAllAudio = function() {
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
        if (CONTENTVIEW.srcAudioType0 != '') {
        	CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW.srcAudioType0, CONTENTVIEW.TypeAudio0);
        } else if (CONTENTVIEW.srcAudioType2 != '') {
        	CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW.srcAudioType2, CONTENTVIEW.TypeAudio2);
        } else if (CONTENTVIEW.TypeAudio1 != '') {
        	CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW.srcAudioType1, CONTENTVIEW.TypeAudio1);
        }
    } else {
        if (document.getElementById("play_audio_0") != undefined) {
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                //document.getElementById("play_audio_0").load();
            }
            document.getElementById("play_audio_0").play();
        } else if (document.getElementById("play_audio_2") != undefined) {
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                //document.getElementById("play_audio_2").load();
            }
            document.getElementById("play_audio_2").play();
        } else if (document.getElementById("play_audio_1") != undefined) {
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                //document.getElementById("play_audio_1").load();
            }
            document.getElementById("play_audio_1").play();
        }
    }
};


/* change main image of media type 4 */
CONTENTVIEW.changeImageType4 = function(objTarget, nIndex, nIndex1) {
    var imageObj = new Image();
    imageObj.onload = function () {
        var canvasObject = document.getElementById("offscreen");
        var contextObject = canvasObject.getContext("2d");

        //#11478
        var canvasWidth = $('#offscreen').width();
        var canvasHeight = $('#offscreen').height();
        var tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPageApi;
        if( tempRatioWidth < 1 ){
            tempRatioWidth = 1;
        }
        var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachPageApi;
        if( tempRatioHeight < 1 ){
            tempRatioHeight = 1;
        }
        var tmpX = objTarget[nIndex].x *  tempRatioWidth;
        var tmpY = objTarget[nIndex].y * tempRatioHeight;
        var tmpW = objTarget[nIndex].width *  tempRatioWidth;
        var tmpH = objTarget[nIndex].height * tempRatioHeight;

        contextObject.drawImage(imageObj, tmpX, tmpY, tmpW, tmpH);
        //contextObject.drawImage(imageObj, objTarget[nIndex].x, objTarget[nIndex].y, objTarget[nIndex].width, objTarget[nIndex].height);

        CONTENTVIEW.flip();
    };
    imageObj.src = objTarget[nIndex].dataObjects[nIndex1].fileName;
};

CONTENTVIEW.imageToScreen = function(x, y) {

    //#11478
    var canvasWidth = $('#offscreen').width();
    var canvasHeight = $('#offscreen').height();
    var tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPageApi;
    if( tempRatioWidth < 1 ){
        tempRatioWidth = 1;
    }
    var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachPageApi;
    if( tempRatioHeight < 1 ){
        tempRatioHeight = 1;
    }
    var tmpX = x *  tempRatioWidth;
    var tmpY = y * tempRatioHeight;

    var pt = new CONTENTVIEW.Point(0, 0);

    // scale vertical and horizontal
    var sx = (CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left) / (CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left);
    var sy = (CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top) / (CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top);

    pt.x = Math.round(sx * (tmpX - CONTENTVIEW.srcRect.left)) + CONTENTVIEW.destRect.left + CONTENTVIEW.marginX;
    pt.y = Math.round(sy * (tmpY - CONTENTVIEW.srcRect.top)) + CONTENTVIEW.destRect.top + CONTENTVIEW.marginY;

    return pt;
};
//Start Function : No.4 - Editor : Long - Date : 08/09/2013 - Summary :
/* Adjust Component size */
CONTENTVIEW.sizingNotFull = function(width, height) {

    //START TRB
    if(CONTENTVIEW.isMediaAndHTMLContent()){

    }
    //END TRB
    else{
        //adjust size of canvas using for draw
        if (COMMON.isTouchDevice() == true) {
            $("#main").css('top', CONTENTVIEW.marginY);
            $("#main").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2));
            $("#mainNext").css('top', CONTENTVIEW.marginY);
            $("#mainPre").css('top', CONTENTVIEW.marginY);

            $("#mainNext").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
              .css('left', width + CONTENTVIEW.marginX);

            $("#mainPre").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
              .css('left', - (width + CONTENTVIEW.marginX));

        } else {
            $("#main").attr('height', height - (CONTENTVIEW.marginY * 2))
                  .attr('width', width - (CONTENTVIEW.marginX * 2))
                   .css('top', CONTENTVIEW.marginY);

            $("#mainNext").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
               .css('top', CONTENTVIEW.marginY)
               .css('left', width + CONTENTVIEW.marginX);

            $("#mainPre").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
               .css('top', CONTENTVIEW.marginY)
               .css('left', -(width + CONTENTVIEW.marginX));

        }

        $("#draw_canvas").css('cursor', 'default');
        $("#marker_canvas").css('cursor', 'default');

        if (CONTENTVIEW.userScale != 1) {
        	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
        }

        /* move image check marking*/
        $('#divCheckExistMarking').css('top', '70px');
        $('#divCheckExistMarking').show();

        /* move image check memo*/
        $('#divCheckExistMemo').css('top', '125px');
        $('#divCheckExistMemo').show();
    }
};

/* Adjust Component size */
CONTENTVIEW.sizingFullSize = function(width, height) {
    // adjust size of body

    //START TRB
    if(CONTENTVIEW.isMediaAndHTMLContent()){

    }
    //END TRB
    else{
        if (COMMON.isTouchDevice() == true) {
            $("#main").css('top', '0px');
            $("#main").attr('height', height)
                       .attr('width', width - (CONTENTVIEW.marginX * 2));

            $("#mainNext").css('top', '0px');
            $("#mainNext").attr('height', height)
                       .attr('width', width - (CONTENTVIEW.marginX * 2));

            $("#mainPre").css('top', '0px');
            $("#mainPre").attr('height', height)
                       .attr('width', width - (CONTENTVIEW.marginX * 2));
        } else {
            $("#main").attr('height', height)
                       .attr('width', width - (CONTENTVIEW.marginX * 2))
                       .css('top', '0px');
            $("#mainNext").attr('height', height)
                        .attr('width', width - (CONTENTVIEW.marginX * 2))
                    .css('top', '0px');
            $("#mainPre").attr('height', height)
                    .attr('width', width - (CONTENTVIEW.marginX * 2))
                .css('top', '0px');
        }

        //adjust size of canvas using for draw

        $("#draw_canvas").css('cursor', 'default');
        $("#marker_canvas").css('cursor', 'default');

        if (CONTENTVIEW.userScale != 1) {
        	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
        }

        /* move image check marking*/
        $('#divCheckExistMarking').css('top', '5px');
        if (ClientData.IsAddingMarking() == true) {
            $('#divCheckExistMarking').hide();
        } else {
            $('#divCheckExistMarking').show();
        }

        /* move image check memo*/
        $('#divCheckExistMemo').css('top', '60px');
        if (ClientData.IsAddingMemo() == true) {
            $('#divCheckExistMemo').hide();
        } else {
            $('#divCheckExistMemo').show();
        }
    }
};
//End Function : No.4 - Editor : Long - Date : 08/09/2013 - Summary :
CONTENTVIEW.zoomVideo = function() {
    var objVideo = document.getElementsByTagName('video');
    if (objVideo.length > 0) {
        var pt1 = CONTENTVIEW.imageToScreen(CONTENTVIEW_GENERAL.pxVideo, CONTENTVIEW_GENERAL.pyVideo);
        var pt2 = CONTENTVIEW.imageToScreen(CONTENTVIEW_GENERAL.pxVideo + CONTENTVIEW_GENERAL.wVideo, CONTENTVIEW_GENERAL.pyVideo + CONTENTVIEW_GENERAL.hVideo);

        if (CONTENTVIEW_GENERAL.isFullScreen == true) {
            pt2.y = pt2.y - CONTENTVIEW.marginY;
            pt1.y = pt1.y - CONTENTVIEW.marginY;
        }
        $('#playvideo').attr('z-order', '1000');

        $('#playvideo').css('left', pt1.x + 'px');
        $('#playvideo').css('top', pt1.y + 'px');

        $(objVideo[0]).attr('width', pt2.x - pt1.x);
        $(objVideo[0]).attr('height', pt2.y - pt1.y);
    }
};

// Adds ctx.getTransform() - returns an SVGMatrix
// Adds ctx.transformedPoint(x,y) - returns an SVGPoint
CONTENTVIEW.trackTransforms = function(ctx) {
    var svg = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
    var xform = svg.createSVGMatrix();
    ctx.getTransform = function () { return xform; };

    var savedTransforms = [];
    var save = ctx.save;
    ctx.save = function () {
        savedTransforms.push(xform.translate(0, 0));
        return save.call(ctx);
    };
    var restore = ctx.restore;
    ctx.restore = function () {
        xform = savedTransforms.pop();
        return restore.call(ctx);
    };

    var scale = ctx.scale;
    ctx.scale = function (sx, sy) {
        xform = xform.scaleNonUniform(sx, sy);
        return scale.call(ctx, sx, sy);
    };
    var rotate = ctx.rotate;
    ctx.rotate = function (radians) {
        xform = xform.rotate(radians * 180 / Math.PI);
        return rotate.call(ctx, radians);
    };
    var translate = ctx.translate;
    ctx.translate = function (dx, dy) {
        xform = xform.translate(dx, dy);
        return translate.call(ctx, dx, dy);
    };
    var transform = ctx.transform;
    ctx.transform = function (a, b, c, d, e, f) {
        var m2 = svg.createSVGMatrix();
        m2.a = a; m2.b = b; m2.c = c; m2.d = d; m2.e = e; m2.f = f;
        xform = xform.multiply(m2);
        return transform.call(ctx, a, b, c, d, e, f);
    };
    var setTransform = ctx.setTransform;
    ctx.setTransform = function (a, b, c, d, e, f) {
        xform.a = a;
        xform.b = b;
        xform.c = c;
        xform.d = d;
        xform.e = e;
        xform.f = f;
        return setTransform.call(ctx, a, b, c, d, e, f);
    };
    var pt = svg.createSVGPoint();
    ctx.transformedPoint = function (x, y) {
        pt.x = x; pt.y = y;
        return pt.matrixTransform(xform.inverse());
    }
};

/* zoomIn event */
CONTENTVIEW.zoomIn = function() {
	CONTENTVIEW.userScale += CONTENTVIEW.scaleDelta;

    if (CONTENTVIEW.userScale > 4) {
    	CONTENTVIEW.userScale = 4;
    }
    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();

    /* close dialog popuptext */
    CONTENTVIEW.closeDialogPopUpText();
};

/* close dialog pop */
CONTENTVIEW.closeDialogPopUpText = function() {
    if (CONTENTVIEW_GENERAL.isOpenPopUpText == true) {
    	CONTENTVIEW_GENERAL.isOpenPopUpText = false;
    	CONTENTVIEW_POPUPTEXT.ClosePopupText();
    }
};

CONTENTVIEW.checkDisableButtonZoom = function() {
    if (CONTENTVIEW.userScale >= 4) {
        $('#zoomin').removeClass();
        $('#zoomin').addClass('expansion_off');
        $("#zoomin").css('cursor', 'default');
    } else {
        $('#zoomin').unbind('click');
        $('#zoomin').bind('click', CONTENTVIEW.zoomIn);

        $('#zoomin').removeClass();
        if (COMMON.isTouchDevice() == true) {
            $('#zoomin').addClass('expansion_device');
        } else {
            $('#zoomin').addClass('expansion');
        }
        $("#zoomin").css('cursor', 'pointer');
    }

    if (CONTENTVIEW.userScale <= 1) {
        $('#zoomout').removeClass();
        $('#zoomout').addClass('reduction_off');
        $("#zoomout").css('cursor', 'default');
    } else {
        $('#zoomout').unbind('click');
        $('#zoomout').bind('click', CONTENTVIEW.zoomOut);

        $('#zoomout').removeClass();
        if (COMMON.isTouchDevice() == true) {
            $('#zoomout').addClass('reduction_device');
        } else {
            $('#zoomout').addClass('reduction');
        }
        $("#zoomout").css('cursor', 'pointer');
    }

    if (CONTENTVIEW.userScale == 1) {
        $('#zoomfit').removeClass();
        $('#zoomfit').addClass('fit_off');
        $("#zoomfit").css('cursor', 'default');
    } else {
        $('#zoomfit').unbind('click');
        $('#zoomfit').bind('click', CONTENTVIEW.screenFit);

        $('#zoomfit').removeClass();
        if (COMMON.isTouchDevice() == true) {
            $('#zoomfit').addClass('fit_device');
        } else {
            $('#zoomfit').addClass('fit');
        }
        $("#zoomfit").css('cursor', 'pointer');
    }
};

/* zoomOut event */
CONTENTVIEW.zoomOut = function() {
	CONTENTVIEW.userScale -= CONTENTVIEW.scaleDelta;
    if (CONTENTVIEW.userScale < 1) {
    	CONTENTVIEW.userScale = 1;
    } 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();

    /* close dialog popuptext */
    CONTENTVIEW.closeDialogResize();
};

/* restore screen size */
CONTENTVIEW.screenFit = function() {

    var canvas = document.getElementById('main');
    var offScreen = document.getElementById('offscreen');
    CONTENTVIEW_GENERAL.context_main.clearRect(0, 0, CONTENTVIEW_GENERAL.canvas_main.width, CONTENTVIEW_GENERAL.canvas_main.height);
    CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offScreen.width, offScreen.height);
    CONTENTVIEW.userScale = 1;
    CONTENTVIEW.userScaleNow = 1;

    CONTENTVIEW.moveX = 0;
    CONTENTVIEW.moveY = 0;

    CONTENTVIEW.flip();

    //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
    if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
    	CONTENTVIEW.flip(1);
    }

    if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
    	CONTENTVIEW.flip(2);
    }
    //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming

    /* zoom video */
    CONTENTVIEW.zoomVideo();

    CONTENTVIEW.checkDisableButtonZoom();

    /* close dialog popuptext */
    CONTENTVIEW.closeDialogResize();
};

/* change Scale screen*/
CONTENTVIEW.changeScale = function(scale) {

    //拡大か判定
    var isZoom = false;
    if( CONTENTVIEW.userScaleNow < scale ){
        isZoom = true;
    }
    CONTENTVIEW.userScaleNow = scale;

    var canvas = document.getElementById('main');
    var offScreen = document.getElementById('offscreen');

    var sc = CONTENTVIEW.srcRect.center();

    var sw = offScreen.width, sh = offScreen.height;

    var width = offScreen.width;
    var height = offScreen.height;
    var aspect = offScreen.width / offScreen.height;
    if (canvas.width > canvas.height) {
        height = canvas.height;
        width = height * aspect;
        /*if(width > canvas.width) {
        width = canvas.width;
        height = width / aspect;
        }*/
    } else {
        width = canvas.width;
        height = width / aspect;
    }

    if (height > canvas.height) {
        var size = canvas.height / height;
        height = canvas.height;
        width = width * size;
    }

    if (width > canvas.width) {
        var size = canvas.width / width;
        width = canvas.width;
        height = height * size;
    }

    if (width < canvas.width) {

        //if(width >= height){
        width = width * scale;

        if (width > canvas.width) {
            sw /= scale;
            sh = sw / (canvas.width / canvas.height);

        } else {
            sh /= scale;
        }

        //}else if(height <= canvas.height){
    } else if (height < canvas.height) {

        height = height * scale;

        if (height > canvas.height) {
            sh /= scale;
            sw = sh / (canvas.height / canvas.width);


        } else {
            sw /= scale;
        }

    } else {
        sh /= scale;
        sw /= scale;
    }

    CONTENTVIEW.srcRect.left = sc.x - Math.round(sw / 2);
    CONTENTVIEW.srcRect.top = sc.y - Math.round(sh / 2);
    CONTENTVIEW.srcRect.right = Math.round(CONTENTVIEW.srcRect.left + sw);
    CONTENTVIEW.srcRect.bottom = Math.round(CONTENTVIEW.srcRect.top + sh);
    CONTENTVIEW.srcRect.width = CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left;
    CONTENTVIEW.srcRect.height = CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top;

    if( isZoom ){

        //var tempRatioWidth = offScreen.width / CONTENTVIEW_GENERAL.widthEachPageApi;
        var tempRatioWidth = CONTENTVIEW_GENERAL.widthEachPageApi / offScreen.width;
            if( tempRatioWidth > 1 ){
                tempRatioWidth = 1;
            }
        //var tempRatioHeight = offScreen.height / CONTENTVIEW_GENERAL.heightEachPageApi;
        var tempRatioHeight = CONTENTVIEW_GENERAL.heightEachPageApi / offScreen.height;
        if( tempRatioHeight > 1 ){
            tempRatioHeight = 1;
        }


        var tmpX = 0;
        var tmpY = 0;
        if( CONTENTVIEW.srcRect.top > 0 ){
            tmpX = Math.round(CONTENTVIEW.srcRect.top * tempRatioWidth);
        }
        if( CONTENTVIEW.srcRect.left > 0 ){
            tmpY = Math.round(CONTENTVIEW.srcRect.left * tempRatioHeight);
        }

        var tmpW = Math.round(CONTENTVIEW.srcRect.width * tempRatioWidth);
        var tmpH = Math.round(CONTENTVIEW.srcRect.height * tempRatioHeight);

        var zoomX = tmpX + Math.round( tmpH / 2 );
        var zoomY = tmpY + Math.round( tmpW / 2 );

        //console.log("tempRatio.width:height " + tempRatioWidth + "," + tempRatioHeight);
        //console.log("CONTENTVIEW.srcRect.left:top " + CONTENTVIEW.srcRect.left + "," + CONTENTVIEW.srcRect.top);
        //console.log("CONTENTVIEW.srcRect.width:height " + CONTENTVIEW.srcRect.width + "," + CONTENTVIEW.srcRect.height);
        //console.log("tmpX.Y " + tmpX + "," + tmpY);
        //console.log("tmpW.H " + tmpW + "," + tmpH);
        //console.log("zoomX.Y " + zoomX + "," + zoomY);

        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = 0;
        objectLog.resourceId = "";
        objectLog.mediaType = "";
        objectLog.actionType = "101"; //拡大アクション定数
        objectLog.actionValue = "";
        objectLog.actionTime = "0";
        objectLog.locationX = zoomX;
        objectLog.locationY = zoomY;
        objectLog.locationHeight = "";
        objectLog.locationWidth = "";
        objectLog.eventType = "5"; //暫定でピンチアウト
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    }

};

//Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
CONTENTVIEW.is3DObject = function(pageContent){
    var result = false;
    if(pageContent == null || pageContent == undefined){
        result = false;
    }
    else{
        if(pageContent.actionType == 9 && pageContent.mediaType == 8){
            result = true;
        }
    }
    return result;
};
//End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :

//コンテンツ差し替えで最大ページ数を超えるデータは削除
CONTENTVIEW.deleteMaxPageOverData = function() {

	if( CONTENTVIEW_GENERAL.totalPage == 0 ){
		return;
	}

	var removeFlag = false;
	//bookmark
	var listBM = [];
	if (ClientData.BookMarkData().length > 0) {
		//get list bookmark
		listBM = ClientData.BookMarkData();
		for(var tmpIndex=0;tmpIndex<10000;tmpIndex++){
			removeFlag = false;
			for (var nIndex = 0; nIndex < listBM.length; nIndex++) {
				//check bookmark belong contentID
				if (listBM[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listBM[nIndex].pageNo > CONTENTVIEW_GENERAL.totalPage ) {
					//console.log("remove bookmark:" + CONTENTVIEW_GENERAL.contentID + " p:" + listBM[nIndex].pageNo);
					listBM.splice(nIndex, 1);
					removeFlag = true;
					break;
				}
			}
			if( !removeFlag ){
				break;
			}
		}
		ClientData.BookMarkData(listBM);

	}

	//memo
	var listMemo = [];
	if (ClientData.MemoData().length > 0) {
		//get list memo
		listMemo = ClientData.MemoData();
		for(var tmpIndex=0;tmpIndex<10000;tmpIndex++){
			removeFlag = false;
			for (var nIndex = 0; nIndex < listMemo.length; nIndex++) {
				//check memo belong contentID
				if (listMemo[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listMemo[nIndex].pageNo > CONTENTVIEW_GENERAL.totalPage ) {
					//console.log("remove memo:" + CONTENTVIEW_GENERAL.contentID + " p:" + listMemo[nIndex].pageNo);
					listMemo.splice(nIndex, 1);
					removeFlag = true;
					break;
				}
			}
			if( !removeFlag ){
				break;
			}
		}
		ClientData.MemoData(listMemo);
	}

	//marking
	var listMarking = [];
	if (ClientData.MarkingData().length > 0) {
		//get list marking
		listMarking = ClientData.MarkingData();
		for(var tmpIndex=0;tmpIndex<10000;tmpIndex++){
			removeFlag = false;
			for (var nIndex = 0; nIndex < listMarking.length; nIndex++) {
				//check memo belong contentID
				if (listMarking[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listMarking[nIndex].pageNo > CONTENTVIEW_GENERAL.totalPage ) {
					//console.log("remove memo:" + CONTENTVIEW_GENERAL.contentID + " p:" + listMarking[nIndex].pageNo);
					listMarking.splice(nIndex, 1);
					removeFlag = true;
					break;
				}
			}
			if( !removeFlag ){
				break;
			}
		}
		ClientData.MarkingData(listMarking);
	}

};

CONTENTVIEW.cssInit = function(){
	//CSS
	$('html').css({
		'overflow-y':'',
		'overflow': 'hidden'
		});
	$('html,body').css({
		'height':'100%',
		'width':'100%',
		'margin':'',
		'padding':''
		});
	$('html>body').css({
		'font-size':''
		});
	$('body').css({
		'font-family': '"メイリオ", "Meiryo", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "ＭＳ Ｐゴシック", "MS P Gothic", "Osaka", Verdana, Arial, Helvetica, sans-serif',
		'font-size':'',
		'background':'#898989',
		'background-image':'url(./img/viewer/article_bg.png)',
		'color':'',
		'margin':'0',
		'padding':'0'
		});
};

CONTENTVIEW.screenMove = function(){
	CONTENTVIEW.initScreen();
	CONTENTVIEW.ready();
};

//戻る処理
CONTENTVIEW.screenBack = function(){

	//後始末
	CONTENTVIEW.initScreen();

	$("#viewer").hide();
	if( $('#bookshelf').length || $('#list').length ){
		HOME.cssInit();
		$("#header-ws").show();
		$("#ws-body").show();
		$("#topcontrol").show();
		document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
		//console.log("back HOME.scrollTop:" + HOME.scrollTop);
		//元の位置に戻す
		window.scrollTo(0,HOME.scrollTop);

	} else if( $('#bookmark').length ){
		BOOKMARK.cssInit();
		$("#header-ws").show();
		$("#ws-body").show();
		$("#topcontrol").show();
		document.title = I18N.i18nText('dspShiori') + ' | ' + I18N.i18nText('sysAppTitle');
		//元の位置に戻す
		window.scrollTo(0,BOOKMARK.scrollTop);
		BOOKMARK.refreshView();

	} else if( $('#history').length ){

		HISTORY.cssInit();
		$("#header-ws").show();
		$("#ws-body").show();
		$("#topcontrol").show();
		document.title = I18N.i18nText('dspViewHistory') + ' | ' + I18N.i18nText('sysAppTitle');
		//元の位置に戻す
		window.scrollTo(0,HISTORY.scrollTop);

	} else if( $('#contentsearch').length ){
		CONTENTSEARCH.cssInit();
		$("#header-ws").show();
		$("#ws-body").show();
		$("#topcontrol").show();
	 	document.title = I18N.i18nText('txtSearchResult') + ' | ' + I18N.i18nText('sysAppTitle');
		//元の位置に戻す
		window.scrollTo(0,CONTENTSEARCH.scrollTop);

	}
	//プッシュメッセージ再開
	// check new push message
	if (COMMON.isAnonymousLogin() == false ) {
		// continue check new push message
		setTimeout(HEADER.getPushMessageNew, HEADER.getTimeWaitCheckNewPushMessage());
	}

};

CONTENTVIEW.initScreen = function(){

	//画面初期化
	if($('#canvasWrapper').length){
		$('#main').empty();
	}
	if($('#dialog').length){
		$('#dialog').hide();
		$('#dialog').empty();
		$('#dialog').removeClass();
		$('#dialog').removeAttr('style');
		//$('#dialog').attr('style', 'width:');
		$('#dialog').addClass('web_dialog');
	}
	$('#header_toolbar').show();
	$('#txtSearch').val('');
	$('#divCheckExistMarking').hide();
	$('#divCheckExistMemo').hide();
	$('#divCacheLoading').hide();
	$('#overlay').hide();
	$('#dialogPopUp').hide();
	$('#arrow').hide();

	$("#wrapper *").unbind("click");

};

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

CONTENTVIEW.ready = function(initContentId){

	CONTENTVIEW_CALLAPI.ready();
	CONTENTVIEW_EVENTS.ready();
	CONTENTVIEW_GETDATA.ready();
	CONTENTVIEW_INITOBJECT.ready();
	CONTENTVIEW_CREATEOBJECT.ready();
	CONTENTVIEW_GENERAL.ready(initContentId);
	CONTENTVIEW_MEMO.ready();
	CONTENTVIEW_GOMU.ready();
	CONTENTVIEW_MAKER.ready();
	CONTENTVIEW_PEN.ready();
	CONTENTVIEW_MARKING.ready();
	CONTENTVIEW_POPUPTEXT.ready();
	CONTENTVIEW_PAINT.ready();
	CONTENTVIEW_ANKET.ready();
	CONTENTVIEW_3D.ready();
	CONTENTVIEW_CONTENTTYPENONE.ready();
	CONTENTVIEW_IMAGEPREVIEW.ready();
	//CONTENTVIEW_FILESYSTEM.ready();

	CONTENTVIEW.isPendingContentBGM = false;
	CONTENTVIEW.isZoomingContent = false;
	CONTENTVIEW.isShowVideoContent = false;

	/* init variable */
	CONTENTVIEW.content = new CONTENTVIEW_CREATEOBJECT.Content();
	CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
	CONTENTVIEW.destRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
	//START TRB00097
	CONTENTVIEW.srcRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
	CONTENTVIEW.srcRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
	CONTENTVIEW.destRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
	CONTENTVIEW.destRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
	//END TRB00097
	CONTENTVIEW.moveX = 0;
	CONTENTVIEW.moveY = 0;
	CONTENTVIEW.userScale = 1;
	CONTENTVIEW.userScaleNow = 1;
	CONTENTVIEW.scaleDelta = 0.5;
	CONTENTVIEW.scaleX;
	CONTENTVIEW.scaleY;
	CONTENTVIEW.objType4_5 = [];

	CONTENTVIEW.moveFlag = false;
	CONTENTVIEW.cancelClick = false;

	CONTENTVIEW.isExistDrawing = false;

	CONTENTVIEW.leftCanvas = 0;
	CONTENTVIEW.topCanvas = 0;

	CONTENTVIEW.srcAudioType0 = '';
	CONTENTVIEW.TypeAudio0;
	CONTENTVIEW.srcAudioType1 = '';
	CONTENTVIEW.TypeAudio1;
	CONTENTVIEW.srcAudioType2 = '';
	CONTENTVIEW.TypeAudio2;

	CONTENTVIEW.scaleFactor = 1.1;

	/**
	* constants
	*/
	if(ClientData.isStreamingMode() || (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode())){
		CONTENTVIEW.marginX = 13;
		CONTENTVIEW.marginY = 5;
	} else {
		CONTENTVIEW.marginX = 13;
		CONTENTVIEW.marginY = 65;
	}

	if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
		//プレビューモード
	} else {
		/* check login */
		if (!AVWEB.avwCheckLogin(COMMON.ScreenIds.Login)) return;
		// Set event to prevent leave
		COMMON.ToogleLogoutNortice();
		//START TRB00048 - EDITOR : Long - Date : 09/18/2013 - Summary : Fix Jumpcontent
		CONTENTVIEW_GETDATA.getContentID();
	}

    var params = {
    		contentId: CONTENTVIEW_GENERAL.contentID,
    		sid: CONTENTVIEW.getSessionId(),
    		getType: 1,
    		isStreaming: ClientData.isStreamingMode()
    };
    AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
         "webGetContent",
         "GET",
         params,
         function (data) {
        	 CONTENTVIEW_GENERAL.contentType = data.contentData.contentType;

        	 if(ClientData.isStreamingMode()){
        		 //リンク、その他は表示出来ないのでここでブロックする
        		 if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Link || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Others){
	            	 CONTENTVIEW.showAlertScreen(I18N.i18nText('msgStreamingOpenError'), null);
	        		 return;
        		 }
        	 }

            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {

            	if(ClientData.isStreamingMode() || CONTENTVIEW_GENERAL.avwUserEnvObj.isIphone()){
            		//iPhoneの場合はデフォルトのviewportのほうが良いみたい
            		//ClientData.IsRefresh(true);
            	} else {
            		//ストリーミング対応以外では元の設定活かす
            		CONTENTVIEW.setViewportForTouchDevice();
            	}

                if (ClientData.IsRefresh() == true) {
                    //Check if is pdf content
                    if(CONTENTVIEW.isMediaAndHTMLContent()){

                    	CONTENTVIEW_INITOBJECT.initPageMediaAndHtmlType();
                        document.title = data.contentData.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                    }
                    else{
                    	CONTENTVIEW_INITOBJECT.initPage();
                    }

                    //ストリーミングならデバイス側に初期表示済通知
                	if(ClientData.isStreamingMode()){
                		CONTENTVIEW_STREAMING.initPageView();
                	}

                } else {
                	//この処理がないと初回画面描画が出来ない　けど点滅する
                	$('body, html').hide();
                	ClientData.IsRefresh(true);
                	location.reload();
                }
            }
            else {

                //Check if is pdf content
                if(CONTENTVIEW.isMediaAndHTMLContent()){
                	CONTENTVIEW_INITOBJECT.initPageMediaAndHtmlType();

                    //START TRB00059 - EDITOR: Long - Date : 09/19/2013 - Summary : Add title for media and html type
                    document.title = data.contentData.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                    //END TRB00059 - EDITOR: Long - Date : 09/19/2013 - Summary : Add title for media and html type
                }
                else{
                	if(CONTENTVIEW_GENERAL.contentType == "exam" || CONTENTVIEW_GENERAL.contentType == "enquete") {
	            		var isShowResult, isSendResult;
	            		if(CONTENTVIEW_GENERAL.contentType == "exam") {
	            			if(data.contentData.showResult == 1){
		                    	isShowResult = true;
		                    } else {
		                    	isShowResult = false;
		                    }
		                    if(data.contentData.sendResult == 1){
		                    	isSendResult = true;
		                    } else {
		                    	isSendResult = false;
		                    }
	            		}
	                    var contentId = data.contentData.contentId;
	                    var url;
	                    if(CONTENTVIEW_GENERAL.contentType == "exam"){
	                    	url = CONTENTVIEW_GETDATA.getURLPageImage("webEnqueteReply/init") + "&abObjectId=&sid=" + CONTENTVIEW.getSessionId()+"&contentId="+contentId+"&isShowResult="+isShowResult+"&isSendResult="+isSendResult;
	                    } else {
	                    	url = CONTENTVIEW_GETDATA.getURLPageImage("webEnqueteReply/init") + "&abObjectId=&sid=" + CONTENTVIEW.getSessionId()+"&contentId="+contentId;
	                    }
	                    /* init footer toolbar */
	                    $('#footer_toolbar_2').hide();
	                    $('#footer_toolbar_1').show();

	                    /* init pos bottom toolbar*/
	                    CONTENTVIEW_INITOBJECT.initDisplayToolbarDevice();

	                    // Lock screen
	                    if(ClientData.serviceOpt_encryption() != 'Y') {
	                   	 	COMMON.LockScreen();
	                    }

	                    //START TRB00094 - Editor : Long - Date : 09/26/2013 - Summary : Setting log
	                    CONTENTVIEW.StartTimerUpdateLog();

	                    /* set start log */
	                    COMMON.SetStartLog(CONTENTVIEW_GENERAL.contentID);
	                    //END TRB00094 - Editor : Long - Date : 09/26/2013 - Summary : Setting log
	                    CONTENTVIEW_GENERAL.disableAllControl();
	                    //enable SpecifyControl
	                    CONTENTVIEW.enableControlForMediaAndHtmlType();
                       　CONTENTVIEW.displayOverlayForSpecifyContentType(url);
                        $(window).resize(function () {

                           //Check if content is zooming
                           if(CONTENTVIEW.isZoomingContent){
                               //var $container = $("#dialog");
                              // var w = window.innerWidth;
                               //var h = window.innerHeight;

                               //$container.css('height', h);
                               //$container.css('width', w);
                           }
                        });

                        CONTENTVIEW.handleSliderBar();
                        $('#lblSlider').text('/ ' + 1);

                        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
                           $("#slider_page").slider("option", "disabled", true);
                        }

                        COMMON.disable('#txtSearch', '#txtSlider');
                	 }else {
                		CONTENTVIEW_INITOBJECT.initPage();
                	 }
                }

                //ストリーミングならデバイス側に初期表示済通知
            	if(ClientData.isStreamingMode()){
            		CONTENTVIEW_STREAMING.initPageView();
            	}

            }
         },
         function (xmlHttpRequest, txtStatus, errorThrown) {

        	 //ページジャンプ設定をクリア
        	 ClientData.JumpQueue([]);
        	 ClientData.IsJumpBack(false);

        	 var moveScreen = null;
        	 if(!ClientData.isStreamingMode() && !ClientData.isGetitsMode()){
        		 moveScreen = COMMON.ScreenIds.Home;
        	 }

             if (xmlHttpRequest.status == 404) {
            	 CONTENTVIEW.showAlertScreen(I18N.i18nText('msgContentNotExist'), moveScreen);
             }
             else if(xmlHttpRequest.status == 403) {
                 //認証エラー
            	 CONTENTVIEW.showAlertScreen(I18N.i18nText('sysErrorCallApi02'), moveScreen);
             }
             else {
                 // Show system error
            	 AVWEB.showSystemError();
             }
         }
    );
};


CONTENTVIEW.handleDisplayMobileToolbar = function(){

	if($('#menu').length){
		if ($('#menu').is(':hidden')) {
		    // 非表示の場合の処理
			$('#menu').show();
		} else {
		    // 表示されている場合の処理
			$('#menu').hide();
		}
	}

};

CONTENTVIEW.getSessionId = function(){

	if (ClientData.userInfo_sid_local()) {
		return ClientData.userInfo_sid_local();
	} else if (ClientData.userInfo_sid_local_bak()) {
		return ClientData.userInfo_sid_local_bak();
	} else {
		return ClientData.userInfo_sid();
	}

};


