//  personal.js
//  Last Update:2012.06.20
//
//		2018.12.xx N.Watanabe alertおよびconfimの代替対応
//                                      alertをmyAlertに置き換え 

// Input Text
function fncInitializeInputText(){
    try{
        var wBase = fncInitializeInputBase();
        if( wBase.getAttribute('id') == 'pnlInputText' ){
            var wPrgs =wBase.getElementsByTagName('p');
            for(var ix1 = 1; ix1 < wPrgs.length; ix1 ++ ){
                var wButtons = wPrgs[ix1].getElementsByTagName('button');
                for(var ix2 = 0; ix2 < wButtons.length; ix2 ++ ){
                    if( wButtons[ix2].className.indexOf('cssUnvisible') < 0 ){
                        wButtons[ix2].onmousedown = function(){fncInputText(this.firstChild.nodeValue);};
                        wButtons[ix2].onmouseup = fncStopInput;
                    }
                }
            }
        }
    }catch(ex){
    }
}
function fncInputText( strValue ){
    try{
        fncStopInput();

        var wObj = document.getElementById('txtInputText');
        if( strValue == '空白' )
            strValue = '　';
        if( strValue.length > 1 ){
            var wOld = wObj.value;
            wObj.value = '';
            for( var ix = 0; ix < wOld.length - 1; ix ++ )
                wObj.value += wOld.charAt(ix);
            if( wObj.value.length > 0 )
                mTimerInput = window.setTimeout("fncInputText('"+strValue+"')", TIME_OUT_COUNT);

        }else{
            if( (strValue == '゛') || (strValue == '゜') ){
                var wFlagError = (wObj.value.length < 1);
                if( !wFlagError ){
                    var wChar = wObj.value.charAt(wObj.value.length -1);
                    if( strValue == '゛' )
                        wFlagError = (('ウカキクケコサシスセソタチツテトハヒフヘホ').indexOf(wChar) < 0);
                    else
                        wFlagError = (('ハヒフヘホ').indexOf(wChar) < 0);
                }
                if( wFlagError ){
                    myAlert('この位置には入力できません。');
                    return;
                }
            }
            if( wObj.value.length < wObj.maxLength ){
                wObj.value += strValue;
                if( (wObj.value.length < wObj.maxLength) && (strValue != '゛') && (strValue != '゜') )
                    mTimerInput = window.setTimeout("fncInputText('"+strValue+"')", TIME_OUT_COUNT);
            }
        }
    }catch(ex){
    }
}

// Text Box
function fncInitializeTextBox(){
    try{
        var wObj = document.getElementById('txtTownCode');
        if( wObj ){
            wObj.onchange = function(){
                document.getElementById('txtTownName').value = '';
            };
            fncChangeTownEnabled();
            document.getElementById('chkAllEntry').onclick = fncChangeTownEnabled;
        }
    }catch(ex){
    }
}
function fncChangeTownEnabled(){
    try{
        var wDisabled = document.getElementById('chkAllEntry').checked;
        var wTextC = document.getElementById('txtTownCode');
        var wTextN = document.getElementById('txtTownName');
        var wButton = document.getElementById('btnSelectTown');
        wTextC.readOnly = wDisabled;
        wButton.disabled = wDisabled;
        wTextC.className = fncGetDisabledClass(wTextC.className, wDisabled);
        wTextN.className = fncGetDisabledClass(wTextN.className, wDisabled);
        wButton.className = fncGetDisabledClass(wButton.className, wDisabled);
    }catch(ex){
    }
}

// Prev Search
function fncSearch(){
    fncShowWait();
    return true;
}

// Load Event
function window.onload(){
    fncInitializeList();
    fncInitializeMove();
    fncInitializeInputText();
    fncInitializeInputDate();
    fncInitializeInputNumber();
    fncInitializeTextBox();
    fncListScrollSet();
    fncShowMessage();
}

// All Timer Stop
function document.onmouseup(){
    fncStopInput();
    fncMoveStop();
}

// All Show Check
var mFlagDocumentFocus = false;
function document.onfocusin(){
    mFlagDocumentFocus = true;
}
function document.onfocusout(){
    mFlagDocumentFocus = false;
}
function document.onkeydown(){
    if( window.event.keyCode == 17 && mFlagDocumentFocus ){
        if( document.getElementById('prgAllShow') ){
            if( !document.getElementById('pnlInputText') && !document.getElementById('pnlInputDate') ){
                document.getElementById('prgAllShow').style.display = 'block';
                document.getElementById('chkAllShow').onfocus = function(){this.blur();};
            }
        }
    }
}
function document.onkeyup(){
    if( document.getElementById('prgAllShow') ){
        if( document.getElementById('prgAllShow').style.display != 'none' )
            document.getElementById('prgAllShow').style.display = 'none';
    }
}
