//##############################################################################
//# ÇÁ·Î±×·¥ID : base.js
//# ÆäÀÌÁö¼³¸í : ¸ðµç »çÀÌÆ® °øÅë ½ºÅ©¸³Æ®
//# ÃÖÃÊÀÛ¼ºÀÚ : ±è¿Õ±â
//# ÃÖÃÊÀÛ¼ºÀÏ : 2007.10.05 (±Ý)
//# ÃÖÁ¾¼öÁ¤ÀÚ : ±è¿Õ±â
//# ÃÖÁ¾¼öÁ¤ÀÏ : 2008.01.26 (Åä)
//#
//#
//# === °ËÁõ °ü·Ã ==============================================================
//# ---> jsIsIE()                                       ===> ºê¶ó¿ìÀú CHECK
//# ---> jsIsEmpty(strText)                             ===> °ø¹é¹®ÀÚ¿­ CHECK
//#      jsIfEmpty(strText, strSub)
//# ---> jsIsDigit(strText)                             ===> ¼ýÀÚ CHECK
//#      jsIfNotDigit(strText, strSub)
//# ---> jsIsEnglish(strText)                           ===> ¿µ¾î CHECK
//#      jsIfNotEnglish(strText, strSub)
//# ---> jsIsDigitEnglish(strText)                      ===> ¼ýÀÚ¿µ¾î CHECK
//#      jsIsDigitEnglishHangeul(strText, strSub)       ===> ¼ýÀÚ¿µ¾îÇÑ±Û CHECK
//# ---> jsIsHangeul(strText)                           ===> ÇÑ±Û CHECK
//#      jsIfNotHangeul(strText, strSub)
//#
//# ---> jsIsEmail(strText)                             ===> ÀÌ¸ÞÀÏ ÀüÃ¼ Ã¼Å©
//#      jsIsEmail2(strText)                            ===> ÀÌ¸ÞÀÏ ¾ÆÀÌµð Ã¼Å©
//#      jsIsEmail3(strText)                            ===> ÀÌ¸ÞÀÏ µµ¸ÞÀÎ Ã¼Å©
//#
//# ---> jsImgExtCheck(strText)                         ===> ÀÌ¹ÌÁö È®ÀåÀÚ CHECK
//#
//# === ¹®ÀÚ¿­ °ü·Ã ============================================================
//# ---> jsTrimString(strText)                          ===> ÁÂ¿ì°ø¹é Á¦°Å
//# ---> jsParseProperty(strProps, strToken)            ===> ÇÁ·ÎÆÛÆ¼ ÆÄ½Ì
//#
//#
//# === Æû °ü·Ã ================================================================
//# ---> jsTrimElement(objEle)                          ===> ¿¤¸®¸ÕÆ® °ª ÁÂ¿ì°ø¹é Á¦°Å
//# ---> jsTrimTextElements(objForm)                    ===> TEXT(TEXTAREA) °ª ÁÂ¿ì°ø¹é Á¦°Å
//# ---> jsGetCheckedValues(objEle, strDilim)           ===> CHECKBOX(RADIO)ÀÇ ¼±ÅÃ°ª
//#
//#
//# === ¿¤¸®¸ÕÆ® °ü·Ã ==========================================================
//# ---> jsGetElementsByClass(strCls, strTag, strPid)   ===> Å¬·¡½º¸íÀ¸·Î ¿¤¸®¸ÕÆ® °Ë»ö
//# ---> jsIgnoreWhiteSpace(objEle)                     ===> ºó ÅØ½ºÆ®³ëµå Á¦°Å
//# ---> jsGetPositionX(objEle)                         ===> BODY¸¦ ±âÁØÀ¸·Î ¿¤¸®¸ÕÆ®ÀÇ XÁÂÇ¥ °è»ê
//# ---> jsGetPositionY(objEle)                         ===> BODY¸¦ ±âÁØÀ¸·Î ¿¤¸®¸ÕÆ®ÀÇ YÁÂÇ¥ °è»ê
//# ---> jsOrderElementPrev(objEle)                     ===> °°Àº ºÎ¸ð³»¿¡¼­ ÀÌÀü ¼ø¼­·Î ÀÌµ¿
//# ---> jsOrderElementNext(objEle)                     ===> °°Àº ºÎ¸ð³»¿¡¼­ ´ÙÀ½ ¼ø¼­·Î ÀÌµ¿
//#
//#
//# === ÄÁÅÙÃ÷ °ü·Ã ============================================================
//# ---> jsPopup(strUrl, strName, strProps)             ===> ÆË¾÷
//# ---> jsViewFlash(strUrl, strProps)                      ===> ÇÃ·¡½Ã
//# ---> jsCreateLayer(strId, strSrc, blnIsFile)        ===> ·¹ÀÌ¾î »ý¼º
//#
//#
//# === ÀÌº¥Æ® °ü·Ã ============================================================
//# ----> jsAttachEvent(strEvent, objFunc)              ===> À©µµ¿ì ÀÌº¥Æ® Ãß°¡
//#
//#
//# === ÀÌ¸ÞÀÏ Ã¼Å©  ===========================================================
//#
//#
//# === AJAX °ü·Ã ==============================================================
//# ---> jsCreateXMLHTTP()                              ===> XMLHTTP °´Ã¼ »ý¼º
//# ---> jsGetSource(strUrl)                            ===> ÆÄÀÏ ³»¿ë ÃßÃâ
//# ---> jsIncludeFile(strUrl, strId)                       ===> ÆÄÀÏ ÀÎÅ¬·çµå
//##############################################################################
//



//==============================================================================
// Á¤±Ô½Ä Á¤ÀÇ
//==============================================================================
var JS_CONST_REGEXP_DIGIT   = /^[0-9]+$/;
var JS_CONST_REGEXP_ENGLISH = /^[a-zA-Z]+$/;
var JS_CONST_REGEXP_HANGEUL = /^[¤¡-¤¾°¡-ÆR]+$/;
var JS_CONST_REGEXP_TRIM    = /(^[\s]*)|([\s]*$)/g;
var JS_CONST_REGEXP_DIGIT_ENGLISH = /^[0-9a-zA-Z]+$/;
var JS_CONST_REGEXP_DIGIT_ENGLISH_HANGEUL = /^[0-9a-zA-Z¤¡-¤¾°¡-ÆR]+$/;
var JS_CONST_REGEXP_email1 = /^[a-zA-Z0-9\-\.\_]+$/;
var JS_CONST_REGEXP_email2 = /^[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4})+$/;


//==============================================================================
// °ËÁõ °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// ºê¶ó¿ìÀú CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsIE()
 * @return
 *      ºê¶ó¿ìÀú°¡ IEÀÎÁöÀÇ ³í¸®°ª
 * @description
 *      ºÒ¿ÏÀü... ³ªÁß¿¡ ·ÎÁ÷ Ãß°¡...
 */
function jsIsIE() {
    return (navigator.userAgent.toUpperCase().indexOf("MSIE") != -1);
}


//------------------------------------------------------------------------------
// °ø¹é¹®ÀÚ¿­ CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsEmpty(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      °ø¹é¹®ÀÚ¿­ÀÎÁöÀÇ ³í¸®°ª
 */
function jsIsEmpty(strText) {
    if (strText != null) {
        return (strText.toString().replace(JS_CONST_REGEXP_TRIM, "").length == 0);
    }
    else {
        return true;
    }
}

/***
 * @function
 *      jsIfEmpty(strText, strSub)
 * @used
 *      jsIsEmpty(strText)
 * @param
 *      strText °ËÁõ¹®ÀÚ¿­
 *      strSub  ´ëÃ¼¹®ÀÚ¿­
 * @return
 *      °ø¹é¹®ÀÚ¿­ ¿©ºÎ¿¡ µû¸¥ °ËÁõ¹®ÀÚ¿­ ¶Ç´Â ´ëÃ¼¹®ÀÚ¿­
 */
function jsIfEmpty(strText, strSub) {
    return (jsIsEmpty(strText) ? strSub : strText);
}


//------------------------------------------------------------------------------
// ¼ýÀÚ CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsDigit(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ¼ýÀÚÀÎÁöÀÇ ³í¸®°ª
 */
function jsIsDigit(strText) {
    return (strText != null) && (JS_CONST_REGEXP_DIGIT.test(strText));
}

/***
 * @function
 *      jsIfNotDigit(strText, strSub)
 * @used
 *      jsIsDigit(strText)
 * @param
 *      strText °ËÁõ¹®ÀÚ¿­
 *      strSub  ´ëÃ¼¹®ÀÚ¿­
 * @return
 *      ¼ýÀÚÀÎÁöÀÇ ¿©ºÎ¿¡ µû¸¥ °ËÁõ¹®ÀÚ¿­ ¶Ç´Â ´ëÃ¼¹®ÀÚ¿­
 */
function jsIfNotDigit(strText, strSub) {
    return (jsIsDigit(strText) ? strText : strSub);
}


//------------------------------------------------------------------------------
// ¿µ¾î CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsEnglish(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ¿µ¹®ÀÚÀÎÁöÀÇ ³í¸®°ª
 */
function jsIsEnglish(strText) {
    return (strText != null) && (JS_CONST_REGEXP_ENGLISH.test(strText));
}

//------------------------------------------------------------------------------
// ¼ýÀÚ + ¿µ¾î CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsDigitEnglish(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ¿µ¹®ÀÚÀÎÁöÀÇ ³í¸®°ª
 */
function jsIsDigitEnglish(strText) {
    return (strText != null) && (JS_CONST_REGEXP_DIGIT_ENGLISH.test(strText));
}


//------------------------------------------------------------------------------
// ¼ýÀÚ + ¿µ¾î + ÇÑ±Û CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsDigitEnglish(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ¿µ¹®ÀÚÀÎÁöÀÇ ³í¸®°ª
 */
function jsIsDigitEnglishHangeul(strText) {
    return (strText != null) && (JS_CONST_REGEXP_DIGIT_ENGLISH_HANGEUL.test(strText));
}


/***
 * @function
 *      jsIfNotEnglish(strText, strSub)
 * @used
 *      jsIsEnglish(strText)
 * @param
 *      strText °ËÁõ¹®ÀÚ¿­
 *      strSub  ´ëÃ¼¹®ÀÚ¿­
 * @return
 *      ¿µ¹®ÀÚÀÎÁöÀÇ ¿©ºÎ¿¡ µû¸¥ °ËÁõ¹®ÀÚ¿­ ¶Ç´Â ´ëÃ¼¹®ÀÚ¿­
 */
function jsIfNotEnglish(strText, strSub) {
    return (jsIsEnglish(strText) ? strText : strSub);
}


//------------------------------------------------------------------------------
// ÇÑ±Û CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsHangeul(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ÇÑ±ÛÀÎÁöÀÇ ³í¸®°ª
 */
function jsIsHangeul(strText) {
    return (strText != null) && (JS_CONST_REGEXP_HANGEUL.test(strText));
}

/***
 * @function
 *      jsIfNotHangeul(strText, strSub)
 * @used
 *      jsIsHangeul(strText)
 * @param
 *      strText °ËÁõ¹®ÀÚ¿­
 *      strSub  ´ëÃ¼¹®ÀÚ¿­
 * @return
 *      ÇÑ±ÛÀÎÁöÀÇ ¿©ºÎ¿¡ µû¸¥ °ËÁõ¹®ÀÚ¿­ ¶Ç´Â ´ëÃ¼¹®ÀÚ¿­
 */
function jsIfNotHangeul(strText, strSub) {
    return (jsIsHangeul(strText) ? strText : strSub);
}

//------------------------------------------------------------------------------
// ÀÌ¸ÞÀÏ ¾ÆÀÌµð CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsEmail2(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ¿µ¹®¼ýÀÚÇÏÀÌÇÂÀÇ ³í¸®°ª
 */
function jsIsEmail2(strText)  {
    return (strText != null) && (JS_CONST_REGEXP_email1.test(strText));
}

//------------------------------------------------------------------------------
// ÀÌ¸ÞÀÏ µµ¸ÞÀÎ CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsEmail3(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ¿µ¹®¼ýÀÚÇÏÀÌÇÂÀÇ ³í¸®°ª
 */
function jsIsEmail3(strText)  {
    return (strText != null) && (JS_CONST_REGEXP_email2.test(strText));
}

//------------------------------------------------------------------------------
// ÀÌ¸ÞÀÏ Çü½Ä CHECK
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIsEmail(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ÀÌ¸ÞÀÏ ÇÕ´çÇÑ ³í¸®°ª
 */
function jsIsEmail(strText) {
    emailEx1 = /[^@]+@[A-Za-z0-9_-]+.[A-Za-z]+/;
    emailEx2 = /[^@]+@[A-Za-z0-9_-]+.[A-Za-z0-9_-]+.[A-Za-z]+/;
    emailEx3 = /[^@]+@[A-Za-z0-9_-]+.[A-Za-z0-9_-]+.[A-Za-z0-9_-]+.[A-Za-z]+/;

    if(emailEx1.test(strText)) return true;
    if(emailEx2.test(strText)) return true;
    if(emailEx3.test(strText)) return true;

    return false;
}


//==============================================================================
// ¹®ÀÚ¿­ °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// ÁÂ¿ì°ø¹é Á¦°Å
//------------------------------------------------------------------------------
/***
 * @function
 *      jsTrimString(strText)
 * @param
 *      strText ¹®ÀÚ¿­
 * @return
 *      ÁÂ¿ì°ø¹éÀÌ Á¦°ÅµÈ ¹®ÀÚ¿­
 */
function jsTrimString(strText) {
    return (strText == null ? null : strText.replace(JS_CONST_REGEXP_TRIM, ""));
}


//------------------------------------------------------------------------------
// ÇÁ·ÎÆÛÆ¼ ÆÄ½Ì
//------------------------------------------------------------------------------
/***
 * @function
 *      jsParseProperty(strProps, strToken)
 * @used
 *      jsIsEmpty(strText)
 * @param
 *      strProps ÇÁ·ÎÆÛÆ¼Çü½Ä ¹®ÀÚ¿­
 *      strToken ±¸ºÐÀÚ
 * @return
 *      Å°¿Í °ªÀ¸·Î ÀÌ·ç¾îÁø ´ÙÂ÷¿ø ¹è¿­º¯¼ö
 * @description
 *      strPropsÀÇ Çü½ÄÀº "key=value"¿Í °°ÀÌ ÀÛ¼ºÇÏ¸ç strTokenÀº ","°¡ µðÆúÆ®
 *
 *      ex) test = jsParseProperty("width=100&height=200&top=50", "&")
 *          test.get("width",  10)  ==> 100
 *          test.get("height", 30)  ==> 200
 *          test.get("top",    0)   ==> 50
 *          test.get("left",   300) ==> 300
 */
function jsParseProperty(strProps, strToken) {
    var aryList  = new Array();

    if (jsIsEmpty(strProps) == false) {
        var aryItems = strProps.replace(/[\s]/g, "").split(strToken == null ? "," : strToken);
        var intCnt   = 0;

        for (var i=0; i < aryItems.length; i++) {
            if (aryItems[i].indexOf("=") > 0) {
                var aryTemp = aryItems[i].split("=");

                if (jsIsEmpty(aryTemp[0]) == false) {
                    aryList[intCnt] = new Array(aryTemp[0], aryTemp[1]);
                    intCnt = intCnt + 1;
                }
            }
        }
    }

    aryList.get = function(strKey, strSub) {
        for (var i=0; i < this.length; i++) {
            if (this[i][0] == strKey) return this[i][1];
        }

        return strSub;
    }

    return aryList;
}


//==============================================================================
// Æû °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// ¿¤¸®¸ÕÆ® °ª ÁÂ¿ì°ø¹é Á¦°Å
//------------------------------------------------------------------------------
/***
 * @function
 *      jsTrimElement(objEle)
 * @used
 *      jsTrimString(strText)
 * @param
 *      objEle ¿¤¸®¸ÕÆ®
 * @return
 *      ÁÂ¿ì°ø¹éÀÌ Á¦°ÅµÈ ¿¤¸®¸ÕÆ®ÀÇ °ª
 */


function jsTrimElement(objEle) {
    objEle.value = jsTrimString(objEle.value);
    return objEle.value;

}


//------------------------------------------------------------------------------
// TEXT(TEXTAREA) ¿¤¸®¸ÕÆ® °ª ÁÂ¿ì°ø¹é Á¦°Å
//------------------------------------------------------------------------------
/***
 * @function
 *      jsTrimTextElements(objForm)
 * @used
 *      jsTrimElement(objEle)
 * @param
 *      objForm ¿¤¸®¸ÕÆ®ÀÇ ºÎ¸ðÆû
 */
function jsTrimTextElements(objForm) {
    for (var i=0; i < objForm.elements.length; i++) {
        if ((objForm.elements[i].type == "text") || (objForm.elements[i].type == "textarea")) {
            jsTrimElement(objForm.elements[i]);
        }
    }
}


//------------------------------------------------------------------------------
// CHECKBOX(RADIO)ÀÇ ¼±ÅÃ°ª
//------------------------------------------------------------------------------
/***
 * @function
 *      jsGetCheckedValues(objEle, strDilim)
 * @param
 *      objEle   ¿¤¸®¸ÕÆ®
 *      strDilim ±¸ºÐÀÚ
 */
function jsGetCheckedValues(objEle, strDilim) {
    var strValues = "";

    if (strDilim == null) strDilim = ",";

    if (objEle.length) {
        for (var i=0; i < objEle.length; i++) {
            if (objEle[i].checked) strValues = strValues + strDilim + objEle[i].value;
        }
    }
    else {
        if (objEle.checked) strValues = objEle.value;
    }

    return strValues.replace(new RegExp("^[" + strDilim + "]"), "");
}


//==============================================================================
// ¿¤¸®¸ÕÆ® °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// Å¬·¡½º¸íÀ¸·Î ¿¤¸®¸ÕÆ® °Ë»ö
//------------------------------------------------------------------------------
/***
 * @function
 *      jsGetElementsByClass(strCls, strTag, strPid)
 * @param
 *      strCls Å¬·¡½º¸í
 *      strTag ÅÂ±×¸í
 *      strPid ºÎ¸ðID
 * @return
 *      °Ë»öµÈ ¿¤¸®¸ÕÆ®°¡ ÀúÀåµÈ ¹è¿­º¯¼ö
 */
function jsGetElementsByClass(strCls, strTag, strPid) {
    var aryList   = new Array();
    var objParent = document.getElementById(strPid);
    var aryEles   = (objParent == null ? document : objParent).getElementsByTagName(strTag == null ? "*" : strTag);
    var intCnt    = 0;

    for (var i=0; i < aryEles.length; i++) {
        if (aryEles[i].className.match(strCls)) {
            aryList[intCnt] = aryEles[i];
            intCnt = intCnt + 1;
        }
    }

    return aryList;
}


//------------------------------------------------------------------------------
// ºó ÅØ½ºÆ®³ëµå Á¦°Å
//------------------------------------------------------------------------------
/***
 * @function
 *      jsIgnoreWhiteSpace(objEle)
 * @used
 *      jsIsEmpty(strText)
 * @param
 *      objEle ¿¤¸®¸ÕÆ®
 */
function jsIgnoreWhiteSpace(objEle) {
    for (var i=0; i < objEle.childNodes.length; i++) {
        var objNode = objEle.childNodes[i];

        if ((objNode.nodeType == 3) && (jsIsEmpty(objNode.nodeValue))) {
            objEle.removeChild(objNode);
            i = i - 1;
        }
        else {
            jsIgnoreWhiteSpace(objNode);
        }
    }
}


//------------------------------------------------------------------------------
// BODY¸¦ ±âÁØÀ¸·Î ¿¤¸®¸ÕÆ®ÀÇ XÁÂÇ¥ °è»ê
//------------------------------------------------------------------------------
/***
 * @function
 *      jsGetPositionX(objEle)
 * @param
 *      objEle ¿¤¸®¸ÕÆ®
 * @return
 *      ¿¤¸®¸ÕÆ®ÀÇ XÁÂÇ¥
 */
function jsGetPositionX(objEle) {
    var intX = 0;

    do {
        intX += objEle.offsetLeft;
        objEle = objEle.offsetParent;
    }
    while (objEle != document.body);

    return intX;
}


//------------------------------------------------------------------------------
// BODY¸¦ ±âÁØÀ¸·Î ¿¤¸®¸ÕÆ®ÀÇ YÁÂÇ¥ °è»ê
//------------------------------------------------------------------------------
/***
 * @function
 *      jsGetPositionY(objEle)
 * @param
 *      objEle ¿¤¸®¸ÕÆ®
 * @return
 *      ¿¤¸®¸ÕÆ®ÀÇ YÁÂÇ¥
 */
function jsGetPositionY(objEle) {
    var intY = 0;

    do {
        intY += objEle.offsetTop;
        objEle = objEle.offsetParent;
    }
    while (objEle != document.body);

    return intY;
}


//------------------------------------------------------------------------------
// °°Àº ºÎ¸ð³»¿¡¼­ ÀÌÀü ¼ø¼­·Î ÀÌµ¿
//------------------------------------------------------------------------------
/***
 * @function
 *      jsOrderElementPrev(objEle)
 * @param
 *      objEle ¿¤¸®¸ÕÆ®
 * @description
 *      ºÎ¸ð¿¤¸®¸ÕÆ®°¡ °°Àº ¿¤¸®¸ÕÆ®°£ÀÇ ¼ø¼­ Á¶Á¤
 */
function jsOrderElementPrev(objEle) {
    var objParent = objEle.parentNode;
    var objPrev   = objEle.previousSibling;

    while (objPrev != null) {
        if ((objPrev.nodeType == 1) && (objPrev.style.display != "none")) {
            break;
        }
        else {
            objPrev = objPrev.previousSibling;
        }
    }

    if (objPrev != null) {
        objParent.removeChild(objEle);
        objParent.insertBefore(objEle, objPrev);
    }
}


//------------------------------------------------------------------------------
// °°Àº ºÎ¸ð³»¿¡¼­ ´ÙÀ½ ¼ø¼­·Î ÀÌµ¿
//------------------------------------------------------------------------------
/***
 * @function
 *      jsOrderElementNext(objEle)
 * @used
 *      jsIsObject(objEle)
 * @param
 *      objEle ¿¤¸®¸ÕÆ®
 * @description
 *      ºÎ¸ð¿¤¸®¸ÕÆ®°¡ °°Àº ¿¤¸®¸ÕÆ®°£ÀÇ ¼ø¼­ Á¶Á¤
 */
function jsOrderElementNext(objEle) {
    var objParent = objEle.parentNode;
    var objNext   = objEle.nextSibling;

    while (objNext != null) {
        if ((objNext.nodeType == 1) && (objNext.style.display != "none")) {
            break;
        }
        else {
            objNext = objNext.nextSibling;
        }
    }

    if (objNext != null) {
        objParent.removeChild(objEle);

        if (objNext.nextSibling == null) {
            objParent.appendChild(objEle);
        }
        else {
            objParent.insertBefore(objEle, objNext.nextSibling);
        }
    }
}


//==============================================================================
// ÄÁÅÙÃ÷ °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// ÆË¾÷
//------------------------------------------------------------------------------
/***
 * @function
 *     jsPopup(strUrl, strName, strProps)
 * @use
 *     jsParseProperty(strProps, strToken)
 * @param
 *     strUrl   ÆÄÀÏ°æ·Î
 *     strName  À©µµ¿ì ÀÌ¸§
 *     strProps ÇÁ·ÎÆÛÆ¼Çü½Ä ¹®ÀÚ¿­
 * @description
 *     strPropsÀÇ ÇüÅÂ´Â "width=100, height=100" °ú °°ÀÌ ÀÛ¼ºÇÑ´Ù.
 *     - top         À§Ä¡ Y          (0)
 *     - left        À§Ä¡ X          (200)
 *     - width       ³ÐÀÌ            (0)
 *     - height      ³ôÀÌ            (0)
 *     - titlebar    Å¸ÀÌÆ²¹Ù À¯¹«   (no)
 *     - toolbar     Åø¹Ù À¯¹«       (no)
 *     - menubar     ¸Þ´º¹Ù À¯¹«     (no)
 *     - location    ÁÖ¼ÒÃ¢ À¯¹«     (no)
 *     - status      »óÅÂÃ¢ À¯¹«     (no)
 *     - resizable   »çÀÌÁîÁ¶Á¤ À¯¹« (no)
 *     - scrollbars  ½ºÅ©·Ñ¹Ù À¯¹«   (yes)
 *     - copthistory È÷½ºÅä¸® ÀúÀå   (no)
 */
function jsPopup(strUrl, strName, strProps) {
    var aryPropList = jsParseProperty(strProps, ",");
    var strParam    = "";

    strParam += "top="         + aryPropList.get("top",         "0")   + ", ";
    strParam += "left="        + aryPropList.get("left",        "200") + ", ";
    strParam += "width="       + aryPropList.get("width",       "0")   + ", ";
    strParam += "height="      + aryPropList.get("height",      "0")   + ", ";
    strParam += "titlebar="    + aryPropList.get("titlebar",    "no")  + ", ";
    strParam += "toolbar="     + aryPropList.get("toolbar",     "no")  + ", ";
    strParam += "menubar="     + aryPropList.get("menubar",     "no")  + ", ";
    strParam += "location="    + aryPropList.get("location",    "no")  + ", ";
    strParam += "status="      + aryPropList.get("status",      "no")  + ", ";
    strParam += "resizable="   + aryPropList.get("resizable",   "no")  + ", ";
    strParam += "scrollbars="  + aryPropList.get("scrollbars",  "no")  + ", ";
    strParam += "copyhistory=" + aryPropList.get("copyhistory", "no")  + "  ";

    window.open(strUrl, strName, strParam);

    return strName;
}


//------------------------------------------------------------------------------
// ÇÃ·¡½Ã
//------------------------------------------------------------------------------
/***
 * @function
 *     jsViewFlash(strUrl, strProps)
 * @use
 *     jsIsIE()
 *     jsParseProperty(strProps, strToken)
 * @param
 *     strUrl   ÆÄÀÏ°æ·Î
 *     strProps ÇÁ·ÎÆÛÆ¼Çü½Ä ¹®ÀÚ¿­
 * @description
 *     strPropsÀÇ ÇüÅÂ´Â "width=100, height=100, align=middle" °ú °°ÀÌ ÀÛ¼ºÇÑ´Ù.
 *     - width   ³ÐÀÌ       (100%)
 *     - height  ³ôÀÌ       (100%)
 *     - align   Á¤·Ä       (middle)
 *     - quality È­Áú       (high)
 *     - bgcolor ¹é±×¶ó¿îµå (#FFFFFF)
 *     - wmode   Åõ¸íµµ     (window)
 */
function jsViewFlash(strUrl, strProps) {
    var aryPropList = jsParseProperty(strProps, ",");
    var strHtml     = "";
    var strType     = "";

    if (jsIsIE()) {
         strType = "classid='clsid:D27CDB6E-AE6D-11CF-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'";
    }
    else {
         strType = "type='application/x-shockwave-flash'";
    }

    strHtml += "<object " + strType + " data='" + strUrl + "' width='" + aryPropList.get("width", "100%") + "' height='" + aryPropList.get("height", "100%") + "' align='" + aryPropList.get("align", "middle") + "'>" + "\n";
    strHtml += "    <param name='movie'             value='" + strUrl                                + "'>" + "\n";
    strHtml += "    <param name='quality'           value='" + aryPropList.get("quality", "high")    + "'>" + "\n";
    strHtml += "    <param name='bgcolor'           value='" + aryPropList.get("bgcolor", "#FFFFFF") + "'>" + "\n";
    strHtml += "    <param name='wmode'             value='" + aryPropList.get("wmode"  , "window")  + "'>" + "\n";
    strHtml += "    <param name='allowScriptAccess' value='always'>                                       " + "\n";
    strHtml += "</object>                                                                                 " + "\n";

    document.write(strHtml);
}


//------------------------------------------------------------------------------
// ·¹ÀÌ¾î »ý¼º
//------------------------------------------------------------------------------
/***
 * @function
 *     jsCreateLayer(strID, strSrc, blnIsFile)
 * @param
 *     strId     ¿¤¸®¸ÕÆ® ID
 *     strSrc    ÄÁÅÙÃ÷ ¼Ò½º
 *     blnIsFile ÄÁÅÙÃ÷(ÆÄÀÏ/ÅØ½ºÆ®) ÆÇ´Ü ³í¸®°ª
 * @return
 *     ·¹ÀÌ¾î(IFrame) ¿¤¸®¸ÕÆ®
 * @description
 *     select¿Í °ãÄ¡´Â ¹®Á¦¶§¹®¿¡ IFrameÀ¸·Î ·¹ÀÌ¾î¸¦ ±¸¼º
 */
function jsCreateLayer(strId, strSrc, blnIsFile) {
    var objLayer = document.getElementById(strId);

    if (objLayer == null) {
        objLayer = document.createElement("iframe");

        objLayer.id             = strId;
        objLayer.frameBorder    = 0;
        objLayer.style.display  = "none";
        objLayer.style.position = "absolute";

        document.body.appendChild(objLayer);

        if (blnIsFile) {
            objLayer.src = strSrc;
        }
        else {
            objLayer.contentWindow.document.open();
            objLayer.contentWindow.document.write(strSrc);
            objLayer.contentWindow.document.close();
        }
    }

    return objLayer;
}


//==============================================================================
// ÀÌº¥Æ® °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// À©µµ¿ì ÀÌº¥Æ® Ãß°¡
//------------------------------------------------------------------------------
/***
 * @function
 *     jsAttachEvent(strEvent, objFunc)
 * @param
 *     strEvent ÀÌº¥Æ®¸í
 *     objFunc  ½ÇÇàÇÔ¼ö
 */
function jsAttachEvent(strEvent, objFunc) {
    if (/^on/i.test(strEvent)) strEvent = strEvent.substring(2);

    if (window.addEventListener) {
        window.addEventListener(strEvent, objFunc, false);
    }
    else {
        window.attachEvent("on" + strEvent, objFunc);
    }
}


//==============================================================================
// AJAX °ü·Ã
//==============================================================================
//------------------------------------------------------------------------------
// XMLHTTP °´Ã¼ »ý¼º
//------------------------------------------------------------------------------
/***
 * @function
 *     jsCreateXMLHTTP()
 * @return
 *     XMLHTTP °´Ã¼
 * @description
 *     Å×½ºÆ®¿ëÀ¸·Î¸¸ »ç¿ëÇÏ°í, ½Ç »õ¹ß½Ã¿¡´Â »ç¿ëÇÏÁö ¾Ê´Â´Ù.
 */
function jsCreateXMLHTTP() {
    var objReq = false;

    if (window.XMLHttpRequest) {
        try {
            objReq = new XMLHttpRequest();
        }
        catch (e) {
            objReq = false;
        }
    }
    else if (window.ActiveXObject) {
        try {
            objReq = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                objReq = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                objReq = false;
            }
        }
    }

    return objReq;
}


//------------------------------------------------------------------------------
// ÆÄÀÏ ³»¿ë ÃßÃâ
//------------------------------------------------------------------------------
/***
 * @function
 *     jsGetSource(strUrl)
 * @use
 *     jsIsIE()
 *     jsCreateXMLHTTP()
 * @param
 *     i_url ÆÄÀÏ°æ·Î
 * @return
 *     XML°´Ã¼ ¶Ç´Â ÆÄÀÏÀÇ ³»¿ë
 * @description
 *     ´ë»ó ÆÄÀÏÀÇ Çü½ÄÀÌ UTF-8 Çü½ÄÀÌ¾î¾ß Á¤»óÀûÀ¸·Î ÀÛµ¿
 *     Å×½ºÆ®¿ëÀ¸·Î¸¸ »ç¿ëÇÏ°í, ½Ç °³¹ß½Ã¿¡´Â »ç¿ëÇÏÁö ¾Ê´Â´Ù.
 * @TODO
 *     onreadystatechange ±¸Çö
 */
function jsGetSource(strUrl) {
    var objSrc = null;
    var objReq = jsCreateXMLHTTP();
    var strExt = strUrl.substring(strUrl.lastIndexOf(".") + 1).toLowerCase();

    try {
        objReq.open("Get", strUrl, false);
        objReq.send(null);

        switch (strExt) {
            case "xml":
                objSrc = objReq.responseXML;

                if ((objSrc.hasChildNodes == false) && jsIsIE()) {
                    objSrc = new ActiveXObject("Microsoft.XMLDOM");
                    objSrc.load(strUrl);
                }
                break;

            default:
                objSrc = objReq.responseText;
        }
    }
    catch (e) {
        objSrc = "<strong style='color:#FF0000;'>Get_Source::" + e.message + "</strong>";
    }

    return objSrc;
}


//------------------------------------------------------------------------------
// ÆÄÀÏ ÀÎÅ¬·çµå
//------------------------------------------------------------------------------
/***
 * @function
 *     jsIncludeFile(strUrl, strId)
 * @use
 *     jsGetSource(strUrl)
 * @param
 *     strUrl ÆÄÀÏ°æ·Î
 *     strId  ¿¤¸®¸ÕÆ® ID
 * @description
 *     ´ë»ó ÆÄÀÏÀÇ Çü½ÄÀÌ UTF-8 Çü½ÄÀÌ¾î¾ß Á¤»óÀûÀ¸·Î ÀÛµ¿
 *     Å×½ºÆ®¿ëÀ¸·Î¸¸ »ç¿ëÇÏ°í, ½Ç °³¹ß½Ã¿¡´Â »ç¿ëÇÏÁö ¾Ê´Â´Ù.
 */
function jsIncludeFile(strUrl, strId) {
    var strSrc = jsGetSource(strUrl);
    var objEle = document.getElementById(strId);

    if (objEle) {
        objEle.innerHTML = strSrc;
    }
    else {
        document.write(strSrc);
    }
}

function jsFileCheck(obj) {

    // ¼±ÅÃÆÄÀÏÀÇ °æ·Î¸¦ ºÐ¸®ÇÏ¿© È®ÀåÀÚ¸¦ ±¸ÇÕ´Ï´Ù.
    PathPoint = obj.lastIndexOf('.');
    FilePoint = obj.substring(PathPoint+1,obj.length);
    ext = FilePoint.toLowerCase();

    // È®ÀåÀÚ°¡ ÀÌ¹ÌÁö ÆÄÀÏÀÌ¸é photo¿¡ º¸¿©ÁÝ´Ï´Ù.
    if((ext == 'zip') || (ext == 'jpg') || (ext == 'gif') || (ext == 'txt') || (ext == 'doc') || (ext == 'pdf') || (ext == 'hwp') || (ext == 'xls') || (ext == 'ppt') || (ext == 'pptx') || (ext == 'xlsx'))
        return true;
    else
    {
        alert("¹®¼­ ¹× ÀÌ¹ÌÁö ÆÄÀÏ¸¸ ¾÷·Îµå °¡´ÉÇÕ´Ï´Ù.");
        return false;
    }
}

function jsImgExtCheck(strText) {
    // ¼±ÅÃÆÄÀÏÀÇ °æ·Î¸¦ ºÐ¸®ÇÏ¿© È®ÀåÀÚ¸¦ ±¸ÇÕ´Ï´Ù.
    PathPoint = strText.lastIndexOf('.');
    FilePoint = strText.substring(PathPoint+1,strText.length);
    ext = FilePoint.toLowerCase();

    // È®ÀåÀÚ°¡ ÀÌ¹ÌÁö ÆÄÀÏÀÌ¸é photo¿¡ º¸¿©ÁÝ´Ï´Ù.
    if((ext == 'jpg') || (ext == 'gif'))
        return true;
    else
        return false;
}
