﻿function loginPop() {
    var logpopup = window.open('/login/popLogin.aspx', 'logpopup', 'top=70,left=70,width=350,height=260');
    logpopup.focus();
}


function payMethodChange(method) {
    document.getElementById("gopaymethod").value = method;
    return;
}

function priceChange(price, mCode,rMCode) {
    document.getElementById("goodname").value = "일지희망편지(" + rMCode + "개월)";
    document.getElementById("monthCode").value = mCode;
    document.getElementById("price").value = price;
    return;
}

function isNumeric(num) {
    for (var i = 3; i < num.length; i++) {
        var ch = num.charAt(i);
        if (ch < '0' || ch > '9') {
            return false;
        }
    }
    return true;
}

function chkDigitM(event) {
    var obj = null;
    if (getBrowser() == BROWSER_IE) {
        obj = event.srcElement;
    } else {
        obj = event.target;
    }

    var KeyResult = event.which;
    if (typeof (KeyResult) == "undefined") {
        KeyResult = event.keyCode
    }

    if ((KeyResult != 8) && (KeyResult != 0) && (KeyResult < 48 || KeyResult > 57) && (KeyResult != 13)) {
        alert("숫자만 입력 가능합니다");
    }

    obj.focus();
}

function modalClose() {
    var modalPopupBehaviorCtrl = $find('MPE');
    modalPopupBehaviorCtrl.hide();
}


function modelView() {
    var logInfo = getElement(document.forms[0], "hdnLogInfo").value;
    if (logInfo == "Y") {

        var dcCount = parseInt(document.getElementById("price").value) / 100;
        setText(document.getElementById("monSpan"), document.getElementById("monthCode").value.trim().substring(1, 2));        
        setText(document.getElementById("dcCnt"), dcCount.toString());
        setText(document.getElementById("dcCnt02"), dcCount.toString());
        document.getElementById("hdnPoint").value = dcCount.toString();

        if (dcCount > parseInt($("lblBeanCount").childNodes[0].nodeValue.replace(",", "").trim())) {
            //            alert("뇌콩이 부족합니다. 충전후 이용하여 주십시요!");
            //            return false;

            $("ibtnBuy").style.display = "none";
            $("ibtnFill").style.display = "";

        } else {
            document.getElementById("hdnChecked").valeu = "br";
            $("ibtnBuy").style.display = "";
            $("ibtnFill").style.display = "none";
        }

        var modalPopupBehaviorCtrl = $find('MPE');
        modalPopupBehaviorCtrl.show();
    } else {
        alert('로그인후 이용하여 주십시요!');
        location.href = "/login/loginPage.aspx?url=" + getElement(document.forms[0], "hdnPUrl").value;
    }
}

function payPopup() {
    var modalPopupBehaviorCtrl = $find('MPE');
    modalPopupBehaviorCtrl.hide();

    LeftPosition = (screen.width) ? (screen.width - 383) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height) / 2 : 0;

    Popup.openPopup('payPopup', "/mypage/pricefilling.aspx", TopPosition, LeftPosition, 383, 335, 'no', 'L');
}

function CheckAlgoSSN(jumin) {
    var check = false;
    var summ = 0;
    var regno = jumin;
    var strNum = "234567892345";
    for (zz = 0; zz < 12; zz++)
        summ = summ + regno.substring(zz, zz + 1) * strNum.substring(zz, zz + 1);

    privot = regno.substring(12, 13)
    end_num = 11 - (summ % 11);
    if (end_num >= 10) end_num = end_num - 10;
    if (privot == end_num) check = true;
    return check;
}

function nextSSN(event) {
    var obj = null;
    if (getBrowser() == BROWSER_IE) {
        obj = event.srcElement;
    } else {
        obj = event.target;
    }

    if (obj.value.length == 6) {
        document.getElementById("jumin2").focus();
    }
}

