//회사명자동검색입력-시작
//회사명입력
var currSelect = -1;
var maxSelect = -1;
var objSpan;
//키보드제어 - thisVal:텍스트박스내용, thisNo:현재 선택한 회사입력칸번호(1-4)
//document.InputForm.current_company_no, document.all.spCompany, document.InputForm.maxRowsCount, "company_seq_no", "company_name", "/main/lib/check_company_submit.asp?company_name=", "trAutoSelect"
//objCurrNo, objSpListLayer, objMaxRow, targetNo, targetName, strURL, trName
function checkListLayer(objCurrNo, objSpListLayer, objMaxRow, targetNo, targetName, strURL, trName, thisVal, thisNo) {
    if (objCurrNo.value != thisNo) {
        hideListLayer(objSpListLayer);
        objCurrNo.value = thisNo;
    }
    
    if (!objMaxRow || objSpListLayer.style.display == "none") {
        makeSelectListLayer(objSpListLayer, targetName, strURL, thisVal, thisNo);
    }
    else {
        if (event.keyCode == 13) {//엔터가 눌렸을 때
            hideListLayer(objSpListLayer);
        }
        else if (event.keyCode == 38) {//위화살표를 눌렀을 때
            maxSelect = Number(objMaxRow.value);
            if (currSelect == -1)
                currSelect = 0;
            else if (currSelect != 0)
                currSelect --;
            for (i=0;i<=maxSelect;i++){
                //objTmp = eval("document.all." + trName + i);
                objTmp = document.getElementById(trName + i);
                if (i == currSelect) {
                    selectListLayerName(objCurrNo, targetNo, targetName, thisNo, objTmp.innerHTML.replace(regRemoveTag,""));
                    objTmp.style.backgroundColor = "8bb2dc";
                }
                else {
                    objTmp.style.backgroundColor = "#dae7f4";
                }
            }
        }
        else if (event.keyCode == 40) {//아래 화살표를 눌렀을 때
            maxSelect = Number(objMaxRow.value);
            if (currSelect == -1)
                currSelect = 0;
            else if (currSelect != maxSelect)
                currSelect ++;
            for (i=0;i<=maxSelect;i++){
                //objTmp = eval("document.all." + trName + i);
                objTmp = document.getElementById(trName + i);
                if (i == currSelect) {
                    selectListLayerName(objCurrNo, targetNo, targetName, thisNo, objTmp.innerHTML.replace(regRemoveTag,""));
                    objTmp.style.backgroundColor = "8bb2dc";
                }
                else {
                    objTmp.style.backgroundColor = "#dae7f4";
                }
            }

        }
        else if (event.keyCode != 16 && event.keyCode != 17 && event.keyCode != 18){//alt,shift,ctrl무시
            makeSelectListLayer(objSpListLayer, targetName, strURL, thisVal, thisNo);
        }
    }
}
//"company_name", "/main/lib/check_company_submit.asp?company_name="
function makeSelectListLayer(objSpListLayer, targetName, strURL, thisVal, thisNo) {
    currSelect = -1;
    //obj0 = eval("document.all." + targetName + thisNo);
    obj0 = document.getElementById(targetName + thisNo);
    valX = FindPosX(obj0);
    valY = FindPosY(obj0) + obj0.offsetHeight;
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url=strURL + escape(thisVal);
    objSpan = objSpListLayer;
    xmlHttp.onreadystatechange=stateCheckListLayer;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function stateCheckListLayer() { 
    if (xmlHttp.readyState==4) {
        objSpan.innerHTML = xmlHttp.responseText;
        objSpan.style.display = "block";
        objSpan.style.left=parseInt(valX);
        objSpan.style.top=parseInt(valY);
    }
}
//자동검색레이어에서 마우스를 올렸을 경우:document.InputForm.maxRowsCount, document.InputForm.current_company_no, "company_seq_no", "company_name"
function overListLayer(objMaxRow, objCurrNo, targetNo, targetName, trName, selectNo) {
    maxSelect = Number(objMaxRow.value);
    for (i=0;i<=maxSelect;i++){
        //objTmp = eval("document.all." + trName + i);
        objTmp = document.getElementById(trName + i);
        if (i == selectNo) {
            objTmp.style.backgroundColor = "8bb2dc";
            thisNo = objCurrNo.value;
            selectListLayerName(objCurrNo, targetNo, targetName, thisNo, objTmp.innerHTML.replace(regRemoveTag,""));
        }
        else {
            objTmp.style.backgroundColor = "#dae7f4";
        }
    }
}
//자동검색레이어에서 마우스를 내렸을 경우:"trAutoSelect", selectNo
function outListLayer(trName, selectNo) {
    //objTmp = eval("document.all." + trName + selectNo);
    objTmp = document.getElementById(trName + selectNo);
    objTmp.style.backgroundColor = "#dae7f4";
}
//자동검색레이어에서 마우스를 클릭했을 경우:document.all.spCompany, document.InputForm.current_company_no, "company_name"
function clickListLayer(objSpan, objCurrNo, targetName) {
    hideListLayer(objSpan);
    eleName = eval("document.InputForm." + targetName + objCurrNo.value);
    //eleName = document.getElementsByName(targetName + objCurrNo.value);
    eleName.focus();
}
//선택한 회사명 입력:document.InputForm.current_company_no, "company_seq_no", "company_name", seq_no, name
function selectListLayerName(objCurrNo, targetNo, targetName, seq_no, name) {
    if (targetNo != "") {
        eleNo = eval("document.InputForm." + targetNo + objCurrNo.value);
        //eleNo = document.getElementsByName(targetNo + objCurrNo.value);
        eleNo.value = seq_no;
    }
    eleName = eval("document.InputForm." + targetName + objCurrNo.value);
    //eleName = document.getElementsByName(targetName + objCurrNo.value);
    eleName.value = name;
}
//hide layer
function hideListLayer(objSpan) {
    objSpan.style.display = "none";
}

/*
function checkCompany(thisVal, thisNo) {
    if (document.InputForm.current_company_no.value != thisNo) {
        document.all.spCompany.style.display = "none";
        document.InputForm.current_company_no.value = thisNo;
    }
    
    if (!document.InputForm.maxRowsCount || document.all.spCompany.style.display == "none") {
        //makeSelectCompany(thisVal, thisNo);
        makeSelectListLayer("company_name", "/main/lib/check_company_submit.asp?company_name=", thisVal, thisNo);
    }
    else {
        if (event.keyCode == 13) {//엔터가 눌렸을 때
            document.all.spCompany.style.display = "none";
        }
        else if (event.keyCode == 38) {//위화살표를 눌렀을 때
            maxSelect = Number(document.InputForm.maxRowsCount.value);
            if (currSelect == -1)
                currSelect = 0;
            else if (currSelect != 0)
                currSelect --;
            for (i=0;i<=maxSelect;i++){
                objTmp = eval("document.all.trAutoSelect" + i);
                if (i == currSelect) {
                    selectListLayerName(document.InputForm.current_company_no, "company_seq_no", "company_name", thisNo, objTmp.innerText);
                    objTmp.style.backgroundColor = "8bb2dc";
                }
                else {
                    objTmp.style.backgroundColor = "#dae7f4";
                }
            }
        }
        else if (event.keyCode == 40) {//아래 화살표를 눌렀을 때
            maxSelect = Number(document.InputForm.maxRowsCount.value);
            if (currSelect == -1)
                currSelect = 0;
            else if (currSelect != maxSelect)
                currSelect ++;
            for (i=0;i<=maxSelect;i++){
                objTmp = eval("document.all.trAutoSelect" + i);
                if (i == currSelect) {
                    selectListLayerName(document.InputForm.current_company_no, "company_seq_no", "company_name", thisNo, objTmp.innerText);
                    objTmp.style.backgroundColor = "8bb2dc";
                }
                else {
                    objTmp.style.backgroundColor = "#dae7f4";
                }
            }

        }
        else if (event.keyCode != 16 && event.keyCode != 17 && event.keyCode != 18){//alt,shift,ctrl무시
            //makeSelectCompany(thisVal, thisNo);
            makeSelectListLayer("company_name", "/main/lib/check_company_submit.asp?company_name=", thisVal, thisNo);
        }
    }
}
function makeSelectCompany(thisVal, thisNo) {
    currSelect = -1;
    obj0 = eval("document.all.company_name" + thisNo);
    valX = FindPosX(obj0);
    valY = FindPosY(obj0) + obj0.offsetHeight;
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url="/main/lib/check_company_submit.asp?company_name=" + escape(thisVal);
    xmlHttp.onreadystatechange=stateCheckCompany;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function stateCheckCompany() { 
    if (xmlHttp.readyState==4) {
        document.all.spCompany.innerHTML = xmlHttp.responseText;
        document.all.spCompany.style.display = "block";
        document.all.spCompany.style.left=parseInt(valX);
        document.all.spCompany.style.top=parseInt(valY);
    }
}
function overCompany(trName, selectNo) {
    maxSelect = Number(document.InputForm.maxRowsCount.value);
    for (i=0;i<=maxSelect;i++){
        objTmp = eval("document.all." + trName + i);
        if (i == selectNo) {
            objTmp.style.backgroundColor = "8bb2dc";
            thisNo = document.InputForm.current_company_no.value;
            selectListLayerName(document.InputForm.current_company_no, "company_seq_no", "company_name", thisNo, objTmp.innerText);
        }
        else {
            objTmp.style.backgroundColor = "#dae7f4";
        }
    }
}
function clickCompany() {
    document.all.spCompany.style.display = "none";
    eleName = eval("document.InputForm.company_name" + document.InputForm.current_company_no.value);
    eleName.focus();
}
function selectCompanyName(seq_no, name) {
    eleNo = eval("document.InputForm.company_seq_no" + document.InputForm.current_company_no.value);
    eleNo.value = seq_no;
    eleName = eval("document.InputForm.company_name" + document.InputForm.current_company_no.value);
    eleName.value = name;
}
*/
//회사명자동검색입력-끝
//회사입력추가