UI.moduleBuilder['FTE']['fte_netPasswordError'] = function() {
    var netPasswordErrorData = {
        passwordErrorText:"",
        inputBgImg: "FTE/fte_txt_fld_mdm_std.png",
        inputBox: "",
        noTextHint: "[SE3014]",//Press OK button  open keyboard
        checkBox: "FTE/"+GLOBAL.LAUNCHER_BRAND +"/fte_chckbx_active.png",
        connectText: "[SE0187]",    //"Connect",
        text1: "[OT0019]",//Show password
        connectImg: UI.item_bg,
        OKBtnImg:UI.item_bg,
        inputBgImgBlank:UI.item_bg,
        wifiNoConnect1Text:"[SE3879]",//Change IP settings
        wifiNoConnect2Text:"[SE3878]",//Use another network
        wifiNoConnect3Text: "[PI0019]"  //Try again
    };
    var template = Util.readJson("module/FTE/fte_netPasswordError.json");
    var netPasswordError = SubModule.create(netPasswordErrorData, template);



    netPasswordError.pageData = {
//        "currPasswd": "",
        "SSID":"",
        "secType":0,
        "authType":0,
        "password":""

    };

    var netWifiResult = UI.getSubModule("fte_netWifiResult");
//    var connectBtn = UI.getItem(netPasswordError, "connectBtn");
    var inputField = UI.getItem(netPasswordError, "inputField");
    var inputBox = UI.getItem(netPasswordError, "inputBox");
    var noTextHint = UI.getItem(netPasswordError, "noTextHint");
    var wifiNoConnect1 = UI.getItem(netPasswordError, "wifiNoConnect1");
    var wifiNoConnect2 = UI.getItem(netPasswordError, "wifiNoConnect2");
    var wifiNoConnect3 = UI.getItem(netPasswordError, "wifiNoConnect3");
    var passwordErrorText = UI.getItem(netPasswordError, "passwordErrorText");



    var textInfo = {
        initVal : "",
        maxLength : 63,
        maxWidth: 700,
        fontSize : 36,
        isPwd : true,
        showPwd: false,  //true 代表显示星号
        color : "#AAAAAA"
    };
    TextBox.create(inputBox, textInfo, onTextChanged);

    function onTextChanged() {
        if (inputBox.children[0].realValue.length != 0) {
            noTextHint.alpha = 0;
//            connectBtnDisableOrNot(1);
        }
        else {
            noTextHint.alpha = 0.5;
//            connectBtnDisableOrNot(0);
        }
        DBG_INFO("value changed!");
        netPasswordError.pageData.password = inputBox.children[0].realValue;
        inputBox.setText(netPasswordError.pageData.password);
//        initWifiInputConnectBtn();
    }

    function netWifiInputDisplay(alphaValue) {
        inputField.alpha = alphaValue;
//        connectBtn.alpha = alphaValue;
        disPlayPasswdItem.alpha = alphaValue;
    }

    inputField.onFocus = function (focus) {
        UI.base.cursor.alpha = 0;
        UI.getTween(UI.base.cursor).set({alpha: 0});
        inputBox.active();
        return false;
    };
    inputField.onNormal = function(focus){
        inputBox.inactive();
//        focus.cache(0, 0, focus.getBounds().width, focus.getBounds().height);
        return true;
    };
    var inputTxt = inputBox.children[0];
    var inputCursor = inputBox.children[1];
    inputField.onkey_RIGHT = function () {
        if (inputBox.inputCursor.index == inputTxt.text.length) {
//            UI.focusTo(connectBtn);
        }
        else {
            inputBox.cursorRight();
        }
    };
    inputField.onkey_LEFT = function() {
        inputBox.cursorLeft();
    };
    inputField.onkey_ENTER = function() {
        inputBox.showKeyBoard();
    };

    var proIpNumKey = function() {
        /*inputBox.children[0].realValue += CONST.NUMIPT_VALUE[UI.currKeyValue];
         inputBox.setText(inputBox.children[0].realValue);*/
        var value = CONST.NUMIPT_VALUE[UI.currKeyValue];
        inputBox.children[0].realValue = inputBox.makeText(value);
        inputBox.setText(inputBox.children[0].realValue);

        inputBox.cursorRight();
        if (inputBox.children[0].realValue.length != 0) {
            noTextHint.alpha = 0;
//            connectBtnDisableOrNot(1);
        }
        else {
            noTextHint.alpha = 0.5;
//            connectBtnDisableOrNot(0);
        }
        DBG_INFO("value changed!");
        netPasswordError.pageData.password = inputBox.children[0].realValue;
//        initWifiInputConnectBtn();

//        UI.updateStage();
    };
    inputField.onkey_ZERO = proIpNumKey;
    inputField.onkey_ONE = proIpNumKey;
    inputField.onkey_TWO = proIpNumKey;
    inputField.onkey_THREE = proIpNumKey;
    inputField.onkey_FOUR = proIpNumKey;
    inputField.onkey_FIVE = proIpNumKey;
    inputField.onkey_SIX = proIpNumKey;
    inputField.onkey_SEVEN = proIpNumKey;
    inputField.onkey_EIGHT = proIpNumKey;
    inputField.onkey_NINE = proIpNumKey;

    var checkBox = UI.getItem(netPasswordError, "checkBox");
    if (inputBox.children[0].showPwd == true) {
        UI.setImage(checkBox, "FTE/fte_chckbx_inactive.png");
    }
    else {
        UI.setImage(checkBox, "FTE/"+GLOBAL.LAUNCHER_BRAND +"/fte_chckbx_active.png");
    }
    netPasswordError.currFocus = UI.getItem(netPasswordError, "wifiNoConnect3");


    function fteConnectWifi() {
        var password = inputBox.children[0].realValue; //得到密码
        DBG_INFO("[zhangnaiyun] input password -------------> " + password);
        netWifiResult.fteSetNetSetWifiConnPara(getfteNetSetWifiPageConnPare());
        netWifiResult.connectData.operateData.password = password;
        DBG_INFO("wifiConnPara.password set new: " + password);

//        UI.popSubModule();
        //开始尝试连接wifi
        netWifiResult.fteNetSetWifiStartConnNetwork();
    }

    function getfteNetSetWifiPageConnPare(){
        try{
            var data = netWifiResult.pageData;

            netPasswordError.pageData.SSID = data.operateData.currSSIDName;
            netPasswordError.pageData.secType = data.operateData.currSecType;
            netPasswordError.pageData.authType = data.operateData.currAuthType;
            netPasswordError.pageData.password = data.operateData.connWifiPara.connPassword;
            DBG_ERROR(" wifiConnPare.SSID is " + netPasswordError.pageData.SSID + " secType is " + netPasswordError.pageData.secType + " authType is " + netPasswordError.pageData.authType +" password is " + netPasswordError.pageData.password );
//            initWifiInputConnectBtn();
            return netPasswordError.pageData;

        }catch (ex){
            DBG_INFO("getSettingNetSetWifiPageConnPare:"+ex.message);
        }
    }

//    function initWifiInputConnectBtn(){
//        DBG_ERROR("netWifiInput.pageData.secType" + netPasswordError.pageData.secType);
//        if($.inArray(parseInt(netPasswordError.pageData.secType),[5,11,16]) != -1){
//            if(netPasswordError.pageData.password.length > 7){
//                setConnectBtnDisableOrNot(false);
//            }else{
//                setConnectBtnDisableOrNot(true);
//            }
//        }else{
//            if(netPasswordError.pageData.password.length > 0){
//                setConnectBtnDisableOrNot(false);
//            }else{
//                setConnectBtnDisableOrNot(true);
//            }
//        }
//        if(netPasswordError.pageData.password.length>0){
//            noTextHint.alpha = 0;
//        }
//
//    }

//    function setConnectBtnDisableOrNot(disable){
//        connectBtn.disable = disable;
//        if(disable){
//            connectBtn.alpha = 0.3;
//        }else{
//            connectBtn.alpha = 1;
//        }
//        UI.updateStage();
//    }


    var network = UI.getSubModule("fte_network");
    var disPlayPasswdItem = UI.getItem(netPasswordError, "disPlayPasswdItem");

    netPasswordError.onPush = function() {
        netPasswordError.currFocus = wifiNoConnect3;
        var data = netWifiResult.pageData;
        netPasswordError.pageData.SSID = data.operateData.currSSIDName;
        netPasswordError.pageData.secType = data.operateData.currSecType;
        netPasswordError.pageData.authType = data.operateData.currAuthType;

        UI.setText(passwordErrorText,"[SE3880]"+ netPasswordError.pageData.SSID);//Incorrect password for
        netWifiInputDisplay(1);
        inputBox.children[0].realValue = netWifiResult.connectData.operateData.password;
        inputBox.setText(inputBox.children[0].realValue);
        inputBox.setCursor(inputBox.children[0].realValue.length);

////        netWifiInput.pageData.password = data.operateData.connWifiPara.connPassword;
//        if (netWifiResult.pageData.operateData.clearPassword) {
//            netPasswordError.inputBoxClean();
//        }
//        else {
//            try {
//                netWifiInputDisplay(1);
//                netPasswordError.alpha = 1;
//                var connPassword = model.network.getEncryptionPassphrase();
//                inputBox.children[0].realValue = connPassword;
//                inputBox.setText(inputBox.children[0].realValue);
//                inputBox.setCursor(inputBox.children[0].realValue.length);
//            }
//            catch (ex) {
//                DBG_ERROR("netWifiInput.onPush: get current password error");
//            }
//        }
        netPasswordError.pageData.password = inputBox.children[0].realValue;
//        initWifiInputConnectBtn();
        if (inputBox.children[0].realValue.length != 0) {
            noTextHint.alpha = 0;
//            connectBtnDisableOrNot(1);
        }
        else {
            noTextHint.alpha = 0.5;
//            connectBtnDisableOrNot(0);
        }
    };

    netPasswordError.onkey_BACKSPACE = function() {
        UI.popSubModule();
//        elementShow(netWifiResult);
        elementShow(UI.getCurrSubModule());
    };

    netPasswordError.inputBoxClean = function() {
        DBG_INFO("netWifiInput clean inputBox");
        netWifiInputDisplay(1);
        netPasswordError.alpha = 1;
        inputBox.children[0].realValue = "";
        inputBox.setText(inputBox.children[0].realValue);
        inputBox.inputCursor.index = 0;
        inputBox.cursorLeft();
        UI.updateStage();
    };

    disPlayPasswdItem.onkey_ENTER = function() {
        if (inputBox.children[0].showPwd == true) {
            UI.setImage(checkBox, "FTE/"+GLOBAL.LAUNCHER_BRAND +"/fte_chckbx_active.png");
//            inputBox.children[0].text = inputBox.children[0].realValue;
            inputBox.children[0].showPwd = false;
            inputBox.setText(inputBox.children[0].realValue);
        }
        else {
            UI.setImage(checkBox, "FTE/fte_chckbx_inactive.png");
            inputBox.children[0].showPwd = true;
            inputBox.setText(inputBox.children[0].realValue);
        }
        UI.updateStage();
    };



    wifiNoConnect1.onkey_ENTER = function(){
        elementHide(netPasswordError);
        network.netType = NetWorkType.WIRELESS;
        network.ipWifiPageMode = 1;
        UI.pushSubModule("FTE", "fte_netIpSet", true);
    };

    wifiNoConnect2.onkey_ENTER = function(){
        popSubModuleUntil("fte_network");
        network.searchEthernet();
    };

    wifiNoConnect3.onkey_ENTER = function () {
        if (inputBox.children[0].realValue.length > 0) {
            fteConnectWifi();
        }
    };


};
