UI.moduleBuilder['Alexa']['register_editName'] = function() {
    var initData = {
        sheetImg1:UI['bg_overlay'],
        registerEditbgImg1:UI.window_bg,
        registerEdittitle:"[SE0010]",//Custom
        registerEditinputimg: "Alexa/register/"+GLOBAL.LAUNCHER_BRAND +"/Manual_input_focused.png",
        registerEditPlaceholder:"[SE3014]",
        registerbtn1bgImg:UI.item_bg,
        registerbtn2bgImg:UI.item_bg,
        registerbtn1Text:"[GE0008]",
        registerbtn2Text:"[GE0007]"//OK
    };
    var template = Util.readJson("module/Alexa/register_editName.json");
    var register_editName = SubModule.create(initData, template);
    var registerBtn1 = UI.getItem(register_editName, "registerBtn1");
    var registerBtn2 = UI.getItem(register_editName, "registerBtn2");
    var registerEditinput = UI.getItem(register_editName, "registerEditinput");
    var registerEditinputimg = UI.getItem(register_editName, "registerEditinputimg");
    var registerEditPlaceholder = UI.getItem(register_editName, "registerEditPlaceholder");
    var registerEdittitle = UI.getItem(register_editName, "registerEdittitle");
    register_editName.protected = true;

    register_editName.inputName = "";
    register_editName.validLength = 22;

    register_editName.currFocus = UI.getItem(register_editName, "registerEditinput");

    var textInfo = {
        initVal: "",
        maxLength: 18,
        maxWidth:744,
        fontSize: 36,
        isPwd: false,
        color: 0xFFFFFF
    };

    TextBox.create(registerEditinput, textInfo, onEditTextChanged);

    function onEditTextChanged(txt) {
        DBG_ERROR("!!!!!!!!!!!!!!!!!!!" + txt);
        register_editName.inputName = txt.text;
        registerEditinput.setText(register_editName.inputName);
        registerEditPlaceholder.alpha = 0;
        UI.updateStage();
    }

    register_editName.onPush = function () {
        registerEditPlaceholder.alpha = 1;
        registerEditinput.setText("");
        registerEditinput.cursorLeft();
        register_editName.inputName = "";
        UI.callTTS("[SE3014]");
        register_editName.currFocus = UI.getItem(register_editName, "registerEditinput");

    }


    register_editName.onFocus = function (focus) {
        if (focus.name == "registerEditinput") {
            UI.base.cursor.alpha = 0;
            UI.setImage(registerEditinputimg,  "Alexa/register/"+GLOBAL.LAUNCHER_BRAND +"/Manual_input_focused.png");
            registerEditinput.active();
            return false;
        }
        else {
            return true;
        }
    }
    register_editName.onNormal = function (focus) {
        if (focus.name == "registerEditinput") {
            UI.base.cursor.alpha = 0;
            UI.setImage(registerEditinputimg, "Alexa/register/Manual_input_normal.png");
            registerEditinput.inactive();
            return false;
        }
        else {
            return true;
        }
    }

    register_editName.onkey_BACKSPACE =function(){
        UI.popSubModule();
        return false;
    }

    registerBtn1.onkey_ENTER = function () {
        UI.popSubModule();
    }

    registerBtn2.onkey_ENTER = function () {
        if(!checkInputIsValid()){
            GLOBAL.CURRENT_TOAST_TYPE=1;
            UI.pushGhostModule("setting","SettingSysToast");
            registerEditinput.setText("");
            registerEditinput.cursorLeft();
            register_editName.inputName="";
        }else{
            setTvName(register_editName.inputName);
            UI.popSubModule();
            if(!tv){
                UIObserver.publishMessage(UIObserver.MESSAGE_NAME.AVS_ONHISENSEDEVICEREPORTRESULT, 0);
            }
        }



    }

    function checkInputIsValid()
    {
        var str = register_editName.inputName;
        if(str.length==0)
        {
            return false
        }
        else if(str.length> register_editName.validLength)
        {
            return false;
        }
        return true;
    }

    registerEditinput.onkey_ENTER = function () {
        DBG_ERROR("!!!!!!!!!!!!!!!!!!!");
        registerEditinput.showKeyBoard();
        registerEditPlaceholder.alpha = 0;

    }

    var proIpNumKey = function() {
        registerEditinput.children[0].realValue += CONST.NUMIPT_VALUE[UI.currKeyValue];
        registerEditinput.setText(registerEditinput.children[0].realValue);
        registerEditinput.cursorRight();
        if (registerEditinput.children[0].realValue.length != 0) {
            registerEditPlaceholder.alpha = 0;
        }
        else {
            registerEditPlaceholder.alpha = 1;
        }
        register_editName.inputName = registerEditinput.children[0].text;
        DBG_ERROR("value changed!");
        UI.updateStage();
    };
    registerEditinput.onkey_ZERO = proIpNumKey;
    registerEditinput.onkey_ONE = proIpNumKey;
    registerEditinput.onkey_TWO = proIpNumKey;
    registerEditinput.onkey_THREE = proIpNumKey;
    registerEditinput.onkey_FOUR = proIpNumKey;
    registerEditinput.onkey_FIVE = proIpNumKey;
    registerEditinput.onkey_SIX = proIpNumKey;
    registerEditinput.onkey_SEVEN = proIpNumKey;
    registerEditinput.onkey_EIGHT = proIpNumKey;
    registerEditinput.onkey_NINE = proIpNumKey;


}






