/* ¾îÇÃ¸®ÄÉÀÌ¼Ç ÄÁÅØ½ºÆ® ÀÌ¸§ */
var CONTEXT_NAME; 

function getContextName(){
    // TODO cookie¸¦ ¾È¾µ °æ¿ì¿£ ¹«Á¶°Ç °ªÀÌ "" ÀÌ µÇ¾î ¹ö¸².
    if (CONTEXT_NAME == null){
    	CONTEXT_NAME = getCookie("j_context_name");
    }
    return CONTEXT_NAME;
}

/**
 * ³¯Â¥¸¦ ¼±ÅÃÇÒ ¼ö ÀÖ´Â ¸ð´Þ ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 *
 * @param field ³¯Â¥°¡ ÀÔ·ÂµÉ ÇÊµå
 */
function getDate(field) {
    var url = getContextName() + "/popup/DatePopup.jsp";
    var ws = formatWindowProperty(200, 100, 250, 230);

    /* IE */
    if (window.showModalDialog) {
        var dt = showModalDialog(url, window, ws);
        if (dt != null) {
            if (dt.year == "") {
                field.value = "";
            } else {
                field.value = dt.year + "-" + dt.month + "-" + dt.day;
            }
        }
    } else {
        url += "?formName=" + field.form.getAttribute("name") + "&fieldName=" + field.name;
        window.open(url, null, ws);
    }
}

/**
 * ¼ø¼­¸¦ º¯°æÇÒ ¼ö ÀÖ´Â ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 *
 * @param getStatement ´ë»ó ¸®½ºÆ®¸¦ °¡Á®¿À´Â Äõ¸® ¾ÆÀÌµð
 * @param updateStatement ¼ø¼­¸¦ º¯°æÇÏ´Â Äõ¸® ¾ÆÀÌµð
 * @param query ±âÅ¸ ÆÄ¶ó¹ÌÅÍ·Î JParam °´Ã¼¸¦ ´ã°í ÀÖ´Â ¹è¿­ 
 */
function openOrderPopup(getStatement, updateStatement, query) {
    var url = getContextName() + "/popup/OrderPopup.jsp?getStatement=" + getStatement + "&updateStatement=" + updateStatement;
    var ws = formatWindowProperty1(166, 129, 310, 280);

	if (query) {
		for (var i = 0; i < query.length; i++) {
			url = url + "&" + query[i].name + "=" + query[i].value;
		}
	}
    window.open(url, null, ws);
}

/**
 * µµ¿ò¸» ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * 
 * @param context ÇöÀç º¸°í ÀÖ´Â ¾÷¹« È­¸éÀÇ URL
 */
function openHelpPopup(context) {
    var url = getContextName() + "/popup/HelpPopup.jsp?context=" + context;
    var ws = formatWindowProperty1(166, 129, 700, 500);
    window.open(url, null, ws);
}

/**
 * ÄÚµå ¸®½ºÆ® ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * 
 * @param id ÄÚµå ¾ÆÀÌµð°¡ ÀÔ·ÂµÉ ÇÊµå
 * @param name ÄÚµå ÀÌ¸§ÀÌ ÀÔ·ÂµÉ ÇÊµå
 * @param code ÄÚµå
 * @param selector ¼±ÅÃÀÚ
 */
function openCodePopup(id, name, code, selector) {
    var url = getContextName() + "/popup/CodePopup.jsp?q_targetId=" + id.name + "&q_targetName=" + name.name + "&q_code=" + code;
    if (selector) {
        url += "&q_selector=" + selector;
    }
    var ws = formatWindowProperty1(166, 129, 600, 500);
    window.open(url, null, ws);
}

/**
 * ¼­¹ö ÀÎ½ºÅÏ½º ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * 
 * @param interface ÄÄÆ÷³ÍÆ® ÀÎÅÍÆäÀÌ½º
 * @param moduleId ÄÄÆ÷³ÍÆ® ¸ðµâ ¾ÆÀÌµð
 */
function openInstancePopup(interfaceName, moduleId) {
    var url = getContextName() + "/RefreshComponent.do?c_interface=" + interfaceName + "&moduleId=" + moduleId;
    var ws = formatWindowProperty1(166, 129, 400, 300);
    window.open(url, null, ws);
}

/**
 * ÁÖ¼Ò ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * 
 * @param post ¿ìÆí º»È£°¡ ÀÔ·ÂµÉ ÇÊµå
 * @param address ÁÖ¼Ò°¡ ÀÔ·ÂµÉ ÇÊµå
 */
function openZipCodePopup(post, address) {
    var url = getContextName() + "/ep/user/userZipPopupList.jsp?q_targetPost=" + post.name + "&q_targetAddress=" + address.name;
    var ws = formatWindowProperty1(166, 129, 414, 462);
    window.open(url, null, ws);
}

/**
 * Å×ÀÌºí Çü½ÄÀÇ Á¶Á÷ ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * 
 * @param id Á¶Á÷ ¾ÆÀÌµð°¡ ÀÔ·ÂµÉ ÇÊµå
 * @param name Á¶Á÷ ÀÌ¸§ÀÌ ÀÔ·ÂµÉ ÇÊµå
 */
function openOrgPopup(id, name) {
    var url = getContextName() + "/popup/OrgPopup.jsp?q_targetId=" + id.name + "&q_targetName=" + name.name;
    var ws = formatWindowProperty1(166, 129, 550, 450);
    window.open(url, null, ws);
}

/**
 * Æ®¸® Çü½ÄÀÇ Á¶Á÷ ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * 
 * @param id Á¶Á÷ ¾ÆÀÌµð°¡ ÀÔ·ÂµÉ ÇÊµå
 * @param name Á¶Á÷ ÀÌ¸§ÀÌ ÀÔ·ÂµÉ ÇÊµå
 */
function openOrgTreePopup(id, name) {
    var url = getContextName() + "/popup/OrgTreePopup.jsp?q_targetId=" + id.name + "&q_targetName=" + name.name;
    var ws = formatWindowProperty1(166, 129, 500, 450);
    window.open(url, null, ws);
}

/**
 * Á¶Á÷ º° »ç¿ëÀÚ ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * @param id »ç¿ëÀÚ ¾ÆÀÌµð°¡ ÀÔ·ÂµÉ ÇÊµå
 * @param name »ç¿ëÀÚ ÀÌ¸§ÀÌ ÀÔ·ÂµÉ ÇÊµå
 */ 
function openOrgUserPopup(id, name) {
    var url = getContextName() + "/popup/OrgUserPopup.jsp?q_targetId=" + id.name + "&q_targetName=" + name.name;
    var ws = formatWindowProperty1(166, 129, 600, 320);
    window.open(url, null, ws);
}

/**
 * »ç¿ëÀÚ ÆË¾÷ È­¸é Ã¢À» ¿¬´Ù.
 * @param params ÆÄ¶ó¹ÌÅÍ
 */
function openUserPopup(params) {
    var url = getContextName() + "/popup/UserPopup.jsp?" + params;
    var ws = formatWindowProperty1(166, 129, 540, 450);
    window.open(url, null, ws);
}

/**
 * ºñ¹Ð¹øÈ£ ¼öÁ¤ È­¸é Ã¢À» ¿¬´Ù.
 */
function openChangePasswordPopup(context) {
    var url = getContextName() + "/popup/ChangePasswordPopup.jsp";
    var ws = formatWindowProperty1(166, 129, 400, 200);
    window.open(url, null, ws);
}

function formatWindowProperty(left, top, width, height) {
    if (window.showModalDialog) {
        return "status:no; dialogLeft:" + left + "px; dialogTop:" + top + "px; dialogWidth:" + width + "px; dialogHeight:" + height + "px";
    } else {
        return "modal, left=" + left + "px, top=" + top + ", width=" + width + "px, height=" + height + "px";
    }
}

function formatWindowProperty1(left, top, width, height) {
    return "left=" + left + ", top=" + top + ", width=" + width + ", height=" + height;
}

function JParam(name, value) {
	this.name = name;
	this.value = value;
}

/**
*
* IP ¾÷¹«¸¦ À§ÇÑ »ý¼º script.
*
**/


/**
 * ½ºÅ©·¦ ¸ñ·Ï ÆË¾÷Ã¢À» ¶ç¿ò.
 *
 * @param 
 * @param 
 */
function openScrpPopup(boardId,dataNo,dataType) {
    
    var url = '/mypage/ipScrpMpgPopup.jsp?boardId='+boardId+'&dataNo='+dataNo+'&dataType='+dataType;
    var ws = formatWindowProperty1(166, 129, 415, 340);
		 ws = ws + ", resizable=no, scrollbars=yes" ;

    window.open(url, null, ws);
}


/**
 * Áöµµ ÀÌ¹ÌÁö¸¦ ½ºÅ©·¦ ÇÔ
 *
 * @param 
 * @param 
 */
function openScrpMapPopup(boardId,dataNo,dataType) {
    
    var url = '/mypage/ipScrpMapPopup.jsp?boardId='+boardId+'&dataNo='+dataNo+'&dataType='+dataType;
    var ws = formatWindowProperty1(166, 129, 415, 340);
	     ws = ws + ", resizable=no, scrollbars=yes" ;
        	
    window.open(url, null, ws);
}
