UI.moduleBuilder['Alexa']['bodyTemplate1'] = function(){
    var bodyTemplate1Data = {
        bodyTemplate1Bg:"Alexa/card_bg.png",
        skillIcon:"",
        logoIcon:"Alexa/avs_logo_template.png"
    };
    var template = Util.readJson("module/Alexa/bodyTemplate1.json");
    var bodyTemplate1 =  SubModule.create(bodyTemplate1Data, template);


    var mainTitle = UI.getItem(bodyTemplate1, "mainTitle");
    var subTitle = UI.getItem(bodyTemplate1, "subTitle");
    var skillIcon = UI.getItem(bodyTemplate1, "skillIcon");
    var textField = UI.getItem(bodyTemplate1, "textField");
    var backgroundImg = UI.getItem(bodyTemplate1, "backgroundImg");
//    var aa = "11";
//    var aa  = "BThe The iThe image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.mage max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.odyTemplate2, like BodyTemplate1, is used for Q&A, Wikipedia queries, and third-party Skill requests, but unlike BodyTemplate1, it also returns a photo. Sample utterances that would invoke BodyTemplate2 include:BodyTemplate2, like BodyTemplate1, is used for Q&A, Wikipedia queries, and third-party Skill requests, but unlike BodyTemplate1, it also returns a photo. Sample utterances that would invoke BodyTemplate2 include:BodyTemplate2, like BodyTemplate1, is used for Q&A, Wikipedia queries, and third-party Skill requests, but unlike BodyTemplate1, it also returns a photo. Sample utterances that would invoke BodyTemplate2 include:BodyTemplate2, like BodyTemplate1, is used for Q&A, Wikipedia queries, and third-party Skill requests, but unlike BodyTemplate1, it also returns a photo. Sample utterances that would invoke BodyTemplate2 include:BodyTemplate2, like BodyTemplate1, is used for Q&A, Wikipedia queries, and third-party Skill requests, but unlike BodyTemplate1, it also returns a photo. Sample utterances that would invoke BodyTemplate2 include:BodyTemplate1, along with BodyTemplate2, is used for Q&A, Wikipedia queries, and third-party Skill requests. Sample utteranNote: Text can extend to 60px above the logo. Any text past that point should be hidden but accessible by scrolling on a 5-way remoteces that would invoke BodyTemplate1 include:";
    var aa = "The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.";
//    var aa = "The image max height and width are 317x477. Images of different aspect ratios should resize to stay within these dimensions.";



    bodyTemplate1.currFocus = textField;
    bodyTemplate1.currHeight = 0;
    bodyTemplate1.step = 100;
    bodyTemplate1.maskHeight = 720;
    bodyTemplate1.scrollStep = 0;
    bodyTemplate1.enableKey = [CONST.KEY.VK_UP,CONST.KEY.VK_DOWN];
    var bodyTemplate1Content = null;

    bodyTemplate1.onPush = function(){
        var graphics = new PIXI.Graphics()
            .beginFill(0x000000, 0.85)
            .drawRect(0, 0, 1920, 1080)
            .endFill();
        UI.setImage(backgroundImg,graphics);
    }
    bodyTemplate1.onShow = function(){
        if(!tv){
            UI.setText(textField,aa);
            UI.addMask(textField, 544, 700, 50, 3);
            UI.setView(textField, 544, 700);
            UI.addScrollbar(textField,-16);
            return;
        }

        UI.setText(mainTitle,bodyTemplate1.param.mainTitle);
        UI.setText(subTitle,bodyTemplate1.param.subTitle);
        // UI.setText(textField,bodyTemplate1.param.textField);
        UI.setText(textField," ");
        var disLayer = $("#divLayer");
        disLayer.html("");
        disLayer.html(getFile("module/Alexa/bodyTemplate1Div.html"));
        var str = bodyTemplate1.param.textField;
        $("#bodyTemplate1").html(str.replace(/\n/g,"<br>"));
        $("#divLayer").css("visibility", "visible");
        bodyTemplate1Content = document.getElementById("bodyTemplate1");
        if(bodyTemplate1Content.scrollHeight>bodyTemplate1Content.clientHeight||bodyTemplate1Content.offsetHeight>bodyTemplate1Content.clientHeight){
            bodyTemplate1Content.hasScrollBar = true;
        } else {
            bodyTemplate1Content.hasScrollBar = false;
        }
        UI.setImage(skillIcon,bodyTemplate1.param.skillIcon);
        UI.addMask(textField, 544, 720, 50, 3);
        UI.setView(textField, 544, 720);
        UI.addScrollbar(textField,-16);
    }

    bodyTemplate1.afterPush = function(){
        bodyTemplate1.currFocus = textField;
    }

    bodyTemplate1.onPop = function(){
        var disLayer = $("#divLayer");
        disLayer.html("");
        $("#divLayer").css("visibility", "hidden");
    }
    textField.onFocus = function(focus){

    }

    bodyTemplate1.onkey = function(focus,evt){
        DBG_INFO("bodyTemplate1 evt.keyCode=" + evt.keyCode);
//        if (evt.keyFrom == "Keyboard") {
            if (evt.value == "DOWN") {
                // if(textField.height - bodyTemplate1.currHeight > bodyTemplate1.maskHeight){
                //     bodyTemplate1.currHeight += bodyTemplate1.step;
                //     textField.y -=  bodyTemplate1.step;
                //     bodyTemplate1.scrollStep = parseInt(800/textField.height *bodyTemplate1.step);//bounds 800
                //     textField.scroll.y += bodyTemplate1.scrollStep;
                //     UI.updateStage();
                // }
                // return true;
                if (bodyTemplate1Content.hasScrollBar) {
                    bodyTemplate1Content.scrollTop += 150;
                    return;
                }

                //TODO:do sth.
            } else if (evt.value == "UP") {
                //TODO:do sth.
                // if(bodyTemplate1.currHeight > 0){
                //     if(bodyTemplate1.currHeight > bodyTemplate1.step){
                //         bodyTemplate1.currHeight -= bodyTemplate1.step;
                //     }else{
                //         bodyTemplate1.currHeight = 0;
                //     }
                //     textField.y += bodyTemplate1.step;
                //     bodyTemplate1.scrollStep = parseInt(800/textField.height *bodyTemplate1.step);
                //     textField.scroll.y -= bodyTemplate1.scrollStep;
                //     UI.updateStage();
                // }
                // return true;
                if (bodyTemplate1Content.hasScrollBar) {
                    bodyTemplate1Content.scrollTop -= 150;
                    return;
                }
            } else if (evt.value == "VOICE" || evt.value == "VOICE_DOWN" || evt.value == "VOICE_UP") {
              return true;
            } else {
                UI.popSubModule();
                return (Alexa_globalKeys.indexOf(evt.keyCode) >= 0);
            }
//        }

    }
}
