/***************************************************
	°øÅë javaScript : portal.js
***************************************************/

/*
 * portal.js ÆÄÀÏ ÃÊ±âÈ­½Ã ÀÛ¾÷
 *
 *  1. Æ÷Å» ÆäÀÌÁö IFrame Ã¢»çÀÌÁî Á¶Àý
 *  2.
 */



/*
 * »õÃ¢Ã³¸®
 */
function OpenWindow(goURL, w, h)
{
  //var w       = w;
  //var h       = h;
    var l       = ( screen.availWidth  - w ) / 2;
    var t       = ( screen.availHeight - h ) / 4;
  //var goURL   = goURL;
    var winType = "width="+w+",height="+h+",left="+l+",top="+t+",scrollbars=yes, resizable=no, menubar=no, status=no";
    var openWin = window.open(goURL, "Çö´ëÇØ»óÈ­Àçº¸Çè(ÁÖ)", winType);
}



/***************************************************
	µµ¿ò¸» ¸Þ½ÃÁöÃ³¸®
***************************************************/
function HelpMessage(helpID)
{
    var w = 400;
    var h = 500;
    var l       = _getLeft(w);
    var t       = _getTop(h);
    var goURL   = "http://hiweb.hi.co.kr/servlet/hdmf.portal.help.servlet.GetHelp_Message?HELPID="+helpID;
    var winType = "width="+w+",height="+h+",top="+t+",left="+l+" status=yes, menu=yes, scrollbars=yes";
	var openWin = window.open(goURL,"help", winType);

}


/***************************************************
	µµ¿ò¸» DIALOG ¸Þ½ÃÁö Ç¥½Ã
***************************************************/
//µµ¿ò¸» Dialog°ü¸® °´Ã¼
var _openDialog = null;

function helpDialog() {
    var sFeatures = "dialogHeight: 105px; dialogWidth: 350px; dialogTop: 150px; dialogLeft: 500px; edge: Raised; center: No; help: No; resizable: No; status: No;";
	_openDialog = window.showModelessDialog("/help/helpDialog.html", "helpDialog", sFeatures);

}

function setHelpDialog(msg)
{
    if(_openDialog != null && !_openDialog.closed) {
        _openDialog.helpMessage.value = msg;
    }
}

/***************************************************
	ÇÁ·¹ÀÓ¸íÀ¸·Î ÆäÀÌÁö ¸®·Îµå
***************************************************/
function reloadPage(frmName) {

    var tempFrame =  _findFrameByName(frmName);

    if(tempFrame == null) {
        alert("ÇØ´ç ÇÁ·¹ÀÓ ["+frmName+"] °¡ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù!");
        return;
    }

    //ÇÁ·¹ÀÓ ¸®·Îµå
    tempFrame.location.reload();
}


/***************************************************************************
	È­¸é·Îµù »ý¼º ½ºÅ©¸³Æ®

	@param  frameName   ¸Þ½ÃÁöÃâ·Â ÇÁ·¹ÀÓ¸í
	@param  msg         Ãâ·ÂÇÒ ¸Þ½ÃÁö
	@param  showTime    ¸Þ½ÃÁö Ãâ·ÂÈÄ showTime ÃÊ°¡ Áö³­ÈÄ ÇØ´çÆäÀÌÁö°¡
	                    Á¤È®È÷ ·ÎµùµÇÁö ¾ÊÀ¸¸é ÇØ´ç ÇÁ·¹ÀÓ CLEAR ½ÃÅ²´Ù.
***************************************************************************/
//Ç¥½ÃÇÒ È­¸éÀÇ ÇÁ·¡ÀÓ°´Ã¼
var frameObj = null;

function loadProgress(frameName, msg, showTime)
{
    //alert("start");
    if (frameName==null || frameName.length == 0) { alert("FRAME °´Ã¼ ÄÚµù ¿À·ù ! ( Frame Name Ã¼Å©ÇÏ¼¼¿ä!)");  return false; }
    //±âº»¸Þ½ÃÁö
    if (msg==null || msg.length == 0) { msg = "È­¸éÀ» ´Ù¿î·Îµå ÁßÀÔ´Ï´Ù.<br>Àá½Ã¸¸ ±â´Ù·ÁÁÖ¼¼¿ä..."; }


	//ÇÁ·¹ÀÓ °´Ã¼ ÃÊ±âÈ­
	frameObj = _findFrameByName(frameName);

	if(frameObj != null) {

        //¸Þ½ÃÁöÃâ·Â
        if(_showProgressMsg(frameObj, msg) && showTime != null && showTime > 0) {
           //showTimeÈÄ ¸Þ½ÃÁö »èÁ¦!!
           setTimeout('_clearProgressMsg()', showTime*1000);
        }

    } else {
        alert(frameName+" frame ÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
    }//°´Ã¼¾øÀ¸¸é ¹«½Ã


}


/***************************************************
	ÀÌ¸§À¸·Î ÇØ´ç ÇÁ·¹ÀÓ °´Ã¼ O±â
***************************************************/
function _findFrameByName(frameName) {

    var Progress = null; //frame°´Ã¼
	var i; //index

	//self°´Ã¼¿¡¼­ °Ë»ö
	for( i=0; i<self.frames.length; i++) {

        //frameO±â
    	if(frameName == self.frames[i].name ) {
    	    Progress = self.frames[i];
    	    break;
    	 }
	}

	//°´Ã¼ ¾øÀ¸¸é parent ¿¡¼­ºÎÅÍ °Ë»ö
	for( i=0; Progress == null && i<parent.frames.length; i++) {
	    //frameO±â
    	if(frameName == parent.frames[i].name ) {
    	    Progress = parent.frames[i];
    	    break;
    	}
	}

    //°´Ã¼ ¾øÀ¸¸é top ¿¡¼­ºÎÅÍ °Ë»ö
	for( i=0; Progress == null && i<top.frames.length; i++) {
	    //frameO±â
    	if(frameName == top.frames[i].name ) {
    	    Progress = top.frames[i];
    	    break;
    	}
	}

	return Progress;

}

/***************************************************
	ÇØ´ç ÇÁ·¹ÀÓ¿¡ Ãâ·ÂµÈ ¸Þ½ÃÁö »èÁ¦
***************************************************/
function _clearProgressMsg() {

    if(frameObj != null) {

        //ÇØ´çÇÁ·¹ÀÓÀÇ Á¤»óÀû·ÎµùÀ¯¹« È®ÀÎÈÄ
        //Á¤»óÀûÀÌÁö ¾ÊÀ¸¸é clear
        if(frameObj.document.referrer.length > 0) {
            return false;
        } else {
            frameObj.document.open();
        	frameObj.document.write("<!-- ÆäÀÌÁö¿¡ ¿À·ù°¡ ÀÖ¾î ÇÁ·¹ÀÓÀ» ÃÊ±âÈ­ -->");
        	frameObj.document.close();
    	    return true;
    	}
    }
}

/***************************************************
	ÇØ´ç ÇÁ·¹ÀÓ¿¡ ¸Þ½ÃÁö Ãâ·Â
***************************************************/
function _showProgressMsg(frameName, msg) {
    if(frameName != null) {
        frameName.document.open();
    	frameName.document.write(getPageLoadStr(msg));
    	frameName.document.close();
    	return true;
    } else {
        return false;
    }
}


/***************************************************
	È­¸é·Îµù ¹®ÀÚ¸®ÅÏ
***************************************************/
function getPageLoadStr(inStr) {
    //null°ª È®ÀÎ
    if (inStr==null || inStr.length == 0) { alert("Ãâ·Â ¸Þ½ÃÁö°¡ ¾ø½À´Ï´Ù.");  return false; }

    return "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='5' align='center'>"
          +"<tr height='26'><td>&nbsp;</td></tr>"
          +"<tr height='26'><td align='center'><img src='/images/common/img_loading.gif' border='0'></td></tr>"
          +"<tr height='35' valign='top'><td align='center'><font style={font-size:12px; font-family:±¼¸²,µ¸¿ò,arial;} color='#D82AB0' >"
          +inStr+"</font></td></tr>"
          +"<tr><td>&nbsp;</td></tr></table>";

}



/***************************************************
//	Æû³» °´Ã¼¸®½ºÆ® Ãâ·Â
//	param - form¸í
//	¼³¸í: Æû³» elementsÀÌ¸§ , °ª¹ÝÈ¯
***************************************************/
function formElementsView(frm) {

    if (frm==null) { alert("Form °´Ã¼ ÄÚµù ¿À·ù ! ( Form Name Ã¼Å©ÇÏ¼¼¿ä!)");  return false; }

    var msg = "\n";
    var emptyMsg = "\n";
    var msgCnt =0;
    var emptyCnt = 0;
    var ITEM_CNT = 4; //ÇÑÁÙ¿¡ Ç¥½ÃÇÒ¾ÆÀÌÅÛ¼ö

    for(var i=0; i< frm.elements.length; i++)   {

        var emtName = frm.elements[i].name;
        var emtValue = frm.elements[i].value;

        if(emtValue == null || emtValue.length == 0) {
            emptyMsg = emptyMsg + emtName + "  ";
            if((++emptyCnt%ITEM_CNT) == 0)  emptyMsg = emptyMsg +"\n";
         } else {
            msg = msg+emtName+":"+ emtValue+"  ";
            if((++msgCnt%ITEM_CNT) == 0)  msg = msg +"\n";
         }
    }

    return "FORM NAME: "+frm.name+"\nelements list ("+msgCnt+")"+msg+"\n\n"+"empty list ("+emptyCnt+")"+emptyMsg;
}

/***************************************************
	Æû³» elements¸®½ºÆ® »õÃ¢¿¡ Ãâ·Â
***************************************************/
function frmView(frm) {

    if (frm==null) { alert("Form °´Ã¼ ÄÚµù ¿À·ù ! ( Form Name Ã¼Å©ÇÏ¼¼¿ä!)");  return false; }

    window2 = _windowOpener("", _getOpenWindowName());

    window2.document.write("<html>");
    window2.document.write("<head>");
    window2.document.write("<LINK rel=StyleSheet href='/images/css/popup.css' type='text/css' >");
    window2.document.write("</head>");
    window2.document.write("<body bgcolor=#FFFFFF>");
    window2.document.write("<textarea rows=150 cols=105 style=\"width:100%;\">");
    window2.document.write(formElementsView(frm));
    window2.document.write("</textarea>");
    window2.document.write("</body>");
    window2.document.write("</html>");
}




/***************************************************
	¿ÀÇÂµÈ À©µµ¿ì°´Ã¼ °ü¸®
	param - À©µµ¿ì¸í
	¼³¸í: À©µµ¿ì¸¦ ¿©·¯°³ ¿ÀÇÂÇÒ¶§ °¢ÀÚÀÇ °³Ã¼°ü¸®
	      ¹× À§Ä¡°ü¸® ±¸ºÐ°ªÀº ÀÌ¸§À¸·Î ÇÑ´Ù.
***************************************************/

var OpenWindows = new Array();

//°°ÀºÀÌ¸§À¸·Î ¿­¸°Ã¢À¯¹«È®ÀÎÈÄ ÀÖÀ¸¸é ÇØ´çindex¹ÝÈ¯
//¾øÀ¸¸é ½Å±ÔÃß°¡°ü¸®

function _hasThisWindow(winName) {

    //°°ÀºÀÌ¸§ÀÇ À©µµ¿ì Ã£±â
    //ÀÖÀ¸¸é ÇØ´ç ÀÎµ¦½º
    for(var i=0; i< OpenWindows.length; i++) {

           if(winName.search(OpenWindows[i]) != -1) return i;

    }
    //¾øÀ¸¸é ÀÔ·ÂÈÄ ÇØ´çÀÎµ¦½º°ª
    //pushÈÄ ArrayÀÇ »çÀÌÁî ¹ÝÈ¯ÇÏ¹Ç·Î -1 ÇØ¼­ ÇØ´ç ÀÎµ¦½º¹ÝÈ¯ÇÑ´Ù
    return OpenWindows.push(winName) - 1;
}

/***************************************************
	»ç¿ëÀÚÀÇ Display ÇØ»óµµ¿¡ ¸Â´Â ¿ÀÇÂÀ©µµ¿ì topÀ§Ä¡ÁöÁ¤
	param - À©µµ¿ì³ôÀÌ
***************************************************/
function _getTop(w_height) {
    var w_top = (window.screen.Height / 2) - w_height/2;

    //À©µµ¿ì³ôÀÌ À§Ä¡Á¶Á¤ ÀÛ¾÷
    if(w_top > window.screen.height - w_height) {
        if(w_top < 0)
            w_top = 0;
        else
            w_top -= window.screen.height - w_height;
    }
    return w_top;
}

/***************************************************
	»ç¿ëÀÚÀÇ Display ÇØ»óµµ¿¡ ¸Â´Â ¿ÀÇÂÀ©µµ¿ì leftÀ§Ä¡ÁöÁ¤
	param - À©µµ¿ì³Êºñ
***************************************************/
function _getLeft(w_width) {

    var w_left = (window.screen.width / 2) - w_width/2;

    //À©µµ¿ì³Êºñ À§Ä¡Á¶Á¤ ÀÛ¾÷
    if(w_left > window.screen.width - w_width) {
        if(w_left < 0)
            w_left = 0;
        else
            w_left -= window.screen.width - w_width;
    }

    return w_left;
}
/***************************************************
	ÇØ´ç¼Ò½ºÀÇ ¿ÀÇÂÀ©µµ¿ì ÀÌ¸§¹ÝÈ¯
	ÇüÅÂ: ¼Ò½º¸í+XXX
***************************************************/
function _getOpenWindowName() {
    //Src¸í ¹ÝÈ¯
    var srcName = location.pathname;
    srcName = srcName.substring(srcName.lastIndexOf("/")+1, srcName.lastIndexOf("."));
    return srcName+"WindowOpen";
}

/***************************************************
	ÆÄ¶ó¸ÞÅÍ °ªÀ¸·Î ½ÇÁ¦ À©µµ¿ì¿ÀÇÂÇÏ¿© °´Ã¼ ¹ÝÈ¯
***************************************************/
function _windowOpener(winName, w_width, w_height, w_top, w_left, w_feature) {

    //¿ÀÇÂÀ©µµ¿ì À§Ä¡ÁöÁ¤
    var str = "width="+w_width+",height="+w_height+",top="+ w_top +",left="+ w_left+" ";

    if(w_feature != null && w_feature.length > 0)
        str = w_feature + str;

    return openWindow=window.open("", winName, str+" status=yes, menu=yes, scrollbars=yes ");
}

/***************************************************
	»õÃ¢À¸·Î À©µµ¿ì ¿ÀÇÂ ½ºÅ©¸³Æ®
	param - À©µµ¿ì¸í, À©µµ¿ì¼Ó¼º
	¼³¸í: ±âº»ÀûÀ¸·Î È­¸éÀÇ Áß¾Ó¿¡ ¿ÀÇÂÀ©µµ¿ì À§Ä¡½ÃÅ´
	»ç¿ë¹ý: ½ºÅ©¸³Æ®¿¡¼­
	        //Æû°´Ã¼ÇÒ´ç
	        var frm = document.myform;
	        frm.action = "/dbm/actionJsp.jsp" ;
	        //À©µµ¿ì¿ÀÇÂ ÇÔ¼öÈ£ÃâÇÏ¿© ¿ÀÇÂµÈ À©µµ¿ì ÀÌ¸§À¸·Î submitÇÑ´Ù.
	        //»çÀÌÁî Å©±âÁöÁ¤ÇÒ¶§´Â windowOpenWithSize(winW, winH) »ç¿ë
	        frm.target = windowOpen();
    		frm.submit();
***************************************************/
function windowOpen(winName, w_feature) {

    //¿©·¯Ã¢À» ¿ÀÇÂÇÒ¶§ Ã¢À§Ä¡ÀÌµ¿ Å©±âÁ¤ÀÇ
    var w_increment = 30;
    var w_width = 860;
    var w_height = 600;

    //±âº»À©µµ¿ì¸í¼³Á¤
    if(winName == null || winName == "") winName = _getOpenWindowName();

    w_increment *= _hasThisWindow(winName);

    //¿ÀÇÂÀ©µµ¿ì À§Ä¡ÁöÁ¤
    var w_top = _getTop(w_height) + w_increment;
    var w_left = _getLeft(w_width) + w_increment;

    return _windowOpener(winName, w_width, w_height, w_top, w_left, w_feature).name;
}



/***************************************************
	»õÃ¢À¸·Î À©µµ¿ì ¿ÀÇÂ ½ºÅ©¸³Æ®
	param - À©µµ¿ì width, À©µµ¿ì HeightÅ©±âÁöÁ¤, À©µµ¿ì¸í
	¼³¸í: ±âº»ÀûÀ¸·Î È­¸éÀÇ Áß¾Ó¿¡ ¿ÀÇÂÀ©µµ¿ì À§Ä¡½ÃÅ´

	»ç¿ë¹ý: ½ºÅ©¸³Æ®¿¡¼­
	        //Æû°´Ã¼ÇÒ´ç
	        var frm = document.myform;
	        frm.action = "/dbm/actionJsp.jsp" ;
	        //À©µµ¿ì¿ÀÇÂ ÇÔ¼öÈ£ÃâÇÏ¿© ¿ÀÇÂµÈ À©µµ¿ì ÀÌ¸§À¸·Î submitÇÑ´Ù.
	        //»çÀÌÁî Å©±âÁöÁ¤ÇÒ¶§´Â windowOpenWithSize(winWidth, winHeight) »ç¿ë
	        frm.target = windowOpen();
    		frm.submit();
***************************************************/
function windowOpenWithSize(w_width, w_height, winName) {

    //¿©·¯Ã¢À» ¿ÀÇÂÇÒ¶§ Ã¢À§Ä¡ÀÌµ¿ Å©±âÁ¤ÀÇ
    var w_increment = 30;

    if(w_width == null || w_width.length == 0) {
        alert("¿ÀÇÂÃ¢ÀÇ Width°ªÀÌ ¾ø½À´Ï´Ù.");
        return false;
    }

    if(w_height == null || w_height.length == 0) {
        alert("¿ÀÇÂÃ¢ÀÇ Height °ªÀÌ ¾ø½À´Ï´Ù.");
        return false;
    }

    //±âº»À©µµ¿ì¸í¼³Á¤
    if(winName == null || winName == "") winName = _getOpenWindowName();

    w_increment *= _hasThisWindow(winName);

    //¿ÀÇÂÀ©µµ¿ì À§Ä¡ÁöÁ¤
    var w_top = _getTop(w_height) + w_increment;
    var w_left = _getLeft(w_width) + w_increment;

    return _windowOpener(winName, w_width, w_height, w_top, w_left).name;
}

/***************************************************
	»õÃ¢À¸·Î À©µµ¿ì ¿ÀÇÂ ½ºÅ©¸³Æ®
	param - À©µµ¿ì ÀÌµ¿Å©±â, À©µµ¿ì¸í
	¼³¸í: ÆË¾÷À©µµ¿ì¿¡¼­ ´Ù½Ã ÆË¾÷À©µµ¿ì ¿ÀÇÂ½Ã À§Ä¡ÀÌµ¿ÇÏ¿©¿ÀÇÂ
****************************************************/

function windowOpenWithMove(wMove, winName) {

    //¿©·¯Ã¢À» ¿ÀÇÂÇÒ¶§ Ã¢À§Ä¡ÀÌµ¿ Å©±âÁ¤ÀÇ
    var w_increment = 30;
    var w_width = 860;
    var w_height = 600;

    //±âº»À©µµ¿ì¸í¼³Á¤
    if(winName == null || winName == "") winName = _getOpenWindowName();

    if(wMove == null || wMove == "") wMove = 30;

    w_increment *= _hasThisWindow(winName);

    //¿ÀÇÂÀ©µµ¿ì À§Ä¡ÁöÁ¤
    var w_top = _getTop(w_height) + w_increment + wMove;
    var w_left = _getLeft(w_width) + w_increment + wMove;

    return _windowOpener(winName, w_width, w_height, w_top, w_left).name;

}

/*****************************************************
 * Function     : ¸ÞÀÎÆäÀÌÁö¿¡¼­ iframe³» form °ª ÀÌµ¿ Æí¸®ÇÏ°Ô ÇÏ±â À§ÇØ
 * @param       : orgForm      - MAIN_FORM
 *                desForm      - MOVE_FORM(¿ø·¡Æû+ MAIN_FORM)
 * »ç¿ë¹ý       : iframeÆû¸í ifrm
                  main frame Æû¸í main
                  ifrmÀ» main¿¡ »ðÀÔÇÏ¿© Àü¼Û½Ã
                  insertForm(ifrm, main) true¼º°ø falseÀÌµ¿Áß ¿À·ù
***************************************************/
function insertForm(orgForm, desForm) {

    //--- form Á¸Àç À¯¹« È®ÀÎ
    if (orgForm == null || desForm == null) {
        window.alert("Form °´Ã¼ ÄÚµù ¿À·ù ! ( Form Name Ã¼Å©ÇÏ¼¼¿ä!)");
        return false;
    }

    var orginHtml = "";
    var fromHtml = "";

    //¿øº» Æû
    desHtml= getFormValue(desForm);

    //»ðÀÔÇÒ Æû
    orgHtml = getFormValue(orgForm);

    desForm.innerHTML = desHtml+orgHtml;

    return true;
}

/**
 * Function     : ÇØ´çÆû³» ÆÄ¶ó¸ÞÅÍ°ª ¹ÝÈ¯
 * @param       : orgForm      - MAIN_FORM(ÆûÀÌ¸§ ¾Æ´Ô)
 *
 */
function getFormValue(thisFrm) {

    var theHtml = "";

    //--- form Á¸Àç À¯¹« È®ÀÎ
    if (thisFrm == "" ) {
        window.alert("Form °´Ã¼ ÄÚµù ¿À·ù ! ( Form Name Ã¼Å©ÇÏ¼¼¿ä!)");
        return theHtml;
    }

    //--- MOVE_FORMÀÇ ÇÊµå »ý¼º
    var theFieldAll = thisFrm.all.tags("INPUT");
    var theLen = theFieldAll.length;
    for (var i = 0;i < theLen;i++) {
        theField = theFieldAll[i];
        if ((theField.type == "radio") || (theField.type == "checkbox")) {
            if (theField.checked) {
                theHtml = theHtml + "<input type='hidden' name='" + theField.name + "' value='" + theField.value + "'></input><br>";
            }
        } else {
            theHtml = theHtml + "<input type='hidden' name='" + theField.name + "' value='" + theField.value + "'></input><br>";
        }
    }

    var theFieldAll = thisFrm.all.tags("TEXTAREA");
    var theLen = theFieldAll.length;
    for (var i = 0;i < theLen;i++) {
        theField = theFieldAll[i];
        if(theField.value != "") {
            theHtml = theHtml + "<input type='hidden' name='" + theField.name + "' value='" + theField.value + "'></input><br>";
        }
    }

    var theFieldAll = thisFrm.all.tags("SELECT");
    var theLen = theFieldAll.length;
    for (var i = 0;i < theLen;i++) {
        theField = theFieldAll[i];
        for (var j = 0;j < theField.length;j++) {
            if (theField.options[j].selected) {
                theHtml = theHtml + "<input type='hidden' name='" + theField.name + "' value='" + theField.options[j].value + "'></input><br>";
            }
        }
    }

    return theHtml;
}


/********************************************************************************
    Å°Æ÷Ä¿½º ÀÌµ¿ÇÏ±â.... s1°ªÀÇ ±æÀÌ°¡ con ¸¦ ¸¸Á· ÇÏ¸é s2 ·Î Æ÷Ä¿½º¸¦ ÀÌµ¿ ½ÃÅ´´Ù.
	@param  fname           ÆûÀÌ¸§
	@param  s1              submitÇÒ ÇÁ·¹ÀÓ¸í
	@param  s2              Á÷¾÷ÄÚµå
	@param  con             °ª¹ÞÀ» Á÷¾÷µî±Þ ÆÄ¶ó¸ÞÅÍ¸í
***************************************************************************/
function MoveCursor(fname, s1, s2, con) {

	var len_s1 = eval("document."+fname+"."+s1+".value.length");

	var tf = "document."+fname+"."+s2+".focus();";

	//focus move
	if( len_s1 >= con )	eval(tf);
}
















