
/// <reference path="../common/js/jquery-ui-1.8.23.custom.min.js" />

/// <reference path="../common/js/common.js" />

/// <reference path="contentview_VarDef.js" />

/// <reference path="contentview_CallApi.js" />

//START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
/* get Json stored content info */
function getJsonContentInfo() {
    avwGrabContentPageImage(ClientData.userInfo_accountPath(),
         { contentId: contentID, sid: ClientData.userInfo_sid(), pageNo: 1 },
         function (data) {    
             pageImages = data;         
             webGetContentData();
             getSearchDataFromJson();
             getJsonDataPageTitle();
             getJsonDataType4();
             getJsonDataType5();
             getDataJsonFile();
             //webGetPageImageContentSize();
             webGetContentPageSize();
         },
         function (xmlHttpRequest, txtStatus, errorThrown) {
             showErrorScreen();
         });
};
//END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content


/* get url */
function getURL(apiName) {
    var sysSettings = avwSysSetting();
    var url = sysSettings.apiResourceDlUrl;
    url = format(url, ClientData.userInfo_accountPath()) + '/' + apiName;
    return url;
};

/* get url */
function getURLPageImage(apiName) {
    var sysSettings = avwSysSetting();
    var url = sysSettings.apiUrl;
    url = format(url, ClientData.userInfo_accountPath()) + '/' + apiName;
    return url;
};

function getPageObjectsByPageIndex(contentData, nIndexPage) {
    pageObjects = [];

    var currentPageObjects;
    for (var nIndex = 0; nIndex < contentData.length; nIndex++) {
        if (contentData[nIndex].page == nIndexPage) {
            currentPageObjects = contentData[nIndex].objects;
            //Start Function: No.9 - Editor : Long - Summary : 
            if(contentData[nIndex].contentDataSub != null && contentData[nIndex].contentDataSub.length > 0){
                //currentPageObjects["contentDataSub"] = contentData[nIndex].contentDataSub;
                for(var i = 0; i < currentPageObjects.length; i++){
                    var tempObj = currentPageObjects[i];
                    tempObj["contentDataSub"] = contentData[nIndex].contentDataSub;
                }               
            }            
            //End Function: No.9 - Editor : Long 
            break;
        }
    }

    if (currentPageObjects != undefined) {
        for (var nIndex = 0; nIndex < currentPageObjects.length; nIndex++) {
            /*get object page*/
            if (currentPageObjects[nIndex].mediaType == 1) {/*media type = 1 */
                var pageObject = getMediaType1(currentPageObjects[nIndex]);
           
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 2) { /*mediaType = 2 */
                var pageObject = getMediaType2(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 3) { /*mediaType = 3*/
                var pageObject = getMediaType3(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 4) { /*mediaType = 4*/
                var pageObject = getMediaType4(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 5) { /*mediaType = 5*/
                var pageObject = getMediaType5(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 6) { /*mediaType = 6*/
                var pageObject = getMediaType6(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 7) { /*mediaType = 7*/
                var pageObject = getMediaType7(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 8) { /*mediaType = 8*/
                var pageObject = getMediaType8(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 9) { /*mediaType = 9*/
                var pageObject = getMediaType9(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 11) { /*mediaType = 11*/
                var pageObject = getMediaType11(currentPageObjects[nIndex]);
                /*add object to page */
                pageObjects.push(pageObject);
            }
        }
    }
};

/*get data mediaType = 1 */
function getMediaType1(iValueObj) {
    /*
    * Action Type = 1 : video
    * Action Type = 2 : music
    * Action Type = 3 : url
    * Action Type = 4 : image preview
    * Action Type = 5 : jump page
    * Action Type = 6 : email
    * Action Type = 7 : 
    * Action Type = 8 : popup
    * Action Type = 9 : video
    * Action Type = 10 : content
    * Action Type = 11 : html
    */

    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;
    pageObject['actionType'] = iValueObj.action.actionType;
    pageObject['visible'] = true;

    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['id'] = "MediaType1_" + iValueObj.action.actionType;
    
	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;
    
    if (iValueObj.action.actionType == 0) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }
    } else if (iValueObj.action.actionType == 1) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get video file */
        if (iValueObj.action.video) {
            pageObject['mediaFile'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceName=" + removeExt(iValueObj.action.video);
            pageObject['media'] = iValueObj.action.video;
            pageObject['mediaResourceId'] = iValueObj.action.resourceId;
        } else {
            pageObject['mediaFile'] = '';
            pageObject['media'] = '';
            pageObject['mediaResourceId'] = '';
        }

    } else if (iValueObj.action.actionType == 2) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get video file */
        if (iValueObj.action.music) {
            if (avwUserEnvObj.browser == 'msie') {
                pageObject['audioFile'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceName=" + removeExt(iValueObj.action.music) + "&isIE=true";
            } else {
                pageObject['audioFile'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceName=" + removeExt(iValueObj.action.music);
            }
            pageObject['audio'] = iValueObj.action.music;
            pageObject['audioResourceId'] = iValueObj.action.resourceId;
        } else {
            pageObject['audioFile'] = '';
            pageObject['audio'] = "";
            pageObject['audioResourceId'] = "";
        }

    } else if (iValueObj.action.actionType == 3) {
        /*get browserType */
        if (iValueObj.action.browserType) {
            pageObject['browserType'] = iValueObj.action.browserType;
        } else {
            pageObject['browserType'] = '';
        }

        /*get browser */
        if (iValueObj.action.browser) {
            pageObject['browser'] = iValueObj.action.browser;
        } else {
            pageObject['browser'] = '';
        }

        /*get linkUrl */
        if (iValueObj.action.linkUrl) {
            pageObject['linkUrl'] = iValueObj.action.linkUrl;
        } else {
            pageObject['linkUrl'] = '';
        }

        /*get mediaInfo */
        if (iValueObj.mediaInfo) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /* action */
        pageObject['action'] = null;

    } else if (iValueObj.action.actionType == 4) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo.resourceId) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get Image Preview */
        var dataResourceImage = iValueObj.action.preview;
        var dataImageFromResource = [];
        pageObject['imagePreviewResourceIds'] = [];
        //START TRB00077 - Editor : Long - Date: 09/24/2013- Summary : Display image preview no image
        if(dataResourceImage){                  
            for (var nIndex = 0; nIndex < dataResourceImage.length; nIndex++) {
                dataImageFromResource.push(getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceName=" + removeExt(dataResourceImage[nIndex]));
            }
            pageObject['imagePreviewResourceIds'] = iValueObj.action.resourceIds;
        }       
        //END TRB00077 - Editor : Long - Date: 09/24/2013- Summary : Display image preview no image
        pageObject['imagePreview'] = dataImageFromResource;

    } else if (iValueObj.action.actionType == 5) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo.resourceId) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get Image Preview */
        if (iValueObj.action.jumpPage) {
            pageObject['jumpPage'] = iValueObj.action.jumpPage;
        } else {
            pageObject['jumpPage'] = '';
        }

    }
    else if (iValueObj.action.actionType == 6) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo.resourceId) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get emailSubject */
        if (iValueObj.action.emailSubject) {
            pageObject['emailSubject'] = iValueObj.action.emailSubject;
        } else {
            pageObject['emailSubject'] = '';
        }

        /*get emailAddress */
        if (iValueObj.action.emailAddress) {
            pageObject['emailAddress'] = iValueObj.action.emailAddress;
        } else {
            pageObject['emailAddress'] = '';
        }

    }
    else if (iValueObj.action.actionType == 8) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo.resourceId) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get content */
        pageObject['content'] = iValueObj.action.content;
    }
    else if (iValueObj.action.actionType == 10) {
        /*get mediaInfo */
        if (iValueObj.mediaInfo.resourceId) {
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        } else {
            pageObject['imageUrl'] = null;
        }

        /*get contentId */
        pageObject['contentId'] = iValueObj.action.contentId;

        /*get pageNo */
        pageObject['pageNo'] = iValueObj.action.pageNo;

    }
    //Start Function : No.9 - Editor : Long - Date: 08/16/2013 - Summary : 
    else if(iValueObj.action.actionType == 11){
        var resourceId = iValueObj.action.resourceId;
        var resourceUrl = "";
        
        //START TRB00093 - Editor : Long - Date: 09/26/2013 - Summary : Check undefine before get
        if(iValueObj.contentDataSub){
            
            for(var i = 0; i < iValueObj.contentDataSub.length; i++){
                var tempData = iValueObj.contentDataSub[i];
                
                if(tempData.resourceId == resourceId){
                    resourceUrl = tempData.resourceUrl;
                    break;
                }
            }
        }              
        //END TRB00093 - Editor : Long - Date: 09/26/2013 - Summary : Check undefine before get
        
        pageObject["imageUrl"] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        pageObject["resourceUrl"] = resourceUrl;
    }
    else if(iValueObj.action.actionType == 12){
            
        pageObject["imageUrl"] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        pageObject["resourceUrl"] = resourceUrl;
        
        pageObject["questionNo"] = iValueObj.action.questionNo;
        pageObject["replyLimit"] = iValueObj.action.replyLimit;
        pageObject["fullScreen"] = iValueObj.action.fullScreen;
        pageObject["saveAs"] = iValueObj.action.saveAs;
        pageObject["resourceId"] = iValueObj.action.resourceId;
        pageObject["enquete"] = iValueObj.action.enquete;
        //pageObject["objectId"] = iValueObj.action.objectId;
    }
    //End Function : No.9 - Editor : Long - Date: 08/16/2013 - Summary : 
    return pageObject;
};

function getMediaType2(iValueObj) {
    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;

    /*get actionType*/
    if (iValueObj.action.actionType) {
        pageObject['actionType'] = iValueObj.action.actionType;
    } else {
        pageObject['actionType'] = '';
    }

    pageObject['id'] = "media" + iValueObj.mediaInfo.resourceId;

    /*get mediaInfo */
    if (iValueObj.mediaInfo.resourceId) {
        pageObject['mediaFile'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        pageObject['media'] = iValueObj.mediaInfo.resourceId; //video1のほうはリソース名で取得している。IDのほうが良いのでは。
    } else {
        pageObject['mediaFile'] = '';
        pageObject['media'] = '';
    }

    /*get mediaInfo */
    if (iValueObj.action.embed) {
        pageObject['embed'] = iValueObj.action.embed;
    } else {
        pageObject['embed'] = '';
    }

    pageObject['imageUrl'] = 'img/iPad_video.png';

    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;

	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

function getMediaType3(iValueObj) {
    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;

    /*get actionType*/
    if (iValueObj.action.actionType) {
        pageObject['actionType'] = iValueObj.action.actionType;
    } else {
        pageObject['actionType'] = '';
    }

    pageObject['id'] = "audio" + iValueObj.mediaInfo.resourceId;

    /*get mediaInfo */
    if (iValueObj.mediaInfo.resourceId) {
        if (avwUserEnvObj.browser == 'msie') {
            pageObject['audioFile'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId + "&isIE=true";
        } else {
            pageObject['audioFile'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        }
        pageObject['audioResourceId'] = iValueObj.mediaInfo.resourceId;
    } else {
        pageObject['audioFile'] = '';
        pageObject['audioResourceId'] = '';
    }

    /*get playtype */
    pageObject['playType'] = iValueObj.action.playType;

    pageObject['imageUrl'] = 'img/iPad_music.png';

    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;

	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

function getMediaType4(iValueObj) {
    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;

    pageObject['id'] = iValueObj.mediaInfo.id;

    /*get image List info */
    var imageObjects = iValueObj.mediaInfo.media;

    for (var nIndex = 0; nIndex < imageObjects.length; nIndex++) {
        /* get image from Json */
        imageObjects[nIndex].fileName = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + imageObjects[nIndex].resourceId;
    }

    pageObject['dataObjects'] = imageObjects;

    if (iValueObj.mediaInfo.triggerType) {
        pageObject['triggerType'] = iValueObj.mediaInfo.triggerType;
    } else {
        pageObject['triggerType'] = '';
    }

    /*get image url */
    if (imageObjects.length > 0) {
        pageObject['imageUrl'] = imageObjects[0].fileName;
    } else {
        pageObject['imageUrl'] = null;
    }


    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;

	//詳細ログ用（使わない）
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

function getMediaType5(iValueObj) {
    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;

    pageObject['id'] = iValueObj.mediaInfo.id;

    /*get video List info */
    var videoObjects = iValueObj.mediaInfo.media;
    for (var nIndex = 0; nIndex < videoObjects.length; nIndex++) {
        /* get image from Json */
        videoObjects[nIndex].fileName = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + videoObjects[nIndex].resourceId;
    }

    pageObject['dataObjects'] = videoObjects;

    /*get image url */
    pageObject['imageUrl'] = '';

    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;

	//詳細ログ用（使わない）
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

function getMediaType6(iValueObj) {
    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;

    /*get actionType*/
    if (iValueObj.action.actionType) {
        pageObject['actionType'] = iValueObj.action.actionType;
    } else {
        pageObject['actionType'] = '';
    }

    
    if(iValueObj.mediaInfo.resourceId){
        pageObject['id'] = "trigger" + iValueObj.mediaInfo.resourceId;
    }
    else if(iValueObj.mediaInfo.resourceThumbnailId){
        pageObject['id'] = "trigger" + iValueObj.mediaInfo.resourceThumbnailId;
    }

    /*get mediaInfo */
    if (iValueObj.mediaInfo) {
        
        if(iValueObj.mediaInfo.resourceId){
            /* get image from Json */
            pageObject['imageUrl'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        }
        else{
            pageObject['imageUrl'] = 'img/iPad_video.png';
        }
               
    } 
    else {
        pageObject['imageUrl'] = null;
    }

    /*get index */
    if (iValueObj.action.index) {
        pageObject['index'] = iValueObj.action.index;
    } 
    else {
        pageObject['index'] = '';
    }

    /*get target */
    if (iValueObj.action.target) {
        pageObject['target'] = iValueObj.action.target;
    } 
    else {
        pageObject['target'] = '';
    }

    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;

	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

function getMediaType7(iValueObj) {
    var pageObject = [];

    pageObject['mediaType'] = iValueObj.mediaType;

    /*get actionType*/
    if (iValueObj.action.actionType) {
        pageObject['actionType'] = iValueObj.action.actionType;
    } else {
        pageObject['actionType'] = '';
    }

    pageObject['id'] = "testText";

    /*get mediaInfo */
    if (iValueObj.mediaInfo.content) {
        pageObject['content'] = iValueObj.mediaInfo.content;
    } else {
        pageObject['content'] = '';
    }

    if (iValueObj.action) {
        pageObject['action'] = "";
    }

    /*get location */
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;

	//詳細ログ用（使わない）
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

//Start Function : No.9 - Editor : Long - Date : 08/15/2013 - Summary : Handle 3d object
function getMediaType8(iValueObj) {
    var pageObject = [];
    
    //Get object Info
    pageObject['mediaType'] = iValueObj.mediaType;
    pageObject['id'] = "MediaType8_" + iValueObj.mediaInfo.resourceId;
    pageObject['actionType'] = iValueObj.action.actionType;
    
    //Get object Location
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;
           
    if(iValueObj.action.actionType == 9){
        
        pageObject['horizonCount'] = iValueObj.mediaInfo.horizonCount;
        pageObject['verticalCount'] = iValueObj.mediaInfo.verticalCount;
        pageObject['initImage'] = getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + iValueObj.mediaInfo.resourceId;
        
        var _3dViewObject = [];
        var data3d = iValueObj.action["3dview"];

        var horizonCnt = 0;
        var verticalCnt = 1; 
            
            
        while(verticalCnt <= iValueObj.mediaInfo.verticalCount){
             horizonCnt++;
             if(horizonCnt > iValueObj.mediaInfo.horizonCount){
                verticalCnt++;
                if(verticalCnt > iValueObj.mediaInfo.verticalCount){
                    break;
                }
                horizonCnt = 1;
             }

             _3dViewObject[convNumTo2Char(verticalCnt)+"-"+convNumTo2Char(horizonCnt)] = 
                            getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() 
                            + "&resourceId=" + data3d[convNumTo2Char(verticalCnt) +"-"+ convNumTo2Char(horizonCnt)].resourceId;
        }                         
        
        pageObject['3dview'] = _3dViewObject;
    }

	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;

    return pageObject;
};

function getMediaType9(iValueObj) {
    var pageObject = [];
    
    //Get object Info
    pageObject['mediaType'] = iValueObj.mediaType;
    pageObject['id'] = "MediaType9_" + iValueObj.mediaInfo.resourceId;
    pageObject['actionType'] = iValueObj.action.actionType;
    
    //Get object Location
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;
    
	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;
    
    if(iValueObj.action.actionType == 11){        
        var resourceId = iValueObj.mediaInfo.resourceId;
        var resourceUrl = "";
        
        //START TRB00093 - Editor : Long - Date: 09/26/2013 - Summary : Check undefine before get
        if(iValueObj.contentDataSub){
            for(var i = 0; i < iValueObj.contentDataSub.length; i++){
                var tempData = iValueObj.contentDataSub[i];
                
                if(tempData.resourceId == resourceId){
                    resourceUrl = tempData.resourceUrl;
                    break;
                }
            }
        }       
        //START TRB00093 - Editor : Long - Date: 09/26/2013 - Summary : Check undefine before get
        
        pageObject["imageUrl"] = 'img/htmltype.png';
        pageObject["resourceUrl"] = resourceUrl;                            
    }

    return pageObject;
};

function getMediaType11(iValueObj) {
    var pageObject = [];
    
    //Get object Info
    pageObject['mediaType'] = iValueObj.mediaType;
    pageObject['id'] = "MediaType11_" + iValueObj.mediaInfo.resourceId;
    pageObject['actionType'] = iValueObj.action.actionType;
    
    //Get object Location
    pageObject['x'] = iValueObj.location.x;
    pageObject['y'] = iValueObj.location.y;
    pageObject['width'] = iValueObj.location.width;
    pageObject['height'] = iValueObj.location.height;
    pageObject['visible'] = true;
    
	//詳細ログ用
	pageObject["objectId"] = iValueObj.action.objectId;
    
   if(iValueObj.action.actionType == 12){
        var resourceId = iValueObj.mediaInfo.resourceId;
    
        pageObject["imageUrl"] = 'img/anket.jpg';
      
        pageObject["questionNo"] = iValueObj.action.questionNo;
        pageObject["replyLimit"] = iValueObj.action.replyLimit;
        pageObject["fullScreen"] = iValueObj.action.fullScreen;
        pageObject["saveAs"] = iValueObj.action.saveAs;
        pageObject["resourceId"] = resourceId;
        pageObject["enquete"] = iValueObj.action.enquete;
        //pageObject["objectId"] = iValueObj.action.objectId;
    }

    return pageObject;
};

function convNumTo2Char(num){
    var nRet = "";
    if(num < 10)
        nRet = "0" + num;
    else 
        nRet =  "" + num;
    return nRet;
};
//End Function : No.9 - Editor : Long - Date : 08/15/2013 - Summary : Handle 3d object

/* get page index */
function getPageIndex() {
    var content = getContent();
    return eval(content.pageIndex);
};

/* get data marking from local storage */
function getDataClientStorage() {
    /*set default size and color */
    if (!ClientData.penOpt_size()) {
        ClientData.penOpt_size(5);
    }

    if (!ClientData.penOpt_color()) {
        ClientData.penOpt_color("fe0000");
    }

    if (!ClientData.maker_size()) {
        ClientData.maker_size(5);
    }

    if (!ClientData.maker_color()) {
        ClientData.maker_color("f8ff00");
    }

    if (!ClientData.erase_size()) {
        ClientData.erase_size(5);
    }

    isAddingMarking = ClientData.IsAddingMarking();
    penSize = ClientData.penOpt_size();
    penColor = ClientData.penOpt_color();
    makerSize = ClientData.maker_size();
    makerColor = ClientData.maker_color();
    eraseSize = ClientData.erase_size();
    markingType = ClientData.MarkingType();
};


/* get list bookmark of content */
function getBookMarkListByContentID() {
    var bmList = [];
    var bmListResult = [];
    bmList = ClientData.BookMarkData();

    for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
        if (bmList[nIndex].contentid == contentID) {
            bmListResult.push(bmList[nIndex]);
        }
    }

    return bmListResult;
};

/* get data load*/
function getDataLoaded(data) {
    var isExist = false;

    for (var i = 0; i < data.length; i++) {
        isExist = false;
        for (var n = 0; n < arrThumbnailsLoaded.length; n++) {
            if (data[i].pageNo == arrThumbnailsLoaded[n].pageNo) {
                isExist = true;
                break;
            }
        }

        /* insert if not exist */
        if (isExist == false) {
            arrThumbnailsLoaded.push(data[i]);
        }
    }

    /* sort data */
    arrThumbnailsLoaded.sort(function (a, b) {
        var a1 = a.pageNo, b1 = b.pageNo;
        if (a1 == b1) return 0;
        return a1 > b1 ? 1 : -1;
    });

};


/* get list info bookmark */
function getBookmarklist(pos) {
    var isExistBookMarkInContent = false;
    sortBookmarkList();
    var bmList = [];
    bmList = ClientData.BookMarkData();

    for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
        if (bmList[nIndex].contentid == contentID) {
            isExistBookMarkInContent = true;
            break;
        }
    }

    if (isExistBookMarkInContent == false) {
        $('#divListBookmark').children().remove();
        $('#divListBookmark').append('<span class="last">' + i18nText('msgShioriNotExists') + '</span>');

        //title start
        $('#bookmarkBoxHdBM').children().remove();
        $('#bookmarkBoxHdBM').html('<a id="bookmarkClosing" class="delete" > </a>');
        $("#bookmarkClosing").click(closeBookmarkBox);
        $('#bookmarkBoxHdBM').append(i18nText('txtShioriCtnLs'));
        //title end
        //lockLayout();
        $('#boxBookMark').css('z-index', '101');
        $('#boxBookMark').css('display', 'block');
        $('#boxBookMark').draggable({ handle: "h1" });
        $("#boxBookMark").offset({ left: pos[0], top: pos[1] });
        $("#divListBookmark").show();
        $("#divListBookmark").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdBM').height()) });
    }
    else {              
        handleAPIWebContentPage(dataWebContentPage, pos)
    }
};

/* get list info bookmark */
function getPageIndexJson(pos) {
    if (dataJsonType5.length > 0) {
        $('#divListIndex').children().remove();

        // $("#divListIndex").dialog({              
        // show: "blind",
        // modal: true,
        // width: WIDTH_DIALOG_INDEX,
        // height:HEIGHT_DIALOG_INDEX,
        // resizable:false,
        // closeOnEscape: false,
        // title: i18nText('txtIndex'),
        // position: pos});

        //title start
        $('#indexBoxHdIndex').children().remove();
        $('#indexBoxHdIndex').html('<a id="indexClosing" class="delete" > </a>');
        $("#indexClosing").click(closeIndexBox);
        $('#indexBoxHdIndex').append(i18nText('txtIndex'));
        //title end
        //lockLayout();
        $('#boxIndex').css('z-index', '101');
        $('#boxIndex').css('display', 'block');
        $('#boxIndex').draggable({ handle: "h1" });
        $("#boxIndex").offset({ left: pos[0], top: pos[1] });
        $("#divListIndex").show();
        $("#divListIndex").offset({ left: pos[0], top: (pos[1] + $('#indexBoxHdIndex').height()) });

        //set data for dialog index                                 
        var dataContent = dataJsonType5;
        var arrData = new Array();
        $.each(dataContent, function (i, value) {
            if (dataContent[i].level == 0) {
                //add parent node
                var node = new TreeNode();
                node.IsCategory = true;
                //node.Text = htmlEncode(truncateByBytes(dataContent[i].title, 30));
                /* check data text */
                if (getBytes(dataContent[i].title) > 30) {
                    node.Text = htmlEncode(truncateByBytes(dataContent[i].title, 30)) + '...';
                } else {
                    node.Text = htmlEncode(dataContent[i].title);
                }
                node.id = dataContent[i].ID;
                node.Value = dataContent[i].destPageNumber;
                AddChidrenNode(node, dataContent);

                arrData.push(node);
            }
        });

        var tree = new TreeViewIndex();
        tree.IsShowTotal = false;
        tree.Show("divListIndex", arrData, "listIndex_Callback");
        $("#divListIndex").treeview();
        $(".treeview, .treeview ul").css('padding', '0px 8px 0');
    } else {
        $('#divListIndex').children().remove();
        $('#divListIndex').append('<span class="no-item">' + i18nText('msgNoIndex') + '</span>');

        // //show dialog index
        // $("#divListIndex").dialog({              
        // show: "blind",
        // modal: true,
        // resizable:false,
        // width: WIDTH_DIALOG_INDEX,
        // height:HEIGHT_DIALOG_INDEX_NO_INDEX,
        // title: i18nText('txtIndex'),
        // position: pos});

        //title start
        $('#indexBoxHdIndex').children().remove();
        $('#indexBoxHdIndex').html('<a id="indexClosing" class="delete" > </a>');
        $("#indexClosing").click(closeIndexBox);
        $('#indexBoxHdIndex').append(i18nText('txtIndex'));
        //title end
        //lockLayout();
        $('#boxIndex').css('z-index', '101');
        $('#boxIndex').css('display', 'block');
        $('#boxIndex').draggable({ handle: "h1" });
        $("#boxIndex").offset({ left: pos[0], top: pos[1] });
        $("#divListIndex").show();
        $("#divListIndex").offset({ left: pos[0], top: (pos[1] + $('#indexBoxHdIndex').height()) });

    }
};

function getText() {
    /* init var page text */
    var data = dataWebContentPage.pages;
    var sPageText = '';
    var w = $("#wrapper").width() / 2 - $('#boxCopyText').width() / 2;
    var h = $("#wrapper").height() / 2 - $('#boxCopyText').height() / 2;

    for (var nIndex = 0; nIndex < data.length; nIndex++) {
        /* get text of current page */
        if (data[nIndex].pageNo == changePageIndex(getPageIndex())) {
            sPageText = htmlEncode(data[nIndex].pageText);
            break;
        }
    }
    if (sPageText == '') {
        return { text: i18nText('txtNoTextCopy'), title: i18nText('txtTextCopy') + ' | ' + i18nText('sysAppTitle') };
    }
    else {
        var strPattern = "\n";
        var strTemp = sPageText;
        strTemp = strTemp.replaceAll(strPattern, "<br/>");
        strTemp += "<br/>";
        return { text: strTemp, title: i18nText('txtTextCopy') + ' | ' + i18nText('sysAppTitle') };
    }
};


/* get contentID */
function getContentID() {
    /* init contentID */
    if (ClientData.common_preContentId()) {
        contentID = ClientData.common_preContentId();
        ClientData.common_preContentId(null);
    } else if (ClientData.IsJumpBack() == true) {
        var dataJump = ClientData.JumpQueue();
        contentID = dataJump[dataJump.length - 1].oldContentID;
    } else {
        contentID = ClientData.contentInfo_contentId();
    }
};

//Download resource
function getResourceByIdFromAPI(resourceId){
    return getURL("webResourceDownload") + "/?sid=" + ClientData.userInfo_sid() + "&resourceId=" + resourceId; 
};

//Get content info type Image
function getContentInfoTypeImage(){
    
    var resourceUrl = downloadResourceById(contentID);               
    
    resourceImage.onload = function(){       
        widthContentImage = resourceImage.width;
        heightContentImage = resourceImage.height;      
           
        getContent().setPageImages(1, resourceUrl).setUpPage(0);     
        handleSliderBar(); 
        
        getContentDataForImageType();
               
        $('#lblSlider').text('/ ' + 1);
        
        //Start: TRB00019 - Editor : Long - Date : 28/08/2013 - Summary : Fix for android resize
        /* window resize event */
        $(window).resize(function () {

            if (isTouchDevice() == true) {
                if (avwUserEnvObj.os == "android") {
                    var tempRatio = document.documentElement.clientWidth / window.innerWidth;
                    if (tempRatio <= 1) {
                        // Adjust position for toolbar and footer bar
                        var top = window.innerHeight - $("#footer_toolbar_1").height();
                        $("#wrapper").css("width", window.innerWidth);
                        $("#wrapper").css("height", window.innerHeight);
                        $("#footer_toolbar_1").css("top", top + "px");
                        $("#footer_toolbar_2").css("top", top + "px");
                    }
                    else {
                        var top = $(window).height() - $("#footer_toolbar_1").height();
                        $("#wrapper").css("width", $(window).width());
                        $("#wrapper").css("height", $(window).height());
                        $("#footer_toolbar_1").css("top", top + "px");
                        $("#footer_toolbar_2").css("top", top + "px");
                    }
                }
            }

            resizeScreen();
            isChangeSizeScreen = false;

            /* change position dialog */
            changePosDialog();

            /* close dialog popuptext */
            closeDialogResize();                

        });
        
        /*init Image Bookmark */
        initImageBookmark();
        
        /* init image had draw */
        initDisplayMarking();
        
        /* check status */
        checkStatusImageMarking();
        
        trackTransforms(context_main);
        
        if (isTouchDevice() == true) {
            if (avwUserEnvObj.os == "android") {
                standardRatio = document.documentElement.clientWidth / window.innerWidth;
                startDetectZoom({ time: 500,
                    callbackFunction: function (oldRatio, newRatio, oldW, oldH, newW, newH) {
                        currentRatio = newRatio;

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

    };
    //End: TRB00019 - Editor : Long - Date : 28/08/2013 - Summary : Fix for android resize
    resourceImage.src = resourceUrl;                
};

function getContentDataForImageType(){
    var params = {
        sid: ClientData.userInfo_sid(),
        contentId: contentID,
        getType: '1',
    };
    
    abapi('webGetContent', params, 'GET', function (data) {
        imageTypeData = data.contentData;
        //Set default page No to image Type
        imageTypeData["pageNo"] = 1;
        
        document.title = data.contentData.contentName + ' | ' + i18nText('sysAppTitle');                                                
    });   
};

/* grab viewer content object */
function getContent() {
    return content;
};
/* get all memo on page */
function getAllMemoOfPage() {
    if (ClientData.IsDisplayMemo() == true) {
        memoObjects = [];

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

        for (var nIndex = 0; nIndex < memoData.length; nIndex++) {
            if (memoData[nIndex].contentid == contentID
            && memoData[nIndex].pageNo == changePageIndex(getPageIndex())) {
                /* create object of memo */
                var memoObject = null;

                if (memoData[nIndex].posY > heightEachPage - 50) {
                    memoData[nIndex].posY = heightEachPage - 50;
                }

                if (memoData[nIndex].posX > widthEachPage - 50) {
                    memoData[nIndex].posX = widthEachPage - 50;
                }
                memoObject = new memo(
                    nIndex,
                    memoData[nIndex].Text,
                    memoData[nIndex].posX,
                    memoData[nIndex].posY,
                    50,
                    50,
                    "img/memo.png"
                );

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

function getPosVideo(px, py, width, height, scale) {
    pxVideo = px;
    pyVideo = py;
    wVideo = width;
    hVideo = height;
    videoScale = scale;
};

//Start Function: No.4 - Editor : Long - Summary : Render Next Page Content

//Render next Page Content
function renderNextPage(){
    
    //Get next page Number
    var pageNo = parseInt(changePageIndex(getPageIndex())) + 1;
        
    //Get next page background image
    if(contentType == ContentTypeKeys.Type_PDF){
        avwGrabContentPageImage(ClientData.userInfo_accountPath(),
             { contentId: contentID, sid: ClientData.userInfo_sid(), pageNo: pageNo },
             function (data) {    
                  nextPageImage = data;                                              
                  
                  nextContent.setPageImages(totalPage, nextPageImage)
                                 .setPageObjects(nextPageObjects)                          
                                 .nextPage();
                                  
             },
             function (xmlHttpRequest, txtStatus, errorThrown) {
                 showErrorScreen();
             });
    }
    //Start Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary : Render next page content image the same with the current one 
    else if(contentType == ContentTypeKeys.Type_NoFile){
        nextPageImage = pageImages;
        nextContent.setPageImages(totalPage, nextPageImage)
                                 .setPageObjects(nextPageObjects)                          
                                 .nextPage();
    }
    //End Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary : Render next page content image the same with the current one

};

//Render prev Page Content
function renderPrevPage(){
    
    //Get prev page Number
    var pageNo = parseInt(changePageIndex(getPageIndex())) - 1;
        
    //Get prev page background image
    if(contentType == ContentTypeKeys.Type_PDF){
    avwGrabContentPageImage(ClientData.userInfo_accountPath(),
         { contentId: contentID, sid: ClientData.userInfo_sid(), pageNo: pageNo },
         function (data) {    
              prevPageImage = data;            
                                       
              prevContent.setPageImages(totalPage, prevPageImage)
                             .setPageObjects(prevPageObjects)                          
                             .previousPage();
                              
         },
         function (xmlHttpRequest, txtStatus, errorThrown) {
             showErrorScreen();
         });
     }
    //Start Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary : Render next page content image the same with the current one 
    else if(contentType == ContentTypeKeys.Type_NoFile){
        prevPageImage = pageImages; 
        prevContent.setPageImages(totalPage, prevPageImage)
                             .setPageObjects(prevPageObjects)                          
                             .previousPage();
    }
    //End Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary : Render next page content image the same with the current one
};

//Get next page objects by page index
function getNextPageObjectsByPageIndex(contentData, nIndexPage) {
    nextPageObjects = [];

    var currentPageObjects;
    for (var nIndex = 0; nIndex < contentData.length; nIndex++) {
        if (contentData[nIndex].page == nIndexPage) {
            currentPageObjects = contentData[nIndex].objects;
            //Start Function: No.9 - Editor : Long - Summary : 
            if(contentData[nIndex].contentDataSub != null && contentData[nIndex].contentDataSub.length > 0){
                //currentPageObjects["contentDataSub"] = contentData[nIndex].contentDataSub;
                for(var i = 0; i < currentPageObjects.length; i++){
                    var tempObj = currentPageObjects[i];
                    tempObj["contentDataSub"] = contentData[nIndex].contentDataSub;
                }               
            }            
            //End Function: No.9 - Editor : Long 
            break;
        }
    }
    
    
    if (currentPageObjects != undefined) {
        for (var nIndex = 0; nIndex < currentPageObjects.length; nIndex++) {
            /*get object page*/
            if (currentPageObjects[nIndex].mediaType == 1) {/*media type = 1 */
                var pageObject = getMediaType1(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 2) { /*mediaType = 2 */
                var pageObject = getMediaType2(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 3) { /*mediaType = 3*/
                var pageObject = getMediaType3(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 4) { /*mediaType = 4*/
                var pageObject = getMediaType4(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 5) { /*mediaType = 5*/
                var pageObject = getMediaType5(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 6) { /*mediaType = 6*/
                var pageObject = getMediaType6(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 7) { /*mediaType = 7*/
                var pageObject = getMediaType7(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 8) { /*mediaType = 8*/
                var pageObject = getMediaType8(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 9) { /*mediaType = 9*/
                var pageObject = getMediaType9(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 11) { /*mediaType = 11*/
                var pageObject = getMediaType11(currentPageObjects[nIndex]);
                /*add object to page */
                nextPageObjects.push(pageObject);
            }
            
        }
    }
};

//Get prev page objects by page index
function getPrevPageObjectsByPageIndex(contentData, nIndexPage) {
    prevPageObjects = [];

    var currentPageObjects;
    for (var nIndex = 0; nIndex < contentData.length; nIndex++) {
        if (contentData[nIndex].page == nIndexPage) {
            currentPageObjects = contentData[nIndex].objects;
            //Start Function: No.9 - Editor : Long - Summary : 
            if(contentData[nIndex].contentDataSub != null && contentData[nIndex].contentDataSub.length > 0){
                //currentPageObjects["contentDataSub"] = contentData[nIndex].contentDataSub;
                for(var i = 0; i < currentPageObjects.length; i++){
                    var tempObj = currentPageObjects[i];
                    tempObj["contentDataSub"] = contentData[nIndex].contentDataSub;
                }               
            }            
            //End Function: No.9 - Editor : Long 
            break;
        }
    }

    if (currentPageObjects != undefined) {
        for (var nIndex = 0; nIndex < currentPageObjects.length; nIndex++) {
            /*get object page*/
            if (currentPageObjects[nIndex].mediaType == 1) {/*media type = 1 */
                var pageObject = getMediaType1(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 2) { /*mediaType = 2 */
                var pageObject = getMediaType2(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 3) { /*mediaType = 3*/
                var pageObject = getMediaType3(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 4) { /*mediaType = 4*/
                var pageObject = getMediaType4(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 5) { /*mediaType = 5*/
                var pageObject = getMediaType5(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 6) { /*mediaType = 6*/
                var pageObject = getMediaType6(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 7) { /*mediaType = 7*/
                var pageObject = getMediaType7(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 8) { /*mediaType = 8*/
                var pageObject = getMediaType8(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 9) { /*mediaType = 9*/
                var pageObject = getMediaType9(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            } else if (currentPageObjects[nIndex].mediaType == 11) { /*mediaType = 11*/
                var pageObject = getMediaType11(currentPageObjects[nIndex]);
                /*add object to page */
                prevPageObjects.push(pageObject);
            }
        }
    }
};

//Switch canvas when flipping page
function switchCanvas(nav){
    // change div id
    
    if(nav == 1){
        $('#mainPre').attr("id","mainPreBK");
        $('#main').attr("id","mainPre");
        $('#mainNext').attr("id","main");
        $('#mainPreBK').attr("id","mainNext");
        
        $('#offscreenPre').attr("id","mainPreBK");
        $('#offscreen').attr("id","offscreenPre");
        $('#offscreenNext').attr("id","offscreen");
        $('#mainPreBK').attr("id","offscreenNext");
        
        //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
        widthEachPrevPage = widthEachPage;
        widthEachPage = widthEachNextPage;
        
        heightEachPrevPage = heightEachPage;
        heightEachPage = heightEachNextPage;
        
        srcRectPrev = srcRect;
        srcRect = srcRectNext; 
               
        destRectPrev = destRect;
        destRect = destRectNext;
        
        userScale = 1;
        changeScale(userScale);
        flip();
        //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
    }
    else{
        // change div id
        $('#mainNext').attr("id","mainNextBK");
        $('#main').attr("id","mainNext");
        $('#mainPre').attr("id","main");
        $('#mainNextBK').attr("id","mainPre");
        
        $('#offscreenNext').attr("id","mainNextBK");
        $('#offscreen').attr("id","offscreenNext");
        $('#offscreenPre').attr("id","offscreen");
        $('#mainNextBK').attr("id","offscreenPre");
        
        //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
        widthEachNextPage = widthEachPage;
        widthEachPage = widthEachPrevPage;
        
        heightEachNextPage = heightEachPage;
        heightEachPage = heightEachPrevPage;
        
        srcRectNext = srcRect;
        srcRect = srcRectPrev; 
               
        destRectNext = destRect;
        destRect = destRectPrev;
        
        userScale = 1;
        changeScale(userScale);
        
        flip();
        //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
    }
   
};

//Assign content properties
function assignCurrentContentPage(nav){
    
    if(nav == 1){      
                     
        prevPageImage = pageImages;
        pageImages = nextPageImage;
                                     
        prevContent.currentPage = content.currentPage;
        prevContent.pageCount = content.pageCount;
        prevContent.pageImages = content.pageImages;
        prevContent.pageIndex = content.pageIndex;
        prevContent.pageObjects = content.pageObjects;      
        
        content.currentPage = nextContent.currentPage;
        content.pageCount = nextContent.pageCount;
        content.pageImages = nextContent.pageImages;
        content.pageIndex = nextContent.pageIndex;
        content.pageObjects = nextContent.pageObjects;
        
        prevPageObjects = pageObjects;
        pageObjects = nextPageObjects;
        
    }
    else{
        nextPageImage = pageImages;
        pageImages = prevPageImage;
        
        nextContent.currentPage = content.currentPage;
        nextContent.pageCount = content.pageCount;
        nextContent.pageImages = content.pageImages;
        nextContent.pageIndex = content.pageIndex;
        nextContent.pageObjects = content.pageObjects;      
        
        content.currentPage = prevContent.currentPage;
        content.pageCount = prevContent.pageCount;
        content.pageImages = prevContent.pageImages;
        content.pageIndex = prevContent.pageIndex;
        content.pageObjects = prevContent.pageObjects;  
        
        nextPageObjects = pageObjects;
        pageObjects = prevPageObjects;
        
    }
      
    //abe
    //alert("assignCurrentContentPage:" + content.currentPage);
      
};

//Correct Canvas Position
function correctCanvasPosition(){
    //correct canvas position
    
    //   Set default value for moving3D object to prevent other object fired when
    //hold on 3d object and move next or prev page. 
    _3dAnimate = false;
    
    if(animateType == animateTypeKeys.Type_Slide){
        $('#canvasWrapper').css("left",'0px');
        $('#main').css("left",'13px');
        $('#mainNext').css("left", $("#canvasWrapper").width() +'px');
        $('#mainPre').css("left", '-' + $("#canvasWrapper").width() +'px');
        $('#mainNext').css("display", 'none');
        $('#mainPre').css("display", 'none');
    }
    else if(animateType == animateTypeKeys.Type_FadeIn){
       $('#mainNext').css("z-index",'0');
       $('#mainPre').css("z-index",'0'); 
       $('#mainNext').css("display", 'none');
       $('#mainPre').css("display", 'none');               
    }
    
};

//Get Page Transition configuration
function getPageTransitionConfig(){
    animateType = ClientData.userOpt_pageTransition();
    animatePeriod = eval(ClientData.userOpt_pageTransitionPeriod()) * 1000;
};
//End Function: No.4 - Editor : Long - Summary : Render Next Page Content