

/**
 * ÆË¾÷ À©µµ¿ì¿¡ ´ëÇØ¼­ °ü¸®ÇÏ´Â ÀÚ¹Ù½ºÅ©¸³Æ®
 *
 * @version	2003-12-16
 * @author	namjinpark
 * @constructor
 */
function WindowUtil() {
	this.im_oWindowList = new Array();
	
	this.openAtCenter = openAtCenter_WindowUtil;
	this.showDialog = showDialog_WindowUtil;
	this.handleUnload = handleUnload_WindowUtil;
}


/**
 * ÇöÀç½ºÅ©¸³Æ® Æ÷ÇÔÇÏ´Â Window°¡ ´Ù¸¥ ÆäÀÌÁö·Î ÀÌµ¿, F5¸¦ ÅëÇØ¼­ ÀÌµ¿µÇ°Å³ª ¶Ç´Â
 * Ã¢ÀÌ´ÝÈ÷´Â °æ¿ìÀÇ onunload event ¸¦ Ã³¸®ÇÏ°Ô µÈ´Ù. <BR>
 * onunload = lm_oWindowUtil.handleUnload; °¡ ¼³Á¤µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. <BR>
 * Ã³¸®°¡ Àß µÇÁö ¾Ê´Â´Ù. 
 */
function handleUnload_WindowUtil() {
	//alert(this.im_oWindowList);
	//alert(this.im_oWindowList.length);
	for (var i in this.im_oWindowList) {
		if (this.im_oWindowList[i] != null) {
			//alert(this.im_oWindowList[i].name);
			if(this.im_oWindowList[i].closed == false) this.im_oWindowList[i].close();
		}	
	}
}

/**
 * ÆË¾÷ À©µµ¿ì¸¦ È­¸é Áß¾Ó¿¡ Ç¥½ÃÇÑ´Ù.
 *
 * @param	pm_sUrl	ÀÌµ¿ÇÒ URL
 * @param	pm_sEnv	ÆË¾÷ À©µµ¿ì È¯°æ º¯¼ö °ª (width, height, left, top, screenX, screenY ´Â Á¦¿ÜÇÑ ³ª¸ÓÁö ¼³Á¤°ª)
 * @param	pm_iWidth	ÆË¾÷ À©µµ¿ì width
 * @param	pm_iHeight	ÆË¾÷ À©µµ¿ì height
 * @param	pm_sWinName	ÆË¾÷ À©µµ¿ì ÀÌ¸§
 * @return	PopUp Window Handler
 */
function openAtCenter_WindowUtil(pm_sUrl, pm_sEnv, pm_iWidth, pm_iHeight, pm_sWinName) {
	// URL ÀÌ ¾ø´Â °æ¿ì null °ªÀ» ¸®ÅÏÇÑ´Ù.
	if(pm_sUrl == null) {
		return null;
	}
	
	var lm_sWinName = "xeip_popup";
	var lm_iXPosition = (window.screen.width / 2);
	var lm_iYPosition = (window.screen.height / 2);
	// ÇöÀç À©µµ¿ìÀÇ width
	var lm_iWidth = window.outerWidth;
	// ÇöÀç À©µµ¿ìÀÇ height
	var lm_iHeight = window.outerHeight;
	// PopUp À©µµ¿ì È¯°æ º¯¼ö °ª
	var lm_sEnv = "";
	
	// Window ÀÌ¸§À» Àü´Þ¹ÞÀº °æ¿ì
	if(pm_sWinName != null) {
		lm_sWinName = pm_sWinName;
	}
	
	// windowÀÇ width¸¦ Àü´Þ ¹ÞÀº °æ¿ì
	if(pm_iWidth != null) {
		lm_iWidth = pm_iWidth;
	}
	
	// windowÀÇ heightÀ» Àü´Þ ¹ÞÀº °æ¿ì
	if(pm_iHeight != null) {
		lm_iHeight = pm_iHeight;
	}
	
	lm_iXPosition = (window.screen.width / 2) - (lm_iWidth / 2 + 10);
	lm_iYPosition = (window.screen.height / 2) - (lm_iHeight / 2 + 20);
	lm_sEnv = "width=" + pm_iWidth + ", height=" + pm_iHeight +", ";
	lm_sEnv = lm_sEnv + "left=" + lm_iXPosition + ",top=" + lm_iYPosition + ",screenX=" + lm_iXPosition + ",screenY=" + lm_iYPosition + ", ";
	// windowÀÇ È¯°æ º¯¼ö °ªÀ» Àü´Þ ¹ÞÀº °æ¿ì
	if(pm_sEnv != null) {
		lm_sEnv += pm_sEnv;
	}
	
	var lm_oWinHandle = window.open(pm_sUrl, lm_sWinName, lm_sEnv);
	lm_oWinHandle.focus();
	this.im_oWindowList[lm_sWinName] = lm_oWinHandle;
    return lm_oWinHandle;
}

/**
 * ModalDialog ¶Ç´Â ModelessDialog¸¦ È­¸é Áß¾Ó¿¡ Ç¥½ÃÇÑ´Ù.
 *
 * @param	pm_sUrl			ÀÌµ¿ÇÒ URL
 * @param	pm_oArguments	ModalDialog¿¡ ³Ñ¾î°¡´Â Argument °´Ã¼ °ª
 * @param	pm_sEnv			ÆË¾÷ À©µµ¿ì È¯°æ º¯¼ö °ª (dialogWidth, dialogHeight, dialogTop, dialogLeft, center ¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö °ª)
 * @param	pm_iWidth		ÆË¾÷ À©µµ¿ì width
 * @param	pm_iHeight		ÆË¾÷ À©µµ¿ì height
 * @param	pm_bModeless	Modeless Dialog Ãâ·Â ÇÃ·¡±× (true ÀÌ¸é Modeless Dialog Ãâ·Â)
 * @return	ModalDialog ÀÇ returnValue
 */
function showDialog_WindowUtil(pm_sUrl, pm_oArguments, pm_sEnv, pm_iWidth, pm_iHeight, pm_bModeless) {
	var lm_sEnv = "";
	var lm_sBasicEnv = "status:no; scroll:no; ";
	lm_sEnv += " dialogWidth:" + pm_iWidth + "px;";
	lm_sEnv += " dialogHeight:" + pm_iHeight + "px;";
	lm_sEnv += " center=yes; ";
	
	if(pm_sEnv == null && pm_sEnv == "") lm_sEnv += lm_sBasicEnv;
	else lm_sEnv += pm_sEnv;
	
	var lm_oReturn = null;
	if(pm_bModeless == true) lm_oReturn = window.showModelessDialog(pm_sUrl, pm_oArguments, lm_sEnv);
	else lm_oReturn = window.showModalDialog(pm_sUrl, pm_oArguments, lm_sEnv);
	
	return lm_oReturn;
}



//==================================================================
// ÇöÀçÀÏÀÚ¸¦ °¡Á®¿À´Â ÇÔ¼ö
// Argument : N/A
// return = yyyymmdd
//==================================================================
function gfn_GetDate() {
  currdate = new Date();

  var tmpyy  = currdate.getYear();
  var ls_yy  = (tmpyy > 99)  ? tmpyy : 1900 + tmpyy;

  var tmpmon = currdate.getMonth();
  var ls_mon = (tmpmon < 9)  ? "0" + (tmpmon + 1) : tmpmon + 1 ;

  var tmpday = currdate.getDate();
  var ls_day = (tmpday < 10) ? "0" + tmpday : tmpday ;

  return ls_yy.toString() + ls_mon.toString() + ls_day.toString() ;
}
//==================================================================
// ±âÁØÀÏÀÚ¿ÍÀÇ Â÷ÀÌÀÏÀÚ¸¦ °è»êÇÏ´Â ÇÔ¼ö
// Argument : sdate : ±âÁØÀÏÀÚ (string : yyyymmdd)
//            sdiff : Â÷ÀÌ (init)
//            stype : °è»êÇü½Ä (Y:Year  M:Month  D:Date)
// return = yyyymmdd
//==================================================================
function gfn_DiffDate(sdate, sdiff, stype) {
  var tyy = sdate.substring(0,4);
  var tmm = sdate.substring(4,6) - 1;
  var tdd = sdate.substring(6,8);

  currdate = new Date(tyy,tmm,tdd);

  switch (stype) {
  case "Y" : diffdate = new Date(currdate.getYear() + sdiff,currdate.getMonth(),currdate.getDate()); break;
  case "M" : diffdate = new Date(currdate.getYear(),currdate.getMonth() + sdiff,currdate.getDate()); break;
  default  : diffdate = new Date(currdate.getYear(),currdate.getMonth(),currdate.getDate() + sdiff); break;
  }

  var tmpyy = diffdate.getYear();
  var ls_yy = (tmpyy > 99) ? tmpyy : 1900 + tmpyy;

  var tmpmm = diffdate.getMonth();
  var ls_mm = (tmpmm < 9)  ? "0" + (tmpmm + 1) : tmpmm + 1;

  var tmpdd = diffdate.getDate();
  var ls_dd = (tmpdd < 10) ? "0" + tmpdd : tmpdd;

  return ls_yy.toString() + ls_mm.toString() + ls_dd.toString() ;
}

//==============================================================================
//   1. Function  ¸í : pop_calendar
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ´Þ·ÂÀ» È£ÃâÇÑ´Ù.
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function pop_calendar(objname) {
  var result = "";
  var firstList = new Array();

  var prop = "dialogWidth:572px; dialogHeight:270px;dialogLeft:400px; dialogTop:200px;status:no;";
  result = window.showModalDialog("/js/calendar3.jsp?", "´Þ·Â", prop);

  if (result==-1 || result==null || result=="") return;
  eval(objname).Text=result;
}

//==============================================================================
//   1. Function  ¸í : gn_DownExcel_data
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¿¢¼¿ ´Ù¿î·Îµå ½ÇÇà 
//                     i_grid   => Grid Name      i_filenm => file Name
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_DownExcel_data(i_grid, i_filenm){


	var gb_Html = "/js/excel.html";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:240px; dialogHeight:140px; status:no");

	//if (typeof(result) == undefined) return;

 
	if (result == 1) {
		i_grid.SaveExcel(i_filenm, true, true, true, i_filenm);
	} else if(result == 2) {
		i_grid.ExportFileEx(i_filenm, true, 0, false);
	} else  if(result == 3) {
		i_grid.RunExcel(i_filenm);
	}
}

//==============================================================================
//   1. Function  ¸í : gn_Find_User
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : »ç¿ëÀÚ Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_User(){

	var gb_Html = "/js/find_user.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:440px; dialogHeight:550px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}

//==============================================================================
//   1. Function  ¸í : gn_Find_Clcode
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¿µÀ§¾÷Á¾ Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Clcode(){

	var gb_Html = "/js/find_clcode.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Clcode_01
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¿µÀ§¾÷Á¾(4ÀÚ¸®) Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Clcode_01(){

	var gb_Html = "/js/find_clcode_01.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Clcode_02
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¿µÀ§¾÷Á¾(3ÀÚ¸®) Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Clcode_02(){

	var gb_Html = "/js/find_clcode_02.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Egcode
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¼Ò¼ÓÁý´Ü Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Egcode(){

	var gb_Html = "/js/find_egcode.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Fbcode
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¼³¸³±Ù°Å Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Fbcode(){

	var gb_Html = "/js/find_fbcode.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Deptcode
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ¼Ò°üºÎ¼­ Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Deptcode(){

	var gb_Html = "/js/find_deptcode.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Deptcode
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : »óÀ§ºÎ¼­ Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Deptcode1(){

	var gb_Html = "/js/find_deptcode1.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}
//==============================================================================
//   1. Function  ¸í : gn_Find_Ofcode
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ÁÖ¹«°üÃ» Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Ofcode(){

	var gb_Html = "/js/find_ofcode.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}

//==============================================================================
//   1. Function  ¸í : gn_Find_Etname
//   2. ÀÛ   ¼º   ÀÏ : 2005-9-21
//   3. Function¼³¸í : ±â¾÷¸í/¹ýÀÎ¹øÈ£(enseq) Ã£±â
//                     i_grid   => »ç¿ëÀÚ ID
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function gn_Find_Etname(){

	var gb_Html = "/js/find_etname.jsp";
	var i_data = "";

	var result = window.showModalDialog(gb_Html, i_data, "dialogWidth:465px; dialogHeight:500px; status:no");

	if (typeof(result) == undefined) return false;
	
	return result;
}


/* arp.js : a function for MS IE ActiveX Rollup Patch */
//==============================================================================
//   1. Function  ¸í : __WS__
//   2. ÀÛ   ¼º   ÀÏ : 2006-02-10   ÃµÀç¼ö
//   3. Function¼³¸í : IE ÆÐÄ¡¿¡ µû¸¥ ActiveX ÄÚµùÃß°¡ºÐ......
//   4. ¼ö Á¤  ³» ¿ª :
//==============================================================================
function __WS__(id)
{
    document.write(id.innerHTML); id.id = "";
}