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

CONTENTVIEW_CREATEOBJECT.alertMessageLevel = {
	    ShowAlert : '1',
	    RequirePassword : '2',
	    None : '0'  
};

/* ----------------------------------- Create memo --------------------------------*/

/* constructor */
CONTENTVIEW_CREATEOBJECT.MemoObject = function (id, text, x, y, width, heigth, imageUrl, action) {

};

/* setup each properties */
CONTENTVIEW_CREATEOBJECT.MemoObject.prototype.setup = function (id, text, x, y, w, h, imageUrl) {
    this.text = text;
    this.id = id;
    this.x = x;
    this.y = y;
    this.width = w;
    this.height = h;
    this.imageUrl = imageUrl;
};

/* prototype hitTest */
CONTENTVIEW_CREATEOBJECT.MemoObject.prototype.hitTest = function (px, py) {

    //#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 = this.x * tempRatioWidth;
    var tmpY = this.y * tempRatioHeight;
    var tmpW = this.width * tempRatioWidth;
    var tmpH = this.height * tempRatioHeight;

    if (tmpX <= px && px <= (tmpX + tmpW)) {
        if (tmpY <= py && py <= (tmpY + tmpH)) {
            return true;
        }
    }
    //if (this.x <= px && px <= (this.x + this.width)) {
    //    if (this.y <= py && py <= (this.y + this.height)) {
    //        return true;
    //    }
    //}
    return false;
};

/* draw Memo */
CONTENTVIEW_CREATEOBJECT.MemoObject.prototype.drawMemo = function (context, opt) {

    //#1478
    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 posX = this.x * tempRatioWidth;
    var posY = this.y * tempRatioHeight;
    var objWidth = this.width * tempRatioWidth;
    var objHeigth = this.height * tempRatioHeight;
    //var posX = this.x;
    //var posY = this.y;
    //var objWidth = this.width;
    //var objHeigth = this.height;
    var imageObj = new Image();

    imageObj.onload = function () {
        context.drawImage(imageObj, posX, posY, objWidth, objHeigth);
        CONTENTVIEW.flip(opt);
    };
    imageObj.src = this.imageUrl;

};

/* create memo object */
CONTENTVIEW_CREATEOBJECT.memo = function (id, text, x, y, w, h, imageUrl) {
    this.setup(id, text, x, y, w, h, imageUrl);
    this.action = function () {
    	CONTENTVIEW_MEMO.EditMemo(id, 0, 0, $('#divDialogMemo'), function () {
            /*set flag change memo */
            ClientData.isChangedMemo(true);
        });
    };
};

CONTENTVIEW_CREATEOBJECT.memo.prototype = new CONTENTVIEW_CREATEOBJECT.MemoObject();

/*click showEditMemo() */
CONTENTVIEW_CREATEOBJECT.showEditMemo = function() {
	CONTENTVIEW_GENERAL.objEditMemo.action();
};

/*click copyMemo() */
CONTENTVIEW_CREATEOBJECT.copyMemo = function() {
    //CONTENTVIEW_GENERAL.isCopyMemo = true;
    ClientData.memo_copyText(CONTENTVIEW_GENERAL.objEditMemo.text);
    //CONTENTVIEW.disableControlsCopyMemo();
    $("#pop_up_memo").hide();
};


/* ----------------------------------- End create memo -----------------------------*/


/* ----------------------------------- Create webGetContentType4 --------------------------------*/

/* constructor */
CONTENTVIEW_CREATEOBJECT.WebGetContentTyp4Object = function (id, x, y, width, heigth, imageUrl, action) {

};

/* setup each properties */
CONTENTVIEW_CREATEOBJECT.WebGetContentTyp4Object.prototype.setup = function (id, x, y, w, h, imageUrl) {
    this.id = id;
    this.x = x;
    this.y = y;
    this.width = w;
    this.height = h;
    this.imageUrl = imageUrl;
};

/* prototype hitTest */
CONTENTVIEW_CREATEOBJECT.WebGetContentTyp4Object.prototype.hitTest = function (px, py) {

    //#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 = this.x * tempRatioWidth;
    var tmpY = this.y * tempRatioHeight;
    var tmpW = this.width * tempRatioWidth;
    var tmpH = this.height * tempRatioHeight;

    if (tmpX <= px && px <= (tmpX + tmpW)) {
        if (tmpY <= py && py <= (tmpY + tmpH)) {
            return true;
        }
    }
    return false;
};

/* draw Memo */
CONTENTVIEW_CREATEOBJECT.WebGetContentTyp4Object.prototype.drawObject = function (context, opt) {
    
    //#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 posX = this.x * tempRatioWidth;
    var posY = this.y * tempRatioHeight;
    var objWidth = this.width * tempRatioWidth;
    var objHeigth = this.height * tempRatioHeight;
    var imageObj = new Image();
    imageObj.onload = function () {
        context.globalAlpha = 0.4;

        context.drawImage(imageObj, posX, posY, objWidth, objHeigth);
        
        //Start Function : No.4 - Editor: Long - Date : 08/14/2013 - Summary : handle lazy loading
        CONTENTVIEW.flip(opt);
       //Start Function : No.4 - Editor: Long - Date : 08/14/2013 - Summary : handle lazy loading   
        context.globalAlpha = 1;
    };
    imageObj.src = this.imageUrl;

};

/* create memo object */
CONTENTVIEW_CREATEOBJECT.webContentType4 = function (id, x, y, w, h, imageUrl, linkKind, destURI, destPageNumber) {
    this.setup(id, x, y, w, h, imageUrl);
    this.action = function () {
        if (linkKind == "1") {
        	//ストリーミングならリンクしない
        	if(!ClientData.isStreamingMode()){
        		//START TRB00070
        		window.onbeforeunload = null;
        		//window.open(destURI, "_blank", "new window");
        		window.open(destURI, "_self");
        		setTimeout(function(){COMMON.ToogleLogoutNortice();}, 200);
        		//END TRB00070
        	}
        } 
        else if (linkKind == "0") {
        	CONTENTVIEW.changePage(CONTENTVIEW.changePageNo(destPageNumber));
        }
    };
};
CONTENTVIEW_CREATEOBJECT.webContentType4.prototype = new CONTENTVIEW_CREATEOBJECT.WebGetContentTyp4Object();

/* ----------------------------------- End create webGetContentType4 -----------------------------*/

/**
* PageObject Class Definition 
*/

/* constructor */
CONTENTVIEW_CREATEOBJECT.PageObject = function (id, imageUrl, x, y, w, h, visible, actionFunction, displayBorder) {
};

/* setup each properties */
CONTENTVIEW_CREATEOBJECT.PageObject.prototype.setup = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, actionFunction, displayBorder, objectId) {

    this.mediaType = mediaType;
    this.actionType = actionType;
    this.id = id;
    this.x = x;
    this.y = y;
    this.width = w;
    this.height = h;
    this.displayBorder = displayBorder;
    this.visible = visible;
    this.imageUrl = imageUrl;
    this.image = new Image();
    if( this.imageUrl != null ){
    	this.image.src = this.imageUrl;
    }
    	
    this.objectId = objectId;
    
};

/* prototype hitTest */
CONTENTVIEW_CREATEOBJECT.PageObject.prototype.hitTest = function (px, py) {

    //#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 = this.x * tempRatioWidth;
    var tmpY = this.y * tempRatioHeight;
    var tmpW = this.width * tempRatioWidth;
    var tmpH = this.height * tempRatioHeight;
    
    if ( tmpX <= px && px <= (tmpX + tmpW)) {
        if (tmpY <= py && py <= (tmpY + tmpH)) {
            return true;
        }
    }
    //if (this.x <= px && px <= (this.x + this.width)) {
    //    if (this.y <= py && py <= (this.y + this.height)) {
    //        return true;
    //    }
    //}
    return false;
};
/* draw page Object */
//Start Function: No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw object on next page
CONTENTVIEW_CREATEOBJECT.PageObject.prototype.drawPageObject = function (context, opt) {
    
	if(opt == undefined || opt == null){
		opt = 0;
	}
	
    var nObjectCnt = 0;
    //#11478
    var tempRatioWidth = 1;
    var tempRatioHeight = 1;
    var canvasWidth = 0;
    var canvasHeight = 0;
    
    //Check which pageObject to be count
    if(opt == 0){
    	
        nObjectCnt = CONTENTVIEW_GENERAL.pageObjects.length;
        
        //#11478
        canvasWidth = $('#offscreen').width();
        canvasHeight = $('#offscreen').height();
        tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPageApi;
        if( tempRatioWidth < 1 ){
            tempRatioWidth = 1;
        }
        var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachPageApi;
        if( tempRatioHeight < 1 ){
            tempRatioHeight = 1;
        }
        
    }
    else if(opt == 1){
        nObjectCnt = CONTENTVIEW_GENERAL.nextPageObjects.length;
        
        //#11478
        canvasWidth = $('#offscreenNext').width();
        canvasHeight = $('#offscreenNext').height();
        tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachNextPageApi;
        if( tempRatioWidth < 1 ){
            tempRatioWidth = 1;
        }
        var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachNextPageApi;
        if( tempRatioHeight < 1 ){
            tempRatioHeight = 1;
        }
        
    }
    else if(opt == 2){
        nObjectCnt = CONTENTVIEW_GENERAL.prevPageObjects.length;
        
        //#11478
        canvasWidth = $('#offscreenPre').width();
        canvasHeight = $('#offscreenPre').height();
        tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPrevPageApi;
        if( tempRatioWidth < 1 ){
            tempRatioWidth = 1;
        }
        var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachPrevPageApi;
        if( tempRatioHeight < 1 ){
            tempRatioHeight = 1;
        }
        
    }
    
    if (this.visible) {
    	
        /* init data */
        var mediaType = this.mediaType;
        var displayBorder = this.displayBorder;
        
        //#11478
        var x = this.x * tempRatioWidth;
        var y = this.y * tempRatioHeight;
        var w = this.width * tempRatioWidth;
        var h = this.height * tempRatioHeight;
        
        var tempUrl = this.imageUrl;
        var isUsedTempImg = false;
        
        //START TRB00046 - Editor : Long - Date: 09/19/2013 - Summary : Fix for draw video object at center
        if(mediaType == '6' && tempUrl == 'img/iPad_video.png'){
            isUsedTempImg = true;
        }
        //END TRB00046 - Editor : Long - Date: 09/19/2013 - Summary : Fix for draw video object at center
        
        if (mediaType == '5') {
        	CONTENTVIEW_GENERAL.nCountObjectLoad[opt]++;
            context.strokeStyle = "black";
            context.lineWidth = "1";
            context.strokeRect(x, y, w, h);
            
            CONTENTVIEW.flip(opt);
        }

        if (this.imageUrl != '') {
            /* init image  */
            var img = new Image();

            img.onload = function () {
            	CONTENTVIEW_GENERAL.nCountObjectLoad[opt]++;

                /* create object store value image */
                var objTemp = [];
                objTemp.mediaType = mediaType;
                objTemp.img = img;
                objTemp.x = x;
                objTemp.y = y;
                objTemp.w = w;
                objTemp.h = h;
                objTemp.displayBorder = displayBorder;

                /* push to array */
                CONTENTVIEW_GENERAL.arrImage.push(objTemp);

                if (mediaType == '2') {/*  media */
                    img.width = 50;
                    img.height = 50;

                    if (img.width > w) {
                        context.drawImage(img, x, y, w, h);
                    } else {
                        /*draw image and border */
                        context.drawImage(img, x + ((w - img.width) / 2), y + ((h - img.height) / 2), img.width, img.height);
                        if (displayBorder == '1') {/* draw border */
                            context.strokeStyle = "black";
                            context.lineWidth = "1";
                            context.strokeRect(x, y, w, h);
                        }
                    }

                } 
                else if (mediaType == '3') {/* audio */
                    img.width = 50;
                    img.height = 50;
                    
                    //START TRB00035 - Editor : Long - Date: 09/17/2013 - Summary : Fix for draw audio object at center
                    context.drawImage(img, x + (w/2 - img.width/2), y + (h/2 - img.height/ 2), img.width, img.height);                 
                    //END TRB00035 - Editor : Long - Date: 09/17/2013 - Summary : Fix for draw audio object at center                                      
                    
                }
                else if(mediaType == '6' && isUsedTempImg){
                    img.width = 50;
                    img.height = 50;
                    
                    //START TRB00046 - Editor : Long - Date: 09/19/2013 - Summary : Fix for draw video object at center
                    context.drawImage(img, x + (w/2 - img.width/2), y + (h/2 - img.height/ 2), img.width, img.height);   
                                        
                    isUsedTempImg = false;              
                    //END TRB00046 - Editor : Long - Date: 09/19/2013 - Summary : Fix for draw video object at center  

                }
                else {
                    context.drawImage(img, x, y, w, h);
                }
                
                CONTENTVIEW.flip(opt);
                
                //console.log("CONTENTVIEW_GENERAL.nCountObjectLoad:" + opt + " "+ CONTENTVIEW_GENERAL.nCountObjectLoad[opt] + " nObjectCnt:" + nObjectCnt);
                if (CONTENTVIEW_GENERAL.nCountObjectLoad[opt] >= nObjectCnt) {                       

                    /* draw marking */
                	CONTENTVIEW.drawMarkingOnScreen(opt);

                    /*set status is loading page */
                    //Start Function : No.4 - Summary : make sure all 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.isLoadingObject = false;
                            }
                        }
                        else{
                        	CONTENTVIEW_GENERAL.isLoadingObject = false;
                        }                                          
                    }
                    else{
                    	CONTENTVIEW_GENERAL.isLoadingObject = false;
                    }
                    //End Function : No.4 - Summary : make sure all page is loaded

                    /* enable controls in page */
                    if (ClientData.IsAddingMarking() == true) {
                    	CONTENTVIEW_GENERAL.disableAllControl();
                        //Start Function : No.4 - Summary : make sure all 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_MARKING.enableButtonMarking();
                                }   
                            }
                            else{
                            	CONTENTVIEW_MARKING.enableButtonMarking();
                            }                     
                        }
                        else{
                        	CONTENTVIEW_MARKING.enableButtonMarking();
                        }
                        //End Function : No.4 - Summary : make sure all page is loaded                       
                    } 
                    else {
                        //Start Function : No.4 - Summary : make sure all 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 all page is loaded  
                    }

                    /*finish loading */
                     //Start Function : No.4 - Summary : make sure all 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 Functi

                    /* set pos video */
                    CONTENTVIEW.zoomVideo();
                }
            };
            img.src = this.imageUrl;
        } 
        else {
        	
        	//console.log("mediaType:" + mediaType);
        	//console.log("tempUrl:" + tempUrl);
            if (CONTENTVIEW_GENERAL.nCountObjectLoad[opt] >= nObjectCnt) {
                /* draw marking */
            	CONTENTVIEW.drawMarkingOnScreen(opt);

                /*set status is loading page */
            	CONTENTVIEW_GENERAL.isLoadingObject = false;
                /* enable controls in page */
                if (ClientData.IsAddingMarking() == true) {
                	CONTENTVIEW_GENERAL.disableAllControl();
                     //Start Function : No.4 - Summary : make sure all 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_MARKING.enableButtonMarking();
                            }
                        }
                        else{
                        	CONTENTVIEW_MARKING.enableButtonMarking();
                        }                       
                    }
                    else{
                    	CONTENTVIEW_MARKING.enableButtonMarking();
                    }
                    //End Function : No.4 - Summary : make sure all page is loaded  
                } else {
                    //Start Function : No.4 - Summary : make sure all 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 : mak
                }

                /*finish loading */ 
                //Start Function : No.4 - Summary : make sure all 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 Func
                /* set pos video */
                CONTENTVIEW.zoomVideo();
            }
        }
    }
};
//End Function: No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw object on next page

//Start Function : No.9

/*mediaType = 8 3d object*/
CONTENTVIEW_CREATEOBJECT.object3d = function (mediaType, actionType, id, imageUrl, x, y, w, h, hCnt, vCnt, visible, imageObjects, objectId){
    
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function (imagePt){      
                    
        //abe
        //alert("object3d");
        
        //#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;
        }
        
        //#11478 操作側のイベント判定には逆に縮める対応が必要
        var tempRatioWidth2 = CONTENTVIEW_GENERAL.widthEachPageApi / canvasWidth;
        if( tempRatioWidth2 > 1 ){
            tempRatioWidth2 = 1;
        }
        var tempRatioHeight2 = CONTENTVIEW_GENERAL.heightEachPageApi / canvasHeight;
        if( tempRatioHeight2 > 1 ){
            tempRatioHeight2 = 1;
        }
        
        //console.log("tempRatioWidth:" + tempRatioWidth + " tempRatioHeight:" + tempRatioHeight);
        //console.log("tempRatioWidth2:" + tempRatioWidth2 + " tempRatioHeight2:" + tempRatioHeight2);
        
        var tmpX = x *  tempRatioWidth;
        var tmpY = y * tempRatioHeight;
        var tmpW = w *  tempRatioWidth;
        var tmpH = h * tempRatioHeight;
        
       if(CONTENTVIEW_3D._3dAction == CONTENTVIEW_3D._3dActionType.TouchStart_MouseDown){
    	   
    	   CONTENTVIEW_3D.OnMouseDown3D(id, imagePt, tmpX, tmpY, tempRatioWidth2, tempRatioHeight2);
       }
       else if(CONTENTVIEW_3D._3dAction == CONTENTVIEW_3D._3dActionType.TouchMove_MouseMove){
    	   
    	   CONTENTVIEW_3D.OnMouseMove3D(id, imagePt, tmpX, tmpY, tmpW, tmpH, hCnt, vCnt, tempRatioWidth2, tempRatioHeight2);
       }
       else if(CONTENTVIEW_3D._3dAction == CONTENTVIEW_3D._3dActionType.TouchEnd_MouseUp){
    	   CONTENTVIEW_3D.OnMouseEnd3D(id, hCnt, vCnt);
           
            //詳細ログ作成
            var objectLog = new ObjectLogEntity();
            objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
            objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
            objectLog.objectId = objectId;
            objectLog.resourceId = "";
            objectLog.mediaType = mediaType;
            objectLog.actionType = actionType;
            objectLog.actionValue = "";
            objectLog.actionTime = "0";
            objectLog.locationX = x;
            objectLog.locationY = y;
            objectLog.locationHeight = h;
            objectLog.locationWidth = w;
            COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
            //---
           
       }              
    };
};
CONTENTVIEW_CREATEOBJECT.object3d.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

//End Function : No.9

/* mediaType = 7 write text object*/
CONTENTVIEW_CREATEOBJECT.text = function (mediaType, actionType, id, x, y, w, h, visible, actionFunction, content, objectId) {
    //var imageUrl = displayText(x,y,w,h,id,content);
    var imageUrl = TEXTOBJECT.getTextObjectImage(w, h, content);
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, actionFunction, null, objectId);
    this.action = function () {
    };
};
CONTENTVIEW_CREATEOBJECT.text.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType=4  list image object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.listImage = function (mediaType, id, imageUrl, x, y, w, h, visible, imageObjects, triggerType, objectId) {
    this.setup(mediaType, null, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        if (triggerType == '1') {
        
            //abe
            //alert("listImage triggerType=1");
        
            //詳細ログ作成
            var objectLog = new ObjectLogEntity();
            objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
            objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
            objectLog.objectId = objectId;
            //objectLog.resourceId = "";
            objectLog.mediaType = mediaType;
            objectLog.actionType = "";
            objectLog.actionValue = "";
            objectLog.actionTime = "0";
            objectLog.locationX = x;
            objectLog.locationY = y;
            objectLog.locationHeight = h;
            objectLog.locationWidth = w;
            //COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
            //---
        
            CONTENTVIEW_GENERAL.mediaType4_changeImage++;

            /* check index bigger than length object */
            if (CONTENTVIEW_GENERAL.mediaType4_changeImage > (imageObjects.length - 1)) {
            	CONTENTVIEW_GENERAL.mediaType4_changeImage = 0;
            }

            //リソースIDセット
            objectLog.resourceId = imageObjects[CONTENTVIEW_GENERAL.mediaType4_changeImage].resourceId;
            COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);

            /* draw image */
            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 = x *  tempRatioWidth;
                var tmpY = y * tempRatioHeight;
                var tmpW = w *  tempRatioWidth;
                var tmpH = h * tempRatioHeight;
                
                contextObject.drawImage(imageObj, tmpX, tmpY, tmpW, tmpH);
                CONTENTVIEW.flip();
            };
            imageObj.src = imageObjects[CONTENTVIEW_GENERAL.mediaType4_changeImage].fileName;
            
        }
    };
};
CONTENTVIEW_CREATEOBJECT.listImage.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType=5 Replace Video object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.listVideo = function (mediaType, id, imageUrl, x, y, w, h, visible, videoObjects, objectId) {
    this.setup(mediaType, null, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
        //abe 
        //alert("listVideo");
    };
};
CONTENTVIEW_CREATEOBJECT.listVideo.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType=6 Trigger object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.trigger = function (mediaType, actionType, id, imageUrl, x, y, w, h, index, target, visible, actionFunction, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, actionFunction, null, objectId);
    this.action = function () {
        // draw object      

        //abe
        //alert("trigger:" + CONTENTVIEW_GETDATA.getPageIndex() + " id:" + id);

        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = "";
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;

        for (var nIndex = 0; nIndex < CONTENTVIEW.objType4_5.length; nIndex++) {
            for (var nIndex1 = 0; nIndex1 < CONTENTVIEW.objType4_5[nIndex].dataObjects.length; nIndex1++) {
                if (CONTENTVIEW.objType4_5[nIndex].dataObjects[nIndex1].index == index
                    && CONTENTVIEW.objType4_5[nIndex].id == target) {
                    if (CONTENTVIEW.objType4_5[nIndex].mediaType == '4') {  /*image*/
                    	CONTENTVIEW.changeImageType4(CONTENTVIEW.objType4_5, nIndex, nIndex1);
                        //詳細ログ用 画像なので0セット
                        objectLog.actionTime = "0";
                        //リソースID
                        objectLog.resourceId = CONTENTVIEW.objType4_5[nIndex].dataObjects[nIndex1].resourceId;
                    } else {   /* video */
                    	CONTENTVIEW.stopAllAudio();
                        CONTENTVIEW.showVideoObject(CONTENTVIEW.objType4_5[nIndex].x, CONTENTVIEW.objType4_5[nIndex].y, CONTENTVIEW.objType4_5[nIndex].width, CONTENTVIEW.objType4_5[nIndex].height, CONTENTVIEW.objType4_5[nIndex].dataObjects[nIndex1].fileName, false);
                        
                        if(ClientData.isStreamingMode() || ClientData.isGetitsMode()){
                            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) { 
                            	var myVideo=document.getElementById("videoOnPage"); 
                            	if (myVideo.paused)
                            	{
                            		myVideo.play();
                            	}
                            }
                        }
                        
                        //詳細ログ用 動画なのでダミーで１以上
                        objectLog.actionTime = "1";
                        //リソースID
                        objectLog.resourceId = CONTENTVIEW.objType4_5[nIndex].dataObjects[nIndex1].resourceId;
                        
                    }
                    break;
                }
            }
        }
        
        //詳細ログ格納
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
        
    };
};
CONTENTVIEW_CREATEOBJECT.trigger.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

//Start Function : No.9 - Editor : Long - Date: 08/16/2013 - Summary : 
CONTENTVIEW_CREATEOBJECT.htmlLinkButton = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, resourceUrl, objectId) {

    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        //abe
        //alert("htmlLinkButton");
    	//CONTENTVIEW_STREAMING.debugLog("htmlLinkButton:" + resourceUrl + ":" + objectId);
    	
        /*stop audio on page */
    	CONTENTVIEW.stopAllAudio();
        
        if (resourceUrl != "") {
        
            //詳細ログ作成
            var objectLog = new ObjectLogEntity();
            objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
            objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
            objectLog.objectId = objectId;
            objectLog.resourceId = "";
            objectLog.mediaType = mediaType;
            objectLog.actionType = actionType;
            objectLog.actionValue = "";
            objectLog.actionTime = "0";
            objectLog.locationX = x;
            objectLog.locationY = y;
            objectLog.locationHeight = h;
            objectLog.locationWidth = w;
            COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
            //---
        
            CONTENTVIEW_CREATEOBJECT.showHtml(resourceUrl, objectId );
            CONTENTVIEW_GENERAL.showDialog(true);
        }        
    };
};
CONTENTVIEW_CREATEOBJECT.htmlLinkButton.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

CONTENTVIEW_CREATEOBJECT.showHtml = function(url, objectId ){

    //abe
    //alert("showHtml");
	
    var $container = $('#dialog');
    
    $container.html('');
    $container.attr('style', 'background-color: white; width:100%; left:0% !important'); 
                 
   //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
        $container.html(
          '<h1>' 
        + '<img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnClose" class="align_right" ></img>' 
        + '</h1>'
        + '<div id="html-wrap" style="height: 95%; position: absolute; width: 100%;">'
        + '<iframe src="'+ url +'" style="position: absolute; width: 100%; height: 100%; ">'
        + '</iframe>'
        + '</div>'
        );
        
        $('#html-wrap').css('overflow', 'scroll');
        $('#html-wrap').css('-webkit-overflow-scrolling', 'touch');
    }
    else{
        $container.html(
          '<h1>' 
        + '<img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnClose" class="align_right" ></img>' 
        + '</h1>'
        + '<iframe src="'+ url +'" style="position: absolute; width: 100%; height: 95%; ">'
        + '</iframe>'
        );
    }
    //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad 
    
    /*
    $('#dialog h1 img').click(function(){
    
        var dateEnd = new Date();
        var actionTime = dateEnd.subtractBySeconds(dateStart);
        //alert("actionTime:" + actionTime);
        COMMON.SetObjectLogActionTime( CONTENTVIEW_GENERAL.contentID, objectId, actionTime );
    
        $container.removeAttr('style');
        CONTENTVIEW_GENERAL.hideDialog();
        
    });
    */
    $("#dialog h1 img").on({
		'click touchend': function(ev){
			var dateEnd = new Date();
			var actionTime = dateEnd.subtractBySeconds(dateStart);
			//alert("actionTime:" + actionTime);
			COMMON.SetObjectLogActionTime( CONTENTVIEW_GENERAL.contentID, objectId, actionTime );
			
			$container.removeAttr('style');
			CONTENTVIEW_GENERAL.hideDialog();
		},
			'touchstart touchmove': function(){
			//これを入れないと次にダイアログを開くと表示位置が大きくズレる
			return false;
		}
	});
    
    var dateStart = new Date();
    
};

CONTENTVIEW_CREATEOBJECT.anket = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, questionNo, replyLimit, fullscreen, saveAs, resourceId, enquete, objectId) {

    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = resourceId;
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = enquete; //objectNameのほうが良かった
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    
        /*stop audio on page */
        CONTENTVIEW.stopAllAudio();
         
        var url = CONTENTVIEW_GETDATA.getURLPageImage("webEnqueteReply/init") + "/?abObjectId="+objectId + "&sid=" + CONTENTVIEW.getSessionId();
        if(ClientData.isStreamingMode()){
        	//ストリーミング
        	url = url + "&isStreaming=true";
        }
        
        var isFullScreen = false;
        if(parseInt(fullscreen) == 1){
            isFullScreen = true;
        }
        
        CONTENTVIEW_ANKET.showAnket(url, isFullScreen, objectId);
        CONTENTVIEW_GENERAL.showDialog(true);
           
    };
};
CONTENTVIEW_CREATEOBJECT.anket.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

//End Function : No.9 - Editor : Long - Date: 08/16/2013 - Summary : 

/* mediaType=3  Audio object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.audioType3 = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, audioFile, audioResourceId, playType, objectId) {

    if (playType == "0") {
        this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
        this.action = function () {
        
            //abe
            //alert("audioType3_0");
    
            //詳細ログ作成
            var objectLog = new ObjectLogEntity();
            objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
            objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
            objectLog.objectId = objectId;
            objectLog.resourceId = audioResourceId;
            objectLog.mediaType = mediaType;
            objectLog.actionType = actionType;
            objectLog.actionValue = "";
            objectLog.actionTime = "0";
            objectLog.locationX = x;
            objectLog.locationY = y;
            objectLog.locationHeight = h;
            objectLog.locationWidth = w;
            COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
            //---
        
            CONTENTVIEW_CREATEOBJECT.createAudio(audioFile, playType);
        };
    }
    else {
        //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
        if(playType == '2' || playType == 2){
            //
        }
        else{
        
            //abe
            //alert("audioType3_x");
    
            //詳細ログ作成
            var objectLog = new ObjectLogEntity();
            objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
            objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
            objectLog.objectId = objectId;
            objectLog.resourceId = audioResourceId;
            objectLog.mediaType = mediaType;
            objectLog.actionType = actionType;
            objectLog.actionValue = "";
            objectLog.actionTime = "0";
            objectLog.locationX = x;
            objectLog.locationY = y;
            objectLog.locationHeight = h;
            objectLog.locationWidth = w;
            COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
            //---
        
            CONTENTVIEW_CREATEOBJECT.createAudio(audioFile, playType);
        }
        //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
        this.setup(mediaType, actionType, id, null, x, y, w, h, visible, null, null, objectId);
        this.action = function () {
            //
        };
    }
};
CONTENTVIEW_CREATEOBJECT.audioType3.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 5 jumpPage object*/
CONTENTVIEW_CREATEOBJECT.jumpPage = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, jumpPage, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        //abe
        //alert("jumpPage");
    
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = jumpPage; //ページ飛び先
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    
        if ((Number(jumpPage) - 1) != CONTENTVIEW_GETDATA.getPageIndex()) {
        	CONTENTVIEW_EVENTS.createLockLayout(true);
            CONTENTVIEW.changePage(Number(jumpPage) - 1);
        }
    };
};
CONTENTVIEW_CREATEOBJECT.jumpPage.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 6 send mail object*/
CONTENTVIEW_CREATEOBJECT.sendMail = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, emailSubject, emailAddress, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
    	//ストリーミングなら反応しない
    	if(ClientData.isStreamingMode()){
    		return;
    	}
    	
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = emailAddress; //メールアドレス
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    
        CONTENTVIEW_POPUPTEXT.MailTo(emailAddress, emailSubject);
    };
};
CONTENTVIEW_CREATEOBJECT.sendMail.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 8 open popup object*/
CONTENTVIEW_CREATEOBJECT.openPopUp = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, content, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        //abe
        //alert("openPopUp:" + CONTENTVIEW_GETDATA.getPageIndex() + " id:" + objectId);
        
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = "";
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
        
        CONTENTVIEW_GENERAL.isOpenPopUpText = true;
        var pt1 = CONTENTVIEW.imageToScreen(x, y + h / 2);

        if (CONTENTVIEW.userScale > 1) {
        	CONTENTVIEW_POPUPTEXT.OpenPopupText(CONTENTVIEW_GENERAL.posXPopupMemo, CONTENTVIEW_GENERAL.posYPopupMemo, content, $('#dialogPopUp'), $('#arrow'));
        } else if ($("#header_toolbar").is(":hidden")) {
        	CONTENTVIEW_POPUPTEXT.OpenPopupText(pt1.x, pt1.y - 65, content, $('#dialogPopUp'), $('#arrow'));
        } else {
        	CONTENTVIEW_POPUPTEXT.OpenPopupText(pt1.x, pt1.y, content, $('#dialogPopUp'), $('#arrow'));
        }
    };
};
CONTENTVIEW_CREATEOBJECT.openPopUp.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 10 move to Content object*/
CONTENTVIEW_CREATEOBJECT.moveToContent = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, contentId, pageNo, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = contentId;
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    
        ///* set end log */
        //COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
        //COMMON.RegisterLog();
        //START TRB00033 - EDITOR: Long - Date : 09/12/2013 - Summary : limit content
        
        var params = {
        		contentId: contentId,
        		sid: CONTENTVIEW.getSessionId(),
        		getType: 1,
        		isStreaming: ClientData.isStreamingMode()
        };
        
        AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
             "webGetContent",
             "GET",
             params,
             function (data) {
                 
                 /* set end log */
                 COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                 COMMON.RegisterLog();
                 
                 if(data.contentData.alertMessageLevel){                    
                     
                     if(data.contentData.alertMessageLevel == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.ShowAlert){
                         if(data.contentData.alertMessage){                           
                            var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GETDATA.getPageIndex() };
                            
                            CONTENTVIEW_CREATEOBJECT.moveContentParam = {};                          
                            CONTENTVIEW_CREATEOBJECT.moveContentParam = {
                                'preContentId' : contentId,
                                'prePageNo' : pageNo,
                                'oldContent' : oldContent
                            };   
                                                                                 
                            CONTENTVIEW_CREATEOBJECT.showContentConfirmDialog(data.contentData.alertMessageLevel, data.contentData.alertMessage);                                                                               
                         }
                     }
                     else if(data.contentData.alertMessageLevel == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.RequirePassword){
                                                
                            var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GETDATA.getPageIndex() };
                            
                            CONTENTVIEW_CREATEOBJECT.moveContentParam = {};
                            CONTENTVIEW_CREATEOBJECT.moveContentParam = {
                                'preContentId' : contentId,
                                'prePageNo' : pageNo,
                                'oldContent' : oldContent
                            };   
                                                 
                            CONTENTVIEW_CREATEOBJECT.showContentConfirmDialog(data.contentData.alertMessageLevel);
                     }
                     else if(data.contentData.alertMessageLevel == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.None){
                            ClientData.common_preContentId(contentId);
                            ClientData.common_prePageNo(pageNo);
                
                            /* store old page */   
                            var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GETDATA.getPageIndex() };                                   
                            var dataJump = ClientData.JumpQueue();                
                            dataJump.push(oldContent);
                            ClientData.JumpQueue(dataJump);
                            
                            if(ClientData.isStreamingMode()){
                            	//ストリーミングのビューアへ移動
                            	AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewStreaming);
                            } else {
                            	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode() ) {
                            		AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewGetits);
                            	} else {
                            		CONTENTVIEW.screenMove();
                            	}
                            }
                     }
                 }
                 //Type 0
                 else{
                        ClientData.common_preContentId(contentId);
                        ClientData.common_prePageNo(pageNo);
                
                        /* store old page */   
                        var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GETDATA.getPageIndex() };                                   
                        var dataJump = ClientData.JumpQueue();                
                        dataJump.push(oldContent);               
                        ClientData.JumpQueue(dataJump);
                        
                        if(ClientData.isStreamingMode()){
                        	//ストリーミングのビューアへ移動
                        	AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewStreaming);
                        } else {
                        	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode()) {
                        		AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewGetits);
                        	} else {
                        		CONTENTVIEW.screenMove();
                        	}
                        }
                 }
                 
             },
             function (xmlHttpRequest, txtStatus, errorThrown) {
                 if (xmlHttpRequest.status == 404) {
                	 CONTENTVIEW.showAlertScreen(I18N.i18nText('msgContentNotExist'), null);
                 }
                 else {
                     // Show system error
                	 AVWEB.showSystemError();
                 }
             }
        );
        //END TRB00033 - EDITOR: Long - Date : 09/12/2013 - Summary : limit content                                     
    };
    
};
CONTENTVIEW_CREATEOBJECT.moveToContent.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();
//START TRB00033 - EDITOR: Long - Date : 09/12/2013 - Summary : limit content

CONTENTVIEW_CREATEOBJECT.showContentConfirmDialog = function(type, msg) {  
    
    if(type == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.ShowAlert){
    	CONTENTVIEW_CREATEOBJECT.createAlertTypeDialog(msg);
        CONTENTVIEW_GENERAL.showDialog(true);
    }
    else if(type == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.RequirePassword){
    	CONTENTVIEW_CREATEOBJECT.createPwdRequiredTypeDialog();
        CONTENTVIEW_GENERAL.showDialog(true);
    }
};

CONTENTVIEW_CREATEOBJECT.createAlertTypeDialog = function(msg){
    var $container = $('#dialog');
    $container.html('');
    $container.addClass('sectionLimitAccess');

    $container.draggable({ handle: "h1" });
    $container.html(
    '  <h1 class="lang" lang="txtContentWarning">'+ I18N.i18nText("txtContentWarning") +'</h1>'
    +'  <p class="message">'
    +       msg     
    +'  </p>'
    +'  <p class="deletebtn">'
    +'      <a lang="dspOK" class="ok lang" id="contentAlertOk">ＯＫ</a>'
    +'      <a lang="dspCancel" class="cancel lang" id="contentAlertCancel">キャンセル</a>'
    +'  </p>'
    );               
    $container.center(); 
    $('#dialog a#contentAlertCancel').click(function(){
    	CONTENTVIEW_GENERAL.hideDialog();        
        var removeTimeOut = setTimeout(function(){
            $container.removeClass('sectionLimitAccess');
        }, 200);      
    });
    
    $('#dialog a#contentAlertOk').click(function(){
        
        ClientData.common_preContentId(CONTENTVIEW_CREATEOBJECT.moveContentParam.preContentId);
        ClientData.common_prePageNo(CONTENTVIEW_CREATEOBJECT.moveContentParam.prePageNo);
        
        /* store old page */                                      
        var dataJump = ClientData.JumpQueue();                
        dataJump.push(CONTENTVIEW_CREATEOBJECT.moveContentParam.oldContent);                      
        ClientData.JumpQueue(dataJump);
        
        if(ClientData.isStreamingMode()){
        	//ストリーミングのビューアへ移動
        	AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewStreaming);
        } else {
        	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode()) {
        		AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewGetits);
        	} else {
        		CONTENTVIEW.screenMove();
        	}
        }
        
    });
};

CONTENTVIEW_CREATEOBJECT.createPwdRequiredTypeDialog = function(){
    var $container = $('#dialog');
    $container.html('');
    $container.addClass('sectionLimitAccess');
    $container.draggable({ handle: "h1" });
    $container.html(
    '  <h1 class="lang" lang="txtContentPWTitle">'+ I18N.i18nText("txtContentPWTitle") +'</h1>'
    +' <p class="message">'
    +'  <label class="text lang" lang="txtContentPWMsg">'+ I18N.i18nText("txtContentPWMsg") +'</label>'
    +'      <input type="password" />'
    +'      <label class="error" id="lblMessageLimitError"></label> '  
    +'  </p>'
    +'  <p class="deletebtn">'
    +'      <a lang="dspOK" class="ok lang" id="contentAlertOk">ＯＫ</a>'
    +'      <a lang="dspCancel" class="cancel lang" id="contentAlertCancel">キャンセル</a>'
    +'  </p>'
    );           
    $container.center();       
    
    $('#dialog a#contentAlertCancel').click(function(){
    	CONTENTVIEW_GENERAL.hideDialog();        
        var removeTimeOut = setTimeout(function(){
            $container.removeClass('sectionLimitAccess');
        }, 200);
        
    });

    
    $('#dialog a#contentAlertOk').click(
        function () {
            var password = $('.sectionLimitAccess .message input').val();
            if (!ValidationUtil.CheckRequiredForText(password)) {
                $('#lblMessageLimitError').html(I18N.i18nText('msgPwdEmpty')).show();
                return;
            }

            // start login
            var params = {
                previousSid: CONTENTVIEW.getSessionId(),
                loginId: ClientData.userInfo_loginId_session(),
                password: password,
                urlpath: ClientData.userInfo_accountPath()
            };
            // Get url to login
            var sysSettings = AVWEB.avwSysSetting();
            var apiLoginUrl = sysSettings.apiLoginUrl;

            AVWEB.avwCmsApiSyncWithUrl(apiLoginUrl, null, 'webClientLogin', 'GET', params,
        function (data) {
            if (data.result == 'success') {                
                ClientData.common_preContentId(CONTENTVIEW_CREATEOBJECT.moveContentParam.preContentId);
                ClientData.common_prePageNo(CONTENTVIEW_CREATEOBJECT.moveContentParam.prePageNo);
                
                /* store old page */                                      
                var dataJump = ClientData.JumpQueue();                
                dataJump.push(CONTENTVIEW_CREATEOBJECT.moveContentParam.oldContent);                      
                ClientData.JumpQueue(dataJump);        
                
                // update sid id
                ClientData.userInfo_sid(data.sid);  
                        
                if(ClientData.isStreamingMode()){
                	//ストリーミングのビューアへ移動
                	AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewStreaming);
                } else {
                	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode()) {
                		AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewGetits);
                	} else {
                		CONTENTVIEW.screenMove();
                	}
                }
            }
            else {
                $('#lblMessageLimitError').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), data.errorMessage).toString()).show();
            }
        },
        function (xhr, statusText, errorThrown) {
            var errorCode = 'E001';
            if (xhr.responseText && xhr.status != 0) {
                errorCode = JSON.parse(xhr.responseText).errorMessage;
            }
            $('#lblMessageLimitError').html(AVWEB.format(I18N.i18nText('msgLoginErrWrong'), errorCode).toString()).show();
        });

        }
    );
};
//END TRB00033 - EDITOR: Long - Date : 09/12/2013 - Summary : limit content

/* mediaType=2  Video object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.videoType2 = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, mediaFile, media, embed, objectId) {

    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, embed, objectId);
    this.action = function () {
    
        //abe
        //alert("videoType2:" + CONTENTVIEW_GETDATA.getPageIndex());
    
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = media; //mediaにリソースIDが入っている
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = "";
        objectLog.actionTime = "1";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    
        /*stop audio on page */
        CONTENTVIEW.stopAllAudio();
        if (embed == "1") {
        	CONTENTVIEW.showVideoObject(x, y, w, h, mediaFile, false);
        	
            if(ClientData.isStreamingMode() || CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile()){
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) { 
                	var myVideo=document.getElementById("videoOnPage"); 
                	if (myVideo.paused)
                	{
                		myVideo.play();
                	}
                }
            }
        	
        } 
        else {
            if (media != '') {
                $('#playvideo').children().remove();

        			//タグは書き出し
                	CONTENTVIEW_CREATEOBJECT.createVideoFulScreen(mediaFile, id);
                    $("#btnCloseVideo").on({
                    	'click touchend': function(ev){
                    		//時間記録
                			CONTENTVIEW_GENERAL.hideDialog();
                    		/*play audio if exist */
                    		CONTENTVIEW.playAllAudio();
                    		return false;
                    	},
                    	'touchstart touchmove': function(){
                    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
                    		return false;
                    	}
                	});
                
                	//必要か　ここから
            		CONTENTVIEW_GENERAL.canvas_draw.removeEventListener('touchstart', function(){},false);
            		CONTENTVIEW_GENERAL.canvas_draw.removeEventListener('touchmove', function(){},false);
            		CONTENTVIEW_GENERAL.canvas_draw.removeEventListener('touchend', function(){},false);
            		CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchstart', function(){return false;}, false);
            		CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchmove', function(){return false;}, false);
            		CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchend', function(){return false;}, false);
                	
                	$("#canvasWrapper").unbind('click');
                	$("#canvasWrapper").unbind('touchstart');
                	$("#canvasWrapper").unbind('touchmove');
                	$("#canvasWrapper").unbind('touchend');
                	
                	document.getElementById('main').addEventListener('click', function(){return false;}, false);
                	document.getElementById('main').addEventListener('touchstart', function(){return false;}, false);
                	document.getElementById('main').addEventListener('touchmove', function(){return false;}, false);
                	document.getElementById('main').addEventListener('touchend', function(){return false;}, false);
                	document.getElementById('canvasWrapper').addEventListener('click', function(){return false;}, false);
                	document.getElementById('canvasWrapper').addEventListener('touchstart', function(){return false;}, false);
                	document.getElementById('canvasWrapper').addEventListener('touchmove', function(){return false;}, false);
                	document.getElementById('canvasWrapper').addEventListener('touchend', function(){return false;}, false); 
                	//必要か　ここまで
                
                	CONTENTVIEW_GENERAL.showDialog(true);
                
                	if(ClientData.isStreamingMode() || CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile()){
                    	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) { 
                    		var myVideo=document.getElementById("videoOnPopUp"); 
                    		if (myVideo.paused)
                    		{
                    			myVideo.play();
                    		}
                    	}
                	}
                
            }
        }
    };
};
CONTENTVIEW_CREATEOBJECT.videoType2.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 0 linkURL object*/
CONTENTVIEW_CREATEOBJECT.imageNoAction = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
        //no action
    };
};
CONTENTVIEW_CREATEOBJECT.imageNoAction.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType=1  Video object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.videoType1 = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, mediaFile, media, mediaResourceId, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        if (media != '') {
        
            //abe
            //alert("videoType1:" + CONTENTVIEW_GETDATA.getPageIndex());
            //詳細ログ作成
            var objectLog = new ObjectLogEntity();
            objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
            objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
            objectLog.objectId = objectId;
            objectLog.resourceId = mediaResourceId; //リソースID
            objectLog.mediaType = mediaType;
            objectLog.actionType = actionType;
            objectLog.actionValue = media; //リソースファイル名
            objectLog.actionTime = "1";
            objectLog.locationX = x;
            objectLog.locationY = y;
            objectLog.locationHeight = h;
            objectLog.locationWidth = w;
            COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
            //---
        
            /* stop all audio on page */
            CONTENTVIEW.stopAllAudio();

            	CONTENTVIEW_CREATEOBJECT.createVideoFulScreen(mediaFile, id);

                $("#btnCloseVideo").on({
                	'click touchend': function(ev){
                		//時間記録
                		var dateEnd = new Date();
                		var actionTime = dateEnd.subtractBySeconds(dateStart);
                		//alert("actionTime:" + actionTime);
                		COMMON.SetObjectLogActionTime( CONTENTVIEW_GENERAL.contentID, objectId, actionTime );
                		CONTENTVIEW_GENERAL.hideDialog();
                		/* play audio  */
                		CONTENTVIEW.playAllAudio();
                	},
                	'touchstart touchmove': function(){
                		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
                		return false;
                	}
            	});
            	CONTENTVIEW_GENERAL.showDialog(true);
            	
        }
        
        //時間記録
        var dateStart = new Date();
        
    };
};
CONTENTVIEW_CREATEOBJECT.videoType1.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType=1 and actionType = 2  Audio object : extends PageObject */
CONTENTVIEW_CREATEOBJECT.audioType1 = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, audioFile, audio, audioResourceId, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {
    
        //abe
        //alert("audioType1");
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = audioResourceId; //リソースID
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = audio;
        objectLog.actionTime = "1";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
    
        CONTENTVIEW_CREATEOBJECT.createAudio(audioFile, "0")
    };
};
CONTENTVIEW_CREATEOBJECT.audioType1.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 3 linkURL object*/
CONTENTVIEW_CREATEOBJECT.linkURL = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, actionFunction, linkUrl, browserType, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, actionFunction, null, objectId);
    this.action = function () {
    
        //abe
        //alert("linkURL");
        
    	//デフォルトでストリーミングなら表示しない
        if( browserType == 1 && ClientData.isStreamingMode()){
        	return;
        }
        
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        objectLog.actionValue = linkUrl;
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---
        
        var linkUrlTmp = linkUrl;
        //DHカスタム
        if( ClientData.serviceOpt_daihatsu() == 'Y'){
            var apiUrl = AVWEB.getApiUrl(ClientData.userInfo_accountPath());
            linkUrlTmp = linkUrlTmp + "?sid=" + CONTENTVIEW.getSessionId() + "&apiurl=" + apiUrl ;
        }
        
        if( browserType == 0 ){
        	CONTENTVIEW_CREATEOBJECT.showHtml(linkUrlTmp, objectId );
        	CONTENTVIEW_GENERAL.showDialog(true);
        } else {
        	window.open(linkUrlTmp, "_blank", "new window, scrollbars=yes");
        }
        
    };
};
CONTENTVIEW_CREATEOBJECT.linkURL.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* mediaType = 1 and actionType = 4 imagePreview object*/
CONTENTVIEW_CREATEOBJECT.imagePreview = function (mediaType, actionType, id, imageUrl, x, y, w, h, visible, imagePreview, imagePreviewResourceIds, objectId) {
    this.setup(mediaType, actionType, id, imageUrl, x, y, w, h, visible, null, null, objectId);
    this.action = function () {

        //abe
        //alert("imagePreview");
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
        objectLog.objectId = objectId;
        objectLog.resourceId = "";
        objectLog.mediaType = mediaType;
        objectLog.actionType = actionType;
        //objectLog.actionValue = "";
        objectLog.actionTime = "0";
        objectLog.locationX = x;
        objectLog.locationY = y;
        objectLog.locationHeight = h;
        objectLog.locationWidth = w;
        
        //プレビュー画像のリソースIDカンマ区切りでセット
        var actionVal = "";
        if(imagePreviewResourceIds){
            for (var nIndex = 0; nIndex < imagePreviewResourceIds.length; nIndex++) {
                if( nIndex > 0 ){
                    actionVal = actionVal + ",";
                }
                actionVal = actionVal + imagePreviewResourceIds[nIndex];
            }
        }
        objectLog.actionValue = actionVal;
        
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
        //---

        CONTENTVIEW_CREATEOBJECT.createImagePreview();

        CONTENTVIEW_IMAGEPREVIEW.showImagePreview($('#divImagePreview'), imagePreview);

        $("#btnClose").on({
        	'click touchend': function(ev){
        		
        		//時間記録
        		var dateEnd = new Date();
        		var actionTime = dateEnd.subtractBySeconds(dateStart);
        		//alert("actionTime:" + actionTime);
        		COMMON.SetObjectLogActionTime( CONTENTVIEW_GENERAL.contentID, objectId, actionTime );
        		CONTENTVIEW_GENERAL.hideDialog();
        		
        		return false;
        	},
        	'touchstart touchmove': function(){
        		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
        		return false;
        	}
        });
        
        CONTENTVIEW_GENERAL.showDialog(true);
        
        //時間記録
        var dateStart = new Date();
        
    };
};
CONTENTVIEW_CREATEOBJECT.imagePreview.prototype = new CONTENTVIEW_CREATEOBJECT.PageObject();

/* rect object */
CONTENTVIEW_CREATEOBJECT.Rect = function (x, y, w, h) {
    this.left = Math.floor(x);
    this.top = Math.floor(y);
    this.right = Math.floor(x + w);
    this.bottom = Math.floor(y + h);
    this.width = w;
    this.height = h;
};
CONTENTVIEW_CREATEOBJECT.Rect.prototype.add = function (x, y) {
    this.left = Math.floor(this.left + x);
    this.right = Math.floor(this.right + x);
    this.top = Math.floor(this.top + y);
    this.bottom = Math.floor(this.bottom + y);
    this.width = this.right - this.left;
    this.height = this.bottom - this.top;
};
CONTENTVIEW_CREATEOBJECT.Rect.prototype.center = function () {
    var x = (this.left + this.right) / 2;
    var y = (this.top + this.bottom) / 2;
    return new CONTENTVIEW.Point(Math.floor(x), Math.floor(y));
};

/**
* Content Class Definition 
*/
CONTENTVIEW_CREATEOBJECT.Content = function () {

    this.pageCount = 0;
    this.pageIndex = 0;
    this.pageImages = null;
    this.pageObjects = null;
    this.currentPage = null;

};

/* ste page images (json data) */
CONTENTVIEW_CREATEOBJECT.Content.prototype.setPageImages = function (pageCount, imageUrls) {
    this.pageCount = pageCount;
    this.pageImages = imageUrls;
    return this;
};

/* set page objects data (json data) */
CONTENTVIEW_CREATEOBJECT.Content.prototype.setPageObjects = function (pageObjects) {
    this.pageObjects = pageObjects;
    return this;
};

/* Set up page */
CONTENTVIEW_CREATEOBJECT.Content.prototype.setUpPage = function (pageIndex, opt) {

    this.currentPage = CONTENTVIEW_CREATEOBJECT.createPage(
                            this.pageIndex,
                            this.pageImages,
                            this.pageObjects,
                            function () {
                                //adjustPage(opt);
                            	CONTENTVIEW.drawCanvas(opt);
                            });
    return this;
};

/* check next page exists */
CONTENTVIEW_CREATEOBJECT.Content.prototype.hasNextPage = function () {
    if ((this.pageIndex + 1) > (this.pageCount - 1)) {
        return false;
    }
    return true;
};

/* setup next page */
CONTENTVIEW_CREATEOBJECT.Content.prototype.nextPage = function () {
    this.pageIndex++;
    if (this.pageIndex > (this.pageCount - 1)) {
        
        this.pageIndex = this.pageCount - 1;
    }
    this.setUpPage(this.pageIndex, 1);
    return this;
};

/* check previous page exists */
CONTENTVIEW_CREATEOBJECT.Content.prototype.hasPreviousPage = function () {
    if ((this.pageIndex - 1) < 0) {
        return false;
    }
    return true;
};

/* setup previous page */
CONTENTVIEW_CREATEOBJECT.Content.prototype.previousPage = function () {
    this.pageIndex--;
    if (this.pageIndex < 0) {
        this.pageIndex = 0;
    }
    this.setUpPage(this.pageIndex, 2);
    return this;
};

/* setup previous page */
CONTENTVIEW_CREATEOBJECT.Content.prototype.toPage = function (index) {
    this.pageIndex = eval(index);
    if (this.pageIndex < 0) {
        this.pageIndex = 0;
    }
    this.setUpPage(this.pageIndex);
    
    //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
    return this;
};

/**
* Transition Class Definition 
*/
CONTENTVIEW_CREATEOBJECT.Transition = function(){ };

//Start Functon : No.4 - Editor : Long - Date : 08/09/2013 - Summary : 
/* Flip Next Page Transition */
CONTENTVIEW_CREATEOBJECT.Transition.prototype.flipNextPage = function () {
    
    //#12373
    var tmpScale = 1;
    
    var w = $('#canvasWrapper').width();
    CONTENTVIEW.removeObject();
    if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_FadeIn){
        $('#mainNext').css('left', CONTENTVIEW.marginX + 'px');
        $('#mainNext').css('display', 'block');
        $('#main').css('z-index', '1');
    }
    else{
        $('#mainNext').css('display', 'block');
    }
         
    if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
       
       tmpScale = CONTENTVIEW.userScale;
       CONTENTVIEW.userScale = 1;
       CONTENTVIEW.flip(1);
       
       if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
           $('#canvasWrapper').stop(true).animate(
                { left: '-' + w + 'px' },
                {
                    duration: CONTENTVIEW_GENERAL.animatePeriod,
                    complete: function () {                                                                                                                            
                        
                    	CONTENTVIEW_GETDATA.assignCurrentContentPage(1);
                        
                        //Change id of canvas
                        CONTENTVIEW_GETDATA.switchCanvas(1);
                        
                        //restore canvas event
                        CONTENTVIEW.setDefaultEvent();
                        
                        //init image bookmark                       
                        CONTENTVIEW_INITOBJECT.initImageBookmark();
                                                                        
                        //Change slider
                        CONTENTVIEW.changeSlider(CONTENTVIEW_GETDATA.getContent().pageIndex);
                        
                        //Draw marking on current screen
                        //CONTENTVIEW.drawMarkingOnScreen();                                            
                        
                        //Correct position of canvas for next flipping
                        CONTENTVIEW_GETDATA.correctCanvasPosition();
                       
                       //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
                        CONTENTVIEW_CREATEOBJECT.createPageBGM();
                       //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM                             
                        if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
                            
                            //Get Next Page Object
                        	CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex() + 1);
                                                        
                            //Load Next
                            CONTENTVIEW_GETDATA.renderNextPage();                                     
                            
                        }else{
                            //Enable all control
                        	CONTENTVIEW_GENERAL.enableAllControl(); 
                            $('#divImageLoading').css('display', 'none');
                            CONTENTVIEW_GENERAL.isLoadingObject = false;
                        }                                                 
                                                                                                        
                        /* init image had draw */
                        CONTENTVIEW_INITOBJECT.initDisplayMarking();
                        
                        /* change title of page */
                        if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex]) {
                            if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] != '') {
                                document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] + ' | ' + I18N.i18nText('sysAppTitle');
                            } else {
                                document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                            }
                        } else {
                            document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                        }
                        /* set end log */
                        COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                        CONTENTVIEW_EVENTS.createLockLayout(false);
                        CONTENTVIEW_INITOBJECT.initImageCheckMarking();
                        
                        //#12373
                        //console.log("tmpScale:" + tmpScale);
                        if (tmpScale != 1) {
                        	CONTENTVIEW.userScale = tmpScale;
                        	CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
                        	CONTENTVIEW.flip();
                        	CONTENTVIEW.checkDisableButtonZoom();
                        }
                        
                    }
                });
       }
       else if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_FadeIn){
           $('#main').stop(true).fadeOut(
                {                   
                    duration: CONTENTVIEW_GENERAL.animatePeriod,
                    complete: function () {                                                                                                                            
                              
                    	CONTENTVIEW_GETDATA.assignCurrentContentPage(1);
                                                                                    
                        //Change id of canvas
                        CONTENTVIEW_GETDATA.switchCanvas(1);
                        
                        //restore canvas event
                        CONTENTVIEW.setDefaultEvent();
                        
                        //init image bookmark                       
                        CONTENTVIEW_INITOBJECT.initImageBookmark();
                                                                        
                        //Change slider
                        CONTENTVIEW.changeSlider(CONTENTVIEW_GETDATA.getContent().pageIndex);
                        
                        //Draw marking on current screen
                        //CONTENTVIEW.drawMarkingOnScreen();                                            
                        
                        //Correct position of canvas for next flipping
                        CONTENTVIEW_GETDATA.correctCanvasPosition();
                                        
                                        
                        if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
                            
                            //Get Next Page Object
                        	CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex() + 1);
                                                        
                            //Load Next
                            CONTENTVIEW_GETDATA.renderNextPage();
                                         
                        }
                        else{
                            //Enable all control
                        	CONTENTVIEW_GENERAL.enableAllControl(); 
                            $('#divImageLoading').css('display', 'none');
                            CONTENTVIEW_GENERAL.isLoadingObject = false;
                        }                                                
                                 
                        /* init image had draw */
                        CONTENTVIEW_INITOBJECT.initDisplayMarking();
                                      
                        /* change title of page */
                        if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex]) {
                            if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] != '') {
                                document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] + ' | ' + I18N.i18nText('sysAppTitle');
                            } else {
                                document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                            }
                        } else {
                            document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                        }
                        /* set end log */
                        COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                        CONTENTVIEW_EVENTS.createLockLayout(false);
                        CONTENTVIEW_INITOBJECT.initImageCheckMarking();
                    }
                });
        }
       CONTENTVIEW_INITOBJECT.initImageCheckMarking();          
    }
};
/* Flip Previous Page Transition */
CONTENTVIEW_CREATEOBJECT.Transition.prototype.flipPreviousPage = function () {

    //#12373
    var tmpScale = 1;

    var w = $('#canvasWrapper').width();
    CONTENTVIEW.removeObject();
    if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_FadeIn){
        $('#mainPre').css('left', CONTENTVIEW.marginX + 'px');
        $('#mainPre').css('display', 'block');
        $('#main').css('z-index', '1');
    }
    else{
        $('#mainPre').css('display', 'block');
    }
    if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {
    
        tmpScale = CONTENTVIEW.userScale;
        CONTENTVIEW.userScale = 1;
        CONTENTVIEW.flip(2);
    
        if(CONTENTVIEW_GENERAL.animateType == CONTENTVIEW_GENERAL.animateTypeKeys.Type_Slide){
            $('#canvasWrapper').stop(true).animate(
                { left: w + 'px' },
                {
                    duration: CONTENTVIEW_GENERAL.animatePeriod,
                    complete: function () {                                                                                                                            
                              
                    	CONTENTVIEW_GETDATA.assignCurrentContentPage(2);
                                                                                    
                        //Change id of canvas
                        CONTENTVIEW_GETDATA.switchCanvas(2);
                        
                        //restore canvas event
                        CONTENTVIEW.setDefaultEvent();
                        
                        //init image bookmark                       
                        CONTENTVIEW_INITOBJECT.initImageBookmark();
                                                                        
                        //Change slider
                        CONTENTVIEW.changeSlider(CONTENTVIEW_GETDATA.getContent().pageIndex);
                        
                        //Draw marking on current screen
                        //CONTENTVIEW.drawMarkingOnScreen();                                            
                        
                        //Correct position of canvas for next flipping
                        CONTENTVIEW_GETDATA.correctCanvasPosition();
                        
                        //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM              
                        CONTENTVIEW_CREATEOBJECT.createPageBGM();
                        //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
                        if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
                            //Get Next Page Object
                        	CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex() - 1);
                            //Load Next
                            CONTENTVIEW_GETDATA.renderPrevPage();
                        }else{
                            //Enable all control
                        	CONTENTVIEW_GENERAL.enableAllControl(); 
                            $('#divImageLoading').css('display', 'none');
                            CONTENTVIEW_GENERAL.isLoadingObject = false;
                        }                                                                            
                               
                        /* init image had draw */
                        CONTENTVIEW_INITOBJECT.initDisplayMarking();
                        
                        /* change title of page */
                        if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex]) {
                            if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] != '') {
                                document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] + ' | ' + I18N.i18nText('sysAppTitle');
                            } else {
                                document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                            }
                        } else {
                            document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                        }
                        
                        /* set end log */
                        COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                        CONTENTVIEW_EVENTS.createLockLayout(false);
                        CONTENTVIEW_INITOBJECT.initImageCheckMarking();
                        
                        //#12373
                        //console.log("tmpScale:" + tmpScale);
                        if (tmpScale != 1) {
                        	CONTENTVIEW.userScale = tmpScale;
                        	CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
                        	CONTENTVIEW.flip();
                        	CONTENTVIEW.checkDisableButtonZoom();
                        }
                        
                    }
                });
        }
        else{
            $('#main').stop(true).fadeOut(
                {
                    duration: CONTENTVIEW_GENERAL.animatePeriod,
                    complete: function () {                                                                                                                            
                              
                    	CONTENTVIEW_GETDATA.assignCurrentContentPage(2);
                                                                                    
                        //Change id of canvas
                        CONTENTVIEW_GETDATA.switchCanvas(2);
                        
                        //restore canvas event
                        CONTENTVIEW.setDefaultEvent();
                        
                        //init image bookmark                       
                        CONTENTVIEW_INITOBJECT.initImageBookmark();
                                                                        
                        //Change slider
                        CONTENTVIEW.changeSlider(CONTENTVIEW_GETDATA.getContent().pageIndex);
                        
                        //Draw marking on current screen
                        //CONTENTVIEW.drawMarkingOnScreen();                                            
                        
                        //Correct position of canvas for next flipping
                        CONTENTVIEW_GETDATA.correctCanvasPosition();
                                        
                                        
                        if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
                            
                            //Get Next Page Object
                        	CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, CONTENTVIEW_GETDATA.getPageIndex() - 1);
                                                        
                            //Load Next
                            CONTENTVIEW_GETDATA.renderPrevPage();
                        }else{
                            //Enable all control
                        	CONTENTVIEW_GENERAL.enableAllControl(); 
                            $('#divImageLoading').css('display', 'none');
                            CONTENTVIEW_GENERAL.isLoadingObject = false;
                        }                                                                        
                                                       
                        /* init image had draw */
                        CONTENTVIEW_INITOBJECT.initDisplayMarking();
     
                        /* change title of page */
                        if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex]) {
                            if (CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] != '') {
                                document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[CONTENTVIEW_GETDATA.getContent().pageIndex] + ' | ' + I18N.i18nText('sysAppTitle');
                            } else {
                                document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                            }
                        } else {
                            document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                        }
                        /* set end log */
                        COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                        CONTENTVIEW_EVENTS.createLockLayout(false);
                        CONTENTVIEW_INITOBJECT.initImageCheckMarking();
                    }
                });
        }
        
    }
};
//Start Functon : No.4 - Editor : Long - Date : 08/09/2013 - Summary : 
/* Flip  Page Transition */
CONTENTVIEW_CREATEOBJECT.Transition.prototype.flipToPage = function (index) {

    //#12373
    var tmpScale = CONTENTVIEW.userScale;

    var w = $('#main').attr('width');
    
    if (index == CONTENTVIEW_GETDATA.getContent().pageIndex) {
        /* init image had draw */
    	CONTENTVIEW_INITOBJECT.initDisplayMarking();       
    } else if (index < CONTENTVIEW_GETDATA.getContent().pageIndex) {
    	CONTENTVIEW_GENERAL.context_main.clearRect(0, 0, CONTENTVIEW_GENERAL.canvas_main.width, CONTENTVIEW_GENERAL.canvas_main.height);
        CONTENTVIEW.removeObject();
        $('#main').animate(
                { left: w + 'px' },
                {
                    duration: CONTENTVIEW_GENERAL.animatePeriod,
                    complete: function () {
                        $('#main').css('left', -w + 'px');
                        $('#main').animate(
                            { left: CONTENTVIEW.marginX + 'px' },
                            { duration: CONTENTVIEW_GENERAL.animatePeriod,
                                complete: function () {
                                	CONTENTVIEW_GENERAL.isFirstLoad = true;
                                    //CONTENTVIEW.screenFit();
                                }
                            });
                        //change pageIndex and image bookmark
                        CONTENTVIEW.userScale = 1;
                        CONTENTVIEW.userScaleNow = 1;
                        //START TRB00097
                        //CONTENTVIEW.changeScale(CONTENTVIEW.userScale);   
                        CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
                        CONTENTVIEW.srcRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
                        CONTENTVIEW.srcRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
                        
                        CONTENTVIEW.destRect = 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.checkDisableButtonZoom();
                        CONTENTVIEW_GETDATA.getContent().toPage(index);                      
                        
                        if(index > 0){
                        	CONTENTVIEW_GENERAL.prevContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
                        	CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, index - 1);               
                            CONTENTVIEW_GETDATA.renderPrevPage();
            
                        }
                        
                        if(index < CONTENTVIEW_GENERAL.totalPage - 1){
                        	CONTENTVIEW_GENERAL.nextContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
                        	CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, index + 1);
                            CONTENTVIEW_GETDATA.renderNextPage();
                        }
                    
                        CONTENTVIEW_INITOBJECT.initImageBookmark();
                        CONTENTVIEW.checkExistNextPrePage();
                        CONTENTVIEW.changeSlider(index);
                        /* init image had draw */
                        CONTENTVIEW_INITOBJECT.initDisplayMarking();
                        /* change title of page */
                        if (CONTENTVIEW_GENERAL.dataPageTitle[index]) {                         
                            if (CONTENTVIEW_GENERAL.dataPageTitle[index] != '') {
                                document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[index] + ' | ' + I18N.i18nText('sysAppTitle');
                            } else {
                                document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                            }
                        } else {
                            document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                        }
                        /* set end log */
                        COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                        CONTENTVIEW_INITOBJECT.initImageCheckMarking();
                        
                        CONTENTVIEW_EVENTS.createLockLayout(false);
                        
                        //#12373
                        //console.log("tmpScale:" + tmpScale);
                        if (tmpScale != 1) {
                        	CONTENTVIEW.userScale = tmpScale;
                        	CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
                        	CONTENTVIEW.flip();
                        }
                        
                    }
                }
             );
    } 
    else {
    	CONTENTVIEW_GENERAL.context_main.clearRect(0, 0, CONTENTVIEW_GENERAL.canvas_main.width, CONTENTVIEW_GENERAL.canvas_main.height);
        CONTENTVIEW.removeObject();
        $('#main').animate(
                { left: '-' + w + 'px' },
                {
                    duration: CONTENTVIEW_GENERAL.animatePeriod,
                    complete: function () {
                        $('#main').css('left', w + 'px');
                        $('#main').animate(
                            { left: CONTENTVIEW.marginX + 'px' },
                            { duration: CONTENTVIEW_GENERAL.animatePeriod,
                                complete: function () {
                                	CONTENTVIEW_GENERAL.isFirstLoad = true;
                                    //CONTENTVIEW.screenFit();
                                }
                            });
                        //change pageIndex and image bookmark
                        CONTENTVIEW.userScale = 1;
                        //START TRB00097
                        //CONTENTVIEW.changeScale(CONTENTVIEW.userScale);   
                        CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
                        CONTENTVIEW.srcRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
                        CONTENTVIEW.srcRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
                        
                        CONTENTVIEW.destRect = 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.checkDisableButtonZoom();
                        CONTENTVIEW_GETDATA.getContent().toPage(index);    
                        
                        if(index > 0){
                        	CONTENTVIEW_GENERAL.prevContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
                        	CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, index - 1);                
                            CONTENTVIEW_GETDATA.renderPrevPage();
            
                        }
                        
                        if(index < CONTENTVIEW_GENERAL.totalPage - 1){
                        	CONTENTVIEW_GENERAL.nextContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
                        	CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, index + 1);
                            CONTENTVIEW_GETDATA.renderNextPage();
                        }

                        CONTENTVIEW_INITOBJECT.initImageBookmark();
                        CONTENTVIEW.checkExistNextPrePage();
                        CONTENTVIEW.changeSlider(index);
                        /* init image had draw */
                        CONTENTVIEW_INITOBJECT.initDisplayMarking();
                        /* change title of page */
                        if (CONTENTVIEW_GENERAL.dataPageTitle[index]) {
                            if (CONTENTVIEW_GENERAL.dataPageTitle[index] != '') {
                                document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[index] + ' | ' + I18N.i18nText('sysAppTitle');
                            } else {
                                document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                            }
                        } else {
                            document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                        }
                        /* set end log */
                        COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
                        CONTENTVIEW_INITOBJECT.initImageCheckMarking();
                        
                        CONTENTVIEW_EVENTS.createLockLayout(false);
                        
                        //#12373
                        //console.log("tmpScale:" + tmpScale);
                        if (tmpScale != 1) {
                        	CONTENTVIEW.userScale = tmpScale;
                        	CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
                        	CONTENTVIEW.flip();
                        }
                        
                    }
                });
    }   
    
};

CONTENTVIEW_CREATEOBJECT.createTextConfirmAudio = function() {
    var text = I18N.i18nText('msgBGMPlayConfirm');
    $('#txtAudio').html(text);
    var text = I18N.i18nText('msgBGMPagePlayConfirm');
    $('#txtAudio_page').html(text);
};

/* create page */
CONTENTVIEW_CREATEOBJECT.createPage = function(pageNumber, pageImage, pageObjects, onCompleteFunc) {

	//abe 次のページを作成している
	//console.log("CreateObj_createPage:" + pageNumber)
	
    var page = new CONTENTVIEW.ContentPage(pageNumber, pageImage);
    /* add page Object */
    //Start Function: No.12
    if (CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile) {
        page.addPageObjects(pageObjects);
    }
    //End Function: No.12
    /* load page */
    page.load(onCompleteFunc);
    
    return page;
};

CONTENTVIEW_CREATEOBJECT.createImagePreview = function() {
    $('#dialog').prepend(
        '<h1>' +
        '<img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnClose" class="align_right" ></img>' +
        '</h1>' +
        '<div id="divImagePreview" class="content_image_preview">' +
        '</div>'
    );
    $('#dialog').css('box-shadow', '0px 0px 3px 1px #666');
    $('#dialog').css('border', 'solid 1px #666');

    $('#dialog').draggable({ handle: "h1" });
};

/* create video on page */
CONTENTVIEW_CREATEOBJECT.createVideoFulScreen = function(video, id) {
    $('#dialog').css('box-shadow', '0px 0px 3px 1px #666');
    $('#dialog').css('border', 'solid 1px #666');
    $('#dialog').draggable({ handle: "h1" });
    
    $('#dialog').children().remove();
    if (ClientData.userOpt_videoMode() == "1") {/* loop video */
        $('#dialog').html(
            '<h1>' +
            '   <img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnCloseVideo" class="align_right" ></img>' +
            '</h1>' +
            '       <div id="videoMedia' + id + '">' +
            '           <video style="height:90%; width:100%;" class="mov" id="videoOnPopUp" autoplay controls loop>' +
            '            <source src="' + video + '" type="video/mp4"> ' +
            '    </video>' +
            '       </div>'
            );
    } else {
        $('#dialog').html(
            '<h1>' +
            '   <img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnCloseVideo" class="align_right" width=25px" ></img>' +
            '</h1>' +
            '       <div id="videoMedia' + id + '">' +
            '           <video style="height:90%; width:100%;" id="videoOnPopUp" class="mov" autoplay controls>' +
            '            <source src="' + video + '" type="video/mp4"> ' +
            '    </video>' +
            '       </div>'
            );
    }
    $('#videoOnPopUp').css('height', ($('#dialog').height() - 25) + "px");
    //CONTENTVIEW.showControlsVideo($('#videoOnPopUp'));
};

/* create audio on page */
CONTENTVIEW_CREATEOBJECT.createAudio = function(audio, type) {
    // if(CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox'){
    // audio =  audio.replace("webResourceDownload/", "webResourceDownload");
    // }
	
    if (audio != '') {
        if (type == "0") { /* play when click */
        	CONTENTVIEW.stopAllAudio();

        	CONTENTVIEW.TypeAudio0 = type;
            CONTENTVIEW.srcAudioType0 = audio;

            if (ClientData.userOpt_musicMode() == "1") {
                //if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                //    $('#playaudio').html(
                //        '    <embed id="play_audio_0" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" loop="true" hidden="true"> </embed>'
                //    );
                //} else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                    $('#playaudio').html(
                        '   <audio  id="play_audio_0" loop="loop"  >' +
                        '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                        '   </audio>'
                        );
                } else {
                    $('#playaudio').html(
                        '   <audio  id="play_audio_0" loop="loop"  autoplay ="autoplay">' +
                        '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                        '   </audio>'
                    );
                }

            } else {
                //if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                //    $('#playaudio').html(
                //        '    <embed id="play_audio_0" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" hidden="true"> </embed>'
                //    );
                //} else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                    $('#playaudio').html(
                        '   <audio  id="play_audio_0">' +
                        '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                        '   </audio>'
                        );
                } else {
                    $('#playaudio').html(
                        '   <audio  id="play_audio_0" autoplay ="autoplay">' +
                        '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                        '   </audio>'
                    );
                }

            }

            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                document.getElementById("play_audio_0").load();
                document.getElementById("play_audio_0").play();
            }
            
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) { 
            	var myAudio=document.getElementById("play_audio_0"); 
            	if (myAudio.paused)
            	{
            		myAudio.play();
            	}
            }

        } 
        else if (type == "1") { /* play all page */        
           
            if (document.getElementById("play_audio_1") != undefined) {

                if (ClientData.userOpt_musicMode() == "1") {
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                        /*
                        $('#playaudioallpage').html(
                                                    '    <embed id="play_audio_1" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" loop="true"  hidden="true"> </embed>'
                                                );*/
                        
                    } 
                    else {
                        if(!CONTENTVIEW.isPendingContentBGM){
                            document.getElementById("play_audio_1").play();
                        }                       
                    }
                }
                else {
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
/*
                        $('#playaudioallpage').html(
                            '    <embed id="play_audio_1" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" hidden="true"> </embed>'
                        );*/

                    } else {
                        if(!CONTENTVIEW.isPendingContentBGM){
                            document.getElementById("play_audio_1").play();
                        }
                    }
                }
                
                //if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) { 
                //	var myAudio=document.getElementById("play_audio_1"); 
                //	if (myAudio.paused)
                //	{
                //		myAudio.play();
                //	}
                //}
                
            } 
            else {
            	CONTENTVIEW.TypeAudio1 = type;
                CONTENTVIEW.srcAudioType1 = audio;

                if (ClientData.userOpt_musicMode() == "1") {                                        
                    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                    //    $('#playaudioallpage').html(
                    //        '    <embed id="play_audio_1" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" loop="true"  hidden="true"> </embed>'
                    //    );
                	//
                    //} 
                    //else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                        $('#playaudioallpage').html(
                             '  <audio  id="play_audio_1" loop="loop" >' +
                             '       <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                             '  </audio>'
                         );
                    }
                    else {                      
                        if(CONTENTVIEW.isPendingContentBGM){
                            $('#playaudioallpage').html(
                                 '  <audio  id="play_audio_1" loop="loop" >' +
                                 '       <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                                 '  </audio>'
                             );
                             document.getElementById('play_audio_1').load();
                             CONTENTVIEW.isPendingContentBGM = false;
                             
                        }
                        else{
                            $('#playaudioallpage').html(
                                 '  <audio  id="play_audio_1" loop="loop" autoplay="autoplay" >' +
                                 '       <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                                 '  </audio>'
                             );
                        }
                    }
                }
                else {
                    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                    //    $('#playaudioallpage').html(
                    //        '    <embed id="play_audio_1" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" hidden="true"> </embed>'
                    //    );
                    //} else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                        $('#playaudioallpage').html(
                             '  <audio  id="play_audio_1" >' +
                             '       <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                             '  </audio>'
                         );
                    } else {
                        if(CONTENTVIEW.isPendingContentBGM){
                            $('#playaudioallpage').html(
                                 '  <audio  id="play_audio_1" >' +
                                 '       <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                                 '  </audio>'
                             );
                             document.getElementById('play_audio_1').load();
                             CONTENTVIEW.isPendingContentBGM = false;
                             
                        }
                        else{
                            $('#playaudioallpage').html(
                                 '  <audio  id="play_audio_1" autoplay="autoplay" >' +
                                 '       <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                                 '  </audio>'
                             );
                        }
                    }
                }
                // Check to play BGM on ipad
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
                    //START TRB00069
                    if(CONTENTVIEW.isPendingContentBGM){
                    	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
                    		document.getElementById('play_audio_1').load();
                    	}
                        CONTENTVIEW.isPendingContentBGM = false;
                    }
                    else{
                        // Show confim message to play background music
                        $("#bgmConfirm_dspCancel").unbind('click');
                        $("#bgmConfirm_dspCancel").click(function () {
                            $("#bgmConfirm").hide();
                        });
                        $("#bgmConfirm_dspOK").unbind('click');
                        $("#bgmConfirm_dspOK").click(function () {
                        	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
                        		document.getElementById('play_audio_1').load();
                        	}
                            document.getElementById('play_audio_1').play();
                            $("#bgmConfirm").hide();
                        });
                        $("#bgmConfirm").show();
                        $("#bgmConfirm").center();
                    }
                    //END TRB00069
                }
                
            }
        }
        else if (type == "2") { /* play on page */                    
           
            if (document.getElementById("play_audio_2") == undefined) {
            	CONTENTVIEW.stopAllAudio();

            	CONTENTVIEW.TypeAudio2 = type;
                CONTENTVIEW.srcAudioType2 = audio;

                if (ClientData.userOpt_musicMode() == "1") {
                    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                    //    $('#playaudiopage').html(
                    //            '    <embed id="play_audio_2" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" loop="true" hidden="true"> </embed>'
                    //        );
                    //} else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                        $('#playaudiopage').html(
                            '   <audio  id="play_audio_2" loop="loop" >' +
                            '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                            '   </audio>'
                        );
                    } else {
                        $('#playaudiopage').html(
                            '   <audio  id="play_audio_2" loop="loop" autoplay ="autoplay">' +
                            '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                            '   </audio>'
                        );
                    }
                } else {
                    //if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
                    //    $('#playaudiopage').html(
                    //            '    <embed id="play_audio_2" src="' + audio + '&key=' + (new Date()).toIdString() + '" autostart="true" hidden="true"> </embed>'
                    //        );
                    //} else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
                        $('#playaudiopage').html(
                            '   <audio  id="play_audio_2" >' +
                            '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                            '   </audio>'
                        );
                    } else {
                        $('#playaudiopage').html(
                            '   <audio  id="play_audio_2" autoplay ="autoplay">' +
                            '        <source src="' + audio + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
                            '   </audio>'
                        );
                    }
                }

                // Check to play BGM on ipad
                if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
                    // Show confim message to play background music
                    $("#bgmConfirm_dspCancel_page").unbind('click');
                    $("#bgmConfirm_dspCancel_page").click(function () {
                        $("#bgmConfirm_page").hide();
                    });
                    $("#bgmConfirm_dspOK_page").unbind('click');
                    $("#bgmConfirm_dspOK_page").click(function () {
                    	if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
                    		document.getElementById('play_audio_2').load();
                    	}
                        document.getElementById('play_audio_2').play();
                        $("#bgmConfirm_page").hide();
                    });
                    
                    $("#bgmConfirm_page").show();
                    $("#bgmConfirm_page").center();
                }
                
            }
        }
    }
    else {
    	CONTENTVIEW.stopAllAudio();
    }

};

//START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
CONTENTVIEW_CREATEOBJECT.createPageBGM = function(){
    
    var currentPageObject = CONTENTVIEW_GETDATA.getContent().pageObjects;
    var audioFile  = '';
    var playType = '';
    $('#playaudiopage').html('');
    for(var i = 0; i < currentPageObject.length; i++){
        var BGMObject = currentPageObject[i];
        
        if(BGMObject.mediaType == '3' && BGMObject.actionType=='2' && BGMObject.playType == '2'){           
            
            audioFile = BGMObject.audioFile;
            playType = BGMObject.playType;
            
            CONTENTVIEW_CREATEOBJECT.createAudio(audioFile, playType);
            
            break;
        }
    }                
};
//END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM

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

CONTENTVIEW_CREATEOBJECT.ready = function(){
	//初期化用
	CONTENTVIEW_CREATEOBJECT.memoObjects = [];
	CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects = [];
	CONTENTVIEW_CREATEOBJECT.moveContentParam = {};
};

