// JScript source code
//==========================================================================================
//  Javascript Function : ÀÔ·ÂÇÔ¼ö
//==========================================================================================
function NumberKeyDownCheck()
{
    if (event.keyCode != 13)
    {
        // ¼ýÀÚ¸¸ ¹Þ¾ÆµéÀÓ        
        if (event.keyCode >= 48 && event.keyCode <= 57) event.returnValue = true;
        else event.returnValue = false;
    }
}

function KeyPressCheck(sFormName, sFieldName, sNextField, iMaxValue)
{
    var value;
    value = GetValue(sFormName, sFieldName);
    
    if (value.length == iMaxValue && sNextField != "END")
        document.forms[sFormName].elements[sNextField].focus();
}

function toUpperCase(str)
{
    var i;
    i = event.keyCode;
    
    if (event.keyCode != 13)
    {
        // ¿µ¹®ÀÚ¸¦ ´ë¹®ÀÚ·Î ¹«Á¶°Ç º¯È¯½ÃÅ´
        if (i >= 97 && i <= 122) i = i - 32;
        event.keyCode = i;
    }
}

//==========================================================================================
//  Javascript Function : È¸¿ø°¡ÀÔ ÀÔ·ÂÇÊµå Ã¼Å©ÇÔ¼ö
//==========================================================================================
function IdCheck(strId)
{
    // ID ºÎºÐÀ» Á¤È®ÇÏ°Ô Ã¼Å© (¼ýÀÚ¿Í ¿µ¹®ÀÚ¸¸ Ã¼Å©)
    var strStringCheck, intCheckCount;
    var name_chkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
    intCheckCount = 0;
    strStringCheck = 1;
    
    for(var i=0;i < strId.length;i++)
    {
        var name_string = strId.charAt(i);
        for (j=0;j< name_chkOK.length;j++)
            if (name_string == name_chkOK.charAt(j)) 
                intCheckCount++;
    }
    
    if (strId == "" || strId == null) return false;
    else if (strId.length != intCheckCount) return false;
    else return true;
}

function NameCheck(strName)
{
    // ¼º¸í ºÎºÐÀ» Á¤È®ÇÏ°Ô Ã¼Å© (½ºÆäÀÌ½º¹Ù, ¼ýÀÚ, ¿µ¹®ÀÚ µîÀÌ ÀÖÀ¸¸é ¿¡·¯ Ç¥½Ã)
    var strStringCheck;
    var name_chkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`1234567890-=\[];',./~!@#$%^&*()_+|{}:<>?\" ";
    strStringCheck = 1;
    
    for(var i=0;i < strName.length;i++)
    {
        var name_string = strName.charAt(i);
        for (j=0;j< name_chkOK.length;j++)
            if (name_string == name_chkOK.charAt(j)) 
                strStringCheck = 0;
    }
    
    if (strName == "" || strName == null) return false;
    else if (strName.length < 2) return false;
    else if (strStringCheck == 0) return false;
    else return true;
}

function EmailCheck(strEmail, strEmailAddress)
{
    // E-MAIL ºÎºÐÀ» Á¤È®ÇÏ°Ô Ã¼Å©
    var strStringCheck;
    var strFullEmail;

    if (strEmailAddress != "0") strFullEmail = strEmail + "@" + strEmailAddress;
    
    for(var i=0;i < strFullEmail.length;i++)
    {
        strStringCheck = 0;
        var email_chkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0987654321-_.@";
        var email_string = strFullEmail.charAt(i);
        for (var j=0;j< email_chkOK.length;j++)
        {
            if (email_string == email_chkOK.charAt(j)) 
                strStringCheck++;
        }
    }
    if (strFullEmail == "" || strFullEmail == null) return false;
    else if (strFullEmail.length < 2) return false;
    else if (strFullEmail.indexOf('@') == -1 || strFullEmail.indexOf('.') == -1) return false;
    else if (strFullEmail.indexOf(" ") >= 0 || strFullEmail.indexOf("?") >= 0) return false;
    else if (strStringCheck != 1) return false;
    else return true;    
}

function PwCheck(strPw)
{
    // E-MAIL ºÎºÐÀ» Á¤È®ÇÏ°Ô Ã¼Å©
    var strStringCheck;
    var strPw;

    for(var i=0;i < strPw.length;i++)
    {
        strStringCheck = 0;
        var pw_chkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`1234567890-=\][;'/.,~!@#$%^&*()_+|{}:<>? ";
        var pw_string = strPw.charAt(i);
        for (var j=0;j< pw_chkOK.length;j++)
        {
            if (pw_string == pw_chkOK.charAt(j)) 
                strStringCheck++;
        }
    }
    if (strPw == "" || strPw == null) return false;
    else if (strPw.length < 4) return false;
    else if (strStringCheck != 1) return false;
    else return true;        
}

function JuminCheck(jnum_01, jnum_02)
{
    check_jumin = false
    // Àß¸øµÈ »ý³â¿ùÀÏÀ» °Ë»çÇÕ´Ï´Ù.
    b_Year = (jnum_02.charAt(0) <= "2") ? "19" : "20"
    /* 2000³âµµºÎÅÍ ¼º±¸º° ¹øÈ£°¡ ¹Ù²î¿´½¿À¸·Î ±¸º°¼ö°¡ 2º¸´Ù ÀÛ´Ù¸é
    1900³âµµ »ýÀÌµÇ°í 2º¸´Ù Å©´Ù¸é 2000³âµµ ÀÌ»ó»ýÀÌ µË´Ï´Ù. 
    ´Ü 1800³âµµ »ýÀº °è»ê¿¡¼­ Á¦¿ÜÇÕ´Ï´Ù.*/

    b_Year += jnum_01.substr(0, 2)
    // ÁÖ¹Î¹øÈ£ÀÇ ¾Õ¿¡¼­ 2ÀÚ¸®¸¦ ÀÌ¾î¼­ 4ÀÚ¸®ÀÇ »ý³âÀ» ÀúÀåÇÕ´Ï´Ù.
    b_Month = jnum_01.substr(2, 2) - 1
    // ´ÞÀ» ±¸ÇÕ´Ï´Ù. 1À» »«°ÍÀº ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­´Â 1¿ùÀ» 0À¸·Î Ç¥±âÇÏ±â ¶§¹®ÀÔ´Ï´Ù.
    b_Date = jnum_01.substr(4, 2)
    b_sum = new Date(b_Year, b_Month, b_Date)
    if ( b_sum.getYear() % 100 != jnum_01.substr(0, 2) || b_sum.getMonth() != b_Month || b_sum.getDate() != b_Date) {
    return check_jumin
    // »ý³â¿ùÀÏÀÇ Å¸´ç¼ºÀ» °Ë»çÇÏ¿© °ÅÁþÀÌ ÀÖÀ»½Ã ¿¡·¯¸Þ¼¼Áö¸¦ ³ªÅ¸³¿
    }

    total = 0
    temp = new Array(13)
    for(i=1; i<=6; i++) temp[i] = jnum_01.charAt(i-1)
    for(i=7; i<=13; i++) temp[i] = jnum_02.charAt(i-7)
    for(i=1; i<=12; i++) {
    k = i + 1
    if(k >= 10) k = k % 10 + 2
    /* °¢ ¼ö¿Í °öÇÒ ¼ö¸¦ »Ì¾Æ³À´Ï´Ù. °ö¼ö°¡ ¸¸ÀÏ 10º¸´Ù Å©°Å³ª °°´Ù¸é
    °è»ê½Ä¿¡ ÀÇÇØ 2·Î ´Ù½Ã ½ÃÀÛÇÏ°Ô µË´Ï´Ù. */
    total = total + (temp[i] * k)
    // °¢ ÀÚ¸®¼ö¿Í °è»ê¼ö¸¦ °öÇÑ°ªÀ» º¯¼ö total¿¡ ´©ÀûÇÕ»ê½ÃÅµ´Ï´Ù.
    }

    last_num = (11- (total % 11)) % 10
    // ¸¶Áö¸· °è»ê½ÄÀ» º¯¼ö last_num¿¡ ´ëÀÔÇÕ´Ï´Ù.
    if(last_num == temp[13]) check_jumin = true
    // laster_numÀÌ ÁÖ¹Î¹øÈ£ÀÇ¸¶Áö¸·¼ö¿Í °°Àº¸é ÂüÀ» Æ²¸®¸é °ÅÁþÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.
    else check_jumin = false
    return check_jumin
}

//==========================================================================================
//  Javascript Function : ÀÏ¹ÝÇÔ¼ö
//==========================================================================================
function SetAlertFocus(strAlertMsg, strFormName, strFocusName)
{
    var objForm;
    
    if (!IsForm(strFormName)) alert("SCRIPT : ÁöÁ¤µÈ Form[" + strFormName + "] ¼Ó¼ºÀ» Ã£À» ¼ö ¾ø½À´Ï´Ù.");
    else if (document.forms[strFormName].elements[strFocusName] == null) alert("SCRIPT : ÁöÁ¤µÈ INPUT TAG [" + strFocusName + "] ¼Ó¼ºÀ» Ã£À» ¼ö ¾ø½À´Ï´Ù.");
    else
    {
        alert(strAlertMsg);
        document.forms[strFormName].elements[strFocusName].focus();
    }    
}

function IsForm(strFormName)
{
    if (document.forms[strFormName] == null) return false;
    return true;
}

//==========================================================================================
// Javascript Function : SelectBox Access / Field Access
//==========================================================================================
function GetSelectBoxText(strFormName, strSelectBoxName)
{
    // SelectBox ¿¡¼­ ¼±ÅÃµÈ option ÀÇ ÅØ½ºÆ®¸¦ °¡Á®¿Â´Ù.
    var intSelectedIndex, strSelectedText;
    
    if (!IsForm(strFormName)) alert("SCRIPT : ÁöÁ¤µÈ Form[" + strFormName + "] ¼Ó¼ºÀ» Ã£À» ¼ö ¾ø½À´Ï´Ù.");
    else
    {
        intSelectedIndex = document.forms[strFormName].elements[strSelectBoxName].selectedIndex;
        strSelectedText = document.forms[strFormName].elements[strSelectBoxName][intSelectedIndex].text;
    
        return strSelectedText;
    }
}

function GetSelectBoxValue(strFormName, strSelectBoxName)
{
    // SelectBox ¿¡¼­ ¼±ÅÃµÈ option ÀÇ ÅØ½ºÆ®¸¦ °¡Á®¿Â´Ù.
    var intSelectedIndex, strSelectedText;
    
    if (!IsForm(strFormName)) alert("SCRIPT : ÁöÁ¤µÈ Form[" + strFormName + "] ¼Ó¼ºÀ» Ã£À» ¼ö ¾ø½À´Ï´Ù.");
    else
    {
        intSelectedIndex = document.forms[strFormName].elements[strSelectBoxName].selectedIndex;
        strSelectedText = document.forms[strFormName].elements[strSelectBoxName][intSelectedIndex].value;
    
        return strSelectedText;
    }
}

function GetValue(strFormName, strFieldName)
{
    // ÁöÁ¤µÈ INPUT ¶Ç´Â HIDDEN ÇÊµå¿¡¼­ °ªÀ» °¡Á®¿Â´Ù
    var strFieldValue;
    
    if (!IsForm(strFormName)) alert("SCRIPT : ÁöÁ¤µÈ Form[" + strFormName + "] ¼Ó¼ºÀ» Ã£À» ¼ö ¾ø½À´Ï´Ù.");
    else
    {
        strFieldValue = document.forms[strFormName].elements[strFieldName].value;
        
        return strFieldValue;
    }
}
