/*=============================================================================
 * ÀÛ¼ºÀÚ : woong.
 * ÀÛ¼ºÀÏ : 200x. xx. xx.
 * ¼³  ¸í : Common javascript.
=============================================================================*/

/*===========================================================================
 * ¹®ÀÚ¿­¿¡¼­ ÁÂ¿ì °ø¹é Á¦°Å.
 *===========================================================================*/
String.prototype.ltrim	= new Function("return this.replace(/^\\s+/,'')")
String.prototype.rtrim	= new Function("return this.replace(/\\s+$/,'')")
String.prototype.trim	= new Function("return this.replace(/^\\s+|\\s+$/g,'')")

/*===========================================================================
 * ÇÑ±ÛÆ÷ÇÔ ¹®ÀÚ¿­ ±æÀÌ Ã¼Å©.
 *===========================================================================*/
String.prototype.lengthB = function() 
{
    var str = this;
    var len = 0;
    for (var i=0; i<str.length; i++) len += (str.charCodeAt(i) > 128) ? 2 : 1;

    return len;
}

/*===========================================================================
 * ÇÑ±ÛÆ÷ÇÔ ¹®ÀÚ¿­ ÀÚ¸£±â.
 *===========================================================================*/
String.prototype.substrB = function(len) 
{
    var str = this;
    var to = 0;
    for (var i=0; i<str.length; i++) {
        to += (str.charCodeAt(i) > 128) ? 2 : 1;
        if (to > len) return str.substring(0,i);
    }
    return str;
}

/*===========================================================================
 * ¹®ÀÚ¿­ Ä¡È¯.
 *===========================================================================*/
String.prototype.replaceAll = function(oldStr, newStr) 
{
	return this.replace((new RegExp(oldStr, "gi")), newStr);
}

/*===========================================================================
 * ¹®ÀÚ¿­ ¿ÞÂÊ Ã¤¿ì±â.
 *===========================================================================*/
String.prototype.lpad = function(size, fill) 
{
	if (size==null) return this;

	var str = this.toString();
	if (fill==null || fill=="") fill = " ";
	
	while (str.lengthB()<size) str = fill+str;
	
	return str.substring(str.lengthB()-size, str.lengthB());
}

/*===========================================================================
 * ¹®ÀÚ¿­ ¿À¸¥ÂÊ Ã¤¿ì±â.
 *===========================================================================*/
String.prototype.rpad = function(size, fill) 
{
	if (size==null) return this;

	var str = this.toString();
	if (fill==null || fill=="") fill = " ";
	
	while (str.lengthB()<size) str += fill;
	
	return str.substring(0,size);
}

/*===========================================================================
 * <>¸¦ ÄÚµå·Î º¯°æ.
 *===========================================================================*/
String.prototype.toHTML = function(str) 
{
	return str.replaceAll(str,"<","&lt;").replaceAll(str,">","&gt;");
}

/*===========================================================================
 * ¹®ÀÚ¿­ ¿ÞÂÊ Ã¤¿ì±â.
 *===========================================================================*/
Number.prototype.lpad = function(size, fill) 
{
	if (size==null) return this;

	var str = this.toString();
	if (fill==null || fill=="") fill = " ";
	
	while (str.lengthB()<size) str = fill+str;
	
	return str.substring(str.lengthB()-size,str.lengthB());
}

/*===========================================================================
 * ¹®ÀÚ¿­ ¿À¸¥ÂÊ Ã¤¿ì±â.
 *===========================================================================*/
Number.prototype.rpad = function(size, fill) 
{
	if (size==null) return this;

	var str = this.toString();
	if (fill==null || fill=="") fill = " ";
	
	while (str.lengthB()<size) str += fill;
	
	return str.substring(0,size);
}

/*===========================================================================
 * ³¯Â¥·ÎºÎÅÍ yyyy-mm-dd Çü½ÄÀÇ ½ºÆ®¸µÀ» ¹Þ´Â´Ù.
*===========================================================================*/
Date.prototype.getFormatDate = function(diff) 
{
	if (diff==null || diff=="") diff = 0;
	this.setDate(this.getDate()+diff);
	return this.getYear()+'-'+(this.getMonth()+1).lpad(2,'0')+'-'+this.getDate().lpad(2,'0');
}

/*===========================================================================
 * ¹è¿­º¹»ç
 *===========================================================================*/
Array.copy = function(a){var n=[];for(var i=a.length-1; i>=0; i--){n[i]=a[i];}return n;};

/*===========================================================================
 * ÁÖ¾îÁø id°ªÀ» °¡Áø °´Ã¼¸¦ ¹ÝÈ¯ÇÑ´Ù(ÇÏ³ª ÀÌ»óÀÌ°Å³ª ¾øÀ»¶§´Â °æ°í ¸Þ¼¼Áö ¾Ë¸²).
 * pDocÀº iframeµî¿¡¼­ Ã£À»¶§ »ç¿ë.
 * »ç¿ë¿¹)
   	- $("txtName") ¶Ç´Â $("txtName", ifrm.document)
 *===========================================================================*/
function $(pObjName, pDoc, pMsgFlag)	{
	var tObjDoc = (pDoc==null) ? document : pDoc;
	if (pMsgFlag==null)	pMsgFlag = true;

	var tObj = tObjDoc.getElementsByName(pObjName);
	if (tObj.length==0)	{
		if (pMsgFlag) alert("[" + pObjName + "] °´Ã¼¸¦ Ã£À» ¼ö ¾ø½À´Ï´Ù.");
		return null;
	}
	else if (tObj.length>1)	{
		if (pMsgFlag) alert("[" + pObjName + "]´Â ÇÏ³ª ÀÌ»óÀÇ °´Ã¼°¡ Á¸ÀçÇÕ´Ï´Ù.");
		return null;
	}
	else	{	// Ã¹¹øÂ° °´Ã¼¸¦ ¹ÝÈ¯ÇÑ´Ù.
		return tObj[0];
	}
}

/*===========================================================================
 * Æ¯Á¤ ID¸¦ °¡Áø °´Ã¼ ¸ñ·Ï(List)À» ¹ÝÈ¯ÇÑ´Ù.
 * »ç¿ë¿¹)
   	- $L("chkID") ¶Ç´Â $L("chkID", ifrm.document)
 *===========================================================================*/
function $L(pObjName, pDoc)	{
	var tObjDoc = (pDoc==null) ? document : pDoc;
	return tObjDoc.getElementsByName(pObjName);
}

/*===========================================================================
 * ÁÖ¾îÁø id°ªÀ» °¡Áø °´Ã¼ÀÇ °ª(value)À» ¹ÝÈ¯ÇÑ´Ù(ÇÏ³ª ÀÌ»óÀÌ°Å³ª ¾øÀ»¶§´Â °æ°í ¸Þ¼¼Áö ¾Ë¸²).
 * pDocÀº iframeµî¿¡¼­ Ã£À»¶§ »ç¿ë.
 * »ç¿ë¿¹)
   	- $V("txtName") ¶Ç´Â $V("txtName", ifrm.document)
 *===========================================================================*/
function $V(pObjName, pDoc)	{
	var tObjDoc = (pDoc==null) ? document : pDoc;

	var tObj = tObjDoc.getElementsByName(pObjName);
	if (tObj.length==0)	{
		alert("[" + pObjName + "] °´Ã¼¸¦ Ã£À» ¼ö ¾ø½À´Ï´Ù.");
		return null;
	}
	else if (tObj.length>1)	{
		alert("[" + pObjName + "]´Â ÇÏ³ª ÀÌ»óÀÇ °´Ã¼°¡ Á¸ÀçÇÕ´Ï´Ù.");
		return null;
	}
	else	{	// Ã¹¹øÂ° °´Ã¼ÀÇ °ªÀ» ¹ÝÈ¯ÇÑ´Ù.
		return tObj[0].value;
	}
}


/*===================================================================
 * ÆäÀÌÂ¡ ÀÌµ¿
 *==================================================================*/
function _PAGE(pageNo, objName)	{
	var objName = (objName==null) ? "page" : objName;
	var objPage = document.getElementsByName(objName);

	var url		= null;
		if (objPage.length == 0)	{
			url = (location.href.indexOf("?")>0) ? location.href.substr(0, location.href.indexOf("?")) : location.href;
			location.href = url + "?" + objName + "=" + pageNo;
		}
		else if (objPage.length == 1)	{
			objPage[0].value	= pageNo;
			objPage[0].form.submit();
		}
		else	{
			alert("[" + objName + "] °´Ã¼°¡ ÇÏ³ª ÀÌ»ó Á¸ÀçÇÕ´Ï´Ù.");
		}
}


/*===========================================================================*/
// °ªÀÌ ºñ¾îÀÖ´ÂÁö¸¦ Ã¼Å©ÇÏ¿© ºñ¾îÀÖÀ¸¸é ÇØ´ç ¸Þ¼¼Áö¸¦ º¸¿©ÁØ´Ù.
// °ªÀÌ ºñ¾îÀÖÀ» °æ¿ì true¸¦ ¹ÝÈ¯ÇÑ´Ù.(ÁÖ·Î form.submit() Àü¿¡ °ª Ã¼Å©)
// ex)  if (isEmpty($("msg"), "¸Þ¼¼Áö"))	return;
//			-> msg ¹Ú½º¿¡ °ªÀÌ ¾øÀ¸¸é ¸Þ¼¼Áö¸¦ Ãâ·ÂÇÏ°í ÇÔ¼ö¸¦ ºüÁ®³ª°¨.
//		if (isEmpty($("msg"), "¸Þ¼¼Áö", 80, "M"))	return;
//			-> msg ¹Ú½º¿¡ °ªÀÌ ¾ø°Å³ª 80¹ÙÀÌÆ®¸¦ ³ÑÀ¸¸é ¸Þ¼¼Áö¸¦ Ãâ·ÂÇÏ°í ÇÔ¼ö¸¦ ºüÁ®³ª°¨.
//		if (isEmpty($("regNo1"), "ÁÖ¹Î¹øÈ£", 6, "FM"))	return;
//			-> ÁÖ¹Î¹øÈ£ ¹Ú½ºÀÇ Ã¹¹øÂ° °ªÀÌ 6ÀÚ¸®°¡ ¾Æ´Ï¸é ¸Þ¼¼Áö¸¦ Ãâ·ÂÇÏ°í ºüÁ®³ª°¨..
//		if (isEmpty($("msg"), "¸Þ¼¼Áö", 80, "NM"))	return;
//			-> msg ¹Ú½ºÀÇ °ªÀÌ 80¹ÙÀÌÆ®¸¦ ³ÑÀ¸¸é ¸Þ¼¼Áö¸¦ Ãâ·ÂÇÏ°í ÇÔ¼ö¸¦ ºüÁ®³ª°¨. ºó°ªÀº ¹«½Ã.
/*===========================================================================*/
function isEmpty(obj, pMsg, pLen, pLenFlag)	{
	//----------
	// FM : ÇÊ¼öÀÔ·ÂÀÌ°í data±æÀÌ°¡ fixµÈ °æ¿ì
	//  M : ÇÊ¼öÀÔ·ÂÀÌ°í data±æÀÌ°¡ ÃÊ°úµÈ °æ¿ì
	// NM : data±æÀÌ°¡ ÃÊ°úµÈ °æ¿ì¸¸
	//----------
	//alert(obj.outerHTML);
	if (pLenFlag == null) pLenFlag = "";

	var objTag	= obj.tagName.toUpperCase();
	var val		= obj.value.trim();
	if (objTag == "INPUT" || objTag == "TEXTAREA")	{
		if ( pLenFlag =="" && val=="" && obj.type.toUpperCase()=="FILE")	{
			alert("ÆÄÀÏÀ» ¼±ÅÃÇÏ¼¼¿ä !!!");
			try {obj.focus();} catch(e){};
			return true;
		}
		else if ( pLenFlag =="" && val=="")	{
			if (pMsg)	alert(pMsg +" ÀÔ·ÂÇÏ¼¼¿ä !!!");
			try {obj.focus();} catch(e){};
			return true;
		}
		//woong Ãß°¡
		else if (pLenFlag=="FM" && pLen && val.lengthB() == 0 )	{
			if (pMsg)	alert(pMsg +" ÀÔ·ÂÇÏ¼¼¿ä !!!");
			try {obj.focus();} catch(e){};
			return true;
		}
		//Ãß°¡³¡
		else if (pLenFlag=="FM" && pLen && val.lengthB() != pLen )	{
			alert(pMsg +"ÀÇ ±æÀÌ°¡ ¸ÂÁö ¾Ê½À´Ï´Ù.\n\nÇØ´ç Ç×¸ñÀÇ ±æÀÌ´Â " + pLen +"ÀÚ ÀÔ´Ï´Ù.");
			try {obj.focus();} catch(e){};
			return true;
		}
		else if (pLenFlag=="M" && pLen && val.lengthB() == 0 )	{
			if (pMsg)	alert(pMsg +" ÀÔ·ÂÇÏ¼¼¿ä !!!");
			try {obj.focus();} catch(e){};
			return true;
		}
		else if (pLenFlag=="M" && pLen && val.lengthB() > pLen )	{
			alert(pMsg +"ÀÇ ±æÀÌ°¡ ³Ê¹« ±é´Ï´Ù.\n\nÇØ´ç Ç×¸ñÀÇ ±æÀÌ´Â " + pLen +"¹ÙÀÌÆ®¸¦ ÃÊ°úÇÒ ¼ö ¾ø½À´Ï´Ù.\n(ÇÑ±ÛÀº 2¹ÙÀÌÆ® ¿µ¹®Àº 1¹ÙÀÌÆ®·Î °è»êµË´Ï´Ù.)");
			try {obj.focus();} catch(e){};
			return true;
		}
		else if (pLenFlag=="NM" && pLen && val.lengthB() > pLen )	{
			alert(pMsg +"ÀÇ ±æÀÌ°¡ ³Ê¹« ±é´Ï´Ù.\n\nÇØ´ç Ç×¸ñÀÇ ±æÀÌ´Â " + pLen +"¹ÙÀÌÆ®¸¦ ÃÊ°úÇÒ ¼ö ¾ø½À´Ï´Ù.\n(ÇÑ±ÛÀº 2¹ÙÀÌÆ® ¿µ¹®Àº 1¹ÙÀÌÆ®·Î °è»êµË´Ï´Ù.)");
			try {obj.focus();} catch(e){};
			return true;
		}

	}
	else if (objTag == "SELECT")	{
		if (obj.selectedIndex == 0 && val=="")	{
			if (pMsg)	alert(pMsg +" ¼±ÅÃÇÏ¼¼¿ä !!!");

			obj.focus();
			return true;
		}
	}
	else	{
		alert("¸Å°³º¯¼ö·Î ³Ñ¾î¿Â °´Ã¼°¡ INPUTÀÌ³ª SELECT Å¸ÀÔÀÌ ¾Æ´Õ´Ï´Ù.");
		return true;
	}

	return false;
}


/*========================================================================*/
// À¯È¿ ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
// arg1 - ¾ÕÀÚ¸® 6
// arg2 - µÞÀÚ¸® 7
/*========================================================================*/
    function isCheckSSN(arg1, arg2) {
        var num = 2;
        var sum = 0;

        for(var i = 0; i < arg1.length; i++)
            sum += parseInt(arg1.substr(i, 1)) * num++;

        for (var j = 0; j < arg2.length - 1; j++) {
            sum += parseInt(arg2.substr(j, 1)) * num++;
            if (num == 10) num = 2;
        }

        var count = 11 - sum % 11;
        if (count == 11) count = 1;
        if (count == 10) count = 0;
        if (count != parseInt(arg2.substr(6, 1))) return false;
        else return true;
    }


/*========================================================================*/
// À¯È¿ ¿Ü±¹ÀÎµî·Ï¹øÈ£ Ã¼Å©
// arg - ¿Ü±¹ÀÎ µî·Ï¹øÈ£
/*========================================================================*/
    function isCheckFgnNo(arg) {
        var sum = 0;
        var odd = 0;

        buf = new Array(13);
        for (i = 0; i < 13; i++) buf[i] = parseInt(arg.charAt(i));

        odd = buf[7] * 10 + buf[8];

        if (odd % 2 != 0) {
            return false;
        }

        if ((buf[11] != 6) && (buf[11] != 7) && (buf[11] != 8) && (buf[11] != 9)) {
            return false;
        }

        multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
        for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

        sum = 11 - (sum % 11);

        if (sum >= 10) sum -= 10;

        sum += 2;

        if (sum >= 10) sum -= 10;

        if (sum != buf[12]) {
            return false;
        }
        else {
            return true;
        }
    }


/*==========================================================================*/
// ÀÌ¸ÞÀÏ Çü½ÄÀÎÁö Ã¼Å©ÇÑ´Ù.(Á¤±ÔÇ¥Çö½Ä »ç¿ëÇÔ)
// ex) if (!checkEmail($V("email"))){
//		   alert("Àß¸øµÈ ÀÌ¸ÞÀÏÀÔ´Ï´Ù.");
//		   return;
//	   }
/*==========================================================================*/
    function checkEmail(strChar){

        var isEmail1    = /^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/;
        var isEmail2    = /^.*@[^_]*$/;


        return(isEmail1.test(strChar) && isEmail2.test(strChar));
    }

/*===========================================================================*/
// ÄÞº¸¹Ú½º¿¡¼­ Æ¯Á¤ÄÚµå¸¦ °¡Áø ¿É¼ÇÀÌ ¼±ÅÃµÇµµ·Ï ÇÑ´Ù.
// ex) setComboOption($("searchpart"), "<%=searchpart%>");
// pObjCombo : selectbox name
// pValue : ¼±ÅÃµÉ °ª
/*===========================================================================*/
function setComboOption (pObjCombo, pValue)	{
	var tOptions = pObjCombo.options;
	var tOption = null;

	for (var tLoop=0; tLoop<tOptions.length; tLoop++)	{
		tOption = tOptions[tLoop];

		if (tOption.value == pValue)	{
			tOption.selected = true;
			break;
		}
	}
}

/*===========================================================================*/
// ÄÞº¸¹Ú½º¿¡¼­ Æ¯Á¤ÄÚµå¸¦ °¡Áø ¿É¼ÇÀÌ ¼±ÅÃµÇµµ·Ï ÇÑ´Ù.
/*===========================================================================*/
function getOptionText (pObjCombo, pIndex)	{
	if (pIndex==null || pIndex=="") pIndex = pObjCombo.selectedIndex;
	
	return pObjCombo.options[pIndex].text;
}

/*===========================================================================*/
// ¸ð´ÞÃ¢ ¶ç¿ì±â.
/*===========================================================================*/
function modalPopup(pURL, pWidth, pHeight, pParam1, pParam2, pParam3, pScroll)	{
	if (pScroll==null)	pScroll = "no";
	
	var tFeatures = "dialogHeight:"+pHeight+"px;dialogWidth:"+pWidth+"px;center:yes;resizable:no;scroll:"+pScroll;

	var tParam = new Object();
	tParam.param1 = pParam1;
	tParam.param2 = pParam2;
	tParam.param3 = pParam3;

	return window.showModalDialog(pURL, tParam, tFeatures);
}

/*================================================================================================*/
// ¸ð´ÞÃ¢ÀÌ ¾Æ´Ñ ÀÏ¹Ý POPUPÃ¢À» ºê¶ó¿ìÀú Áß°£ÁöÁ¡¿¡ ¿ÀÇÂÇÑ´Ù.
// ex) <a href="javascript:openWin('aaa.asp', 'a', 400, 200, 'no','no','no','yes')">new window</a>
/*================================================================================================*/
function openWin(pURL, pWinName, pWidth, pHeight, pToolbar,pMenubar,pLocation,pScrollbars)
{

    if (pToolbar==null)	pToolbar = "no"; 
    if (pMenubar==null)	pMenubar = "no"; 
    if (pLocation==null)	pLocation = "no"; 
    if (pLocation==null)	pLocation = "yes"; 
    
    pWidth	= (pWidth<=0)  ? (screen.availWidth -pWidth ) : pWidth;
    pHeight	= (pHeight<=0) ? (screen.availHeight-pHeight) : pHeight;
    
    var tLeft  = screen.width /2 - pWidth /2;
    var tTop   = screen.height/2 - pHeight/2;
    tParam = "toolbar=" + pToolbar + ",menubar=" + pMenubar + ",location=" + pLocation + ",scrollbars=" + pScrollbars + ",status=yes"
    		+ ",left=" + tLeft + ",top=" +  tTop + ",width=" + pWidth + ",height=" + pHeight;

    var tWin = window.open(pURL, pWinName, tParam );
}

/*=======================================================
 * ObjectÀÇ »óÀ§ °´Ã¼ Ã£±â.
 *=======================================================*/
function findParentObject(obj, findID)	{
	var objParent	= obj;
	var objFind		= null;

	while ((objParent = objParent.parentElement)!=null)	{
		if (objParent.getAttribute("id")==findID)	{
			return objParent;
			break;
		}
	}
	return null;
}

/*=======================================================
 * ObjectÀÇ ÇÏÀ§ °´Ã¼ Ã£±â.
 *=======================================================*/
function findChildObject(obj, findID)	{
	var objChild	= null;
	var objFind		= null;

	var objList	= obj.children;
	for(var tLoop=0; tLoop<objList.length; tLoop++)	{
		objChild 	= objList[tLoop];
		
		// Ã£À» °æ¿ì ¹ÝÈ¯ÇÏ°í ³¡³¿.
		if (objChild.getAttribute("id")==findID || objChild.getAttribute("name")==findID)	{
			return objChild;
			break;
		}
		// Ã£´Â °´Ã¼°¡ ¾Æ´Ñ °æ¿ì¿¡ ÀÚ½Ä °´Ã¼µéÀÌ ÀÖÀ¸¸é recursive È£Ãâ.
		else if (objChild.children.length > 0)	{
			objFind	= findChildObject(objChild, findID);
			if (objFind != null) return objFind;
		}
	}
	return null;
}
		
/*=======================================================
 * Æ¯Á¤ °´Ã¼¿¡ ÀÏ·Ã¹øÈ£ ºÎ¿©ÇÏ±â.
 *=======================================================*/
function makeSequence(objList)	{
	for (var tLoop=0; tLoop<objList.length; tLoop++)	{
		objList[tLoop].innerText	= tLoop + 1;
	}
}

/*===========================================================================*/
// Ã¼Å©¹Ú½ºÀÇ ¿É¼ÇÀÌ ÇÏ³ª ÀÌ»ó Ã¼Å©µÇ¾î ÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
// ex)if (checkSelected ($L('chkList')==false)) {
//       alert("ÇÏ³ª ÀÌ»ó ¼±ÅÃÇÏ¼¼¿ä");
//       return;
//   }

/*===========================================================================*/
function checkSelected (objList)	{
	var tObject = null;
	
	for (var tLoop=0; tLoop<objList.length; tLoop++)	{
		tObject = objList[tLoop];
		if (tObject.checked) {
			return true;
		}
	}
	return false;
}

/*===========================================================================*/
// ¶óµð¿À ¿É¼Ç¿¡¼­ Æ¯Á¤ÄÚµå¸¦ °¡Áø ¿É¼ÇÀÌ ¼±ÅÃµÇµµ·Ï ÇÑ´Ù.
/*===========================================================================*/
function setRadioOption (pObjectList, pValue)	{
	if (pObjectList==null) return;

	var tObject = null;
	for (var tLoop=0; tLoop<pObjectList.length; tLoop++)	{
		tObject = pObjectList[tLoop];

		if (tObject.value == pValue)	{
			tObject.checked = true;
			break;
		}
	}
}

/*===========================================================================*/
// ¶óµð¿À ¿É¼ÇÀÌ ÇÏ³ª¶óµµ ¼±ÅÃµÇ¾ú´ÂÁö È®ÀÎÇÑ´Ù.
// ex)  if ( ! checkedRadio($L("optType"), "Å¸ÀÔ")) return;
/*===========================================================================*/
function checkedRadio (pObjectList, pMsg)	{
	if (pObjectList==null)	return false;
	
	var tObject = null;
	var rtnVal = false;
	
	if (pMsg == "") pMsg = null;

	for (var tLoop=0; tLoop<pObjectList.length; tLoop++)	{
		tObject = pObjectList[tLoop];

		if (tObject.checked == true)	{
			return true;
		}
	}
	
	if (pMsg) alert(pMsg+" ¼±ÅÃÇÏ¼¼¿ä.");
		if(pObjectList.length > 1){
			pObjectList[0].focus();
		}else{
			pObjectList.focus();
		}
	return false;
}

/*===========================================================================*/
// Ã¼Å©¹Ú½º¸¦ ÀüÃ¼ ¼±ÅÃÇÏ°Å³ª ÀüÃ¼ ÇØÁ¦ÇÑ´Ù.
// ex) <input type="checkbox" name="checkbox2" value="checkbox" 
//     onclick="javascript:setCheckAll($L('chkReceiver'), this.checked)">
/*===========================================================================*/
function setCheckAll (objList, bool)	{
	if (objList==null) return;
	
	var obj = null;
	for (var tLoop=0; tLoop<objList.length; tLoop++)	{
		obj = objList[tLoop];
		// ¼Ó¼ºÀÌ disabledÀÎ °æ¿ì´Â Á¦¿ÜÇÔ.
		if (obj.disabled==false) obj.checked = bool;
	}
}

/*===========================================================================*/
// Function    : fc_chk_byte(aro_name, ari_max, flag)
// Description : ÀÔ·ÂÇÑ ±ÛÀÚ¼ö¸¦ º¸¿©ÁÖ°í Ã¼Å©ÇÑ´Ù 
//               aro_name:ÅØ½ºÆ®ÇÊµå¸í, ari_max:Á¦ÇÑÇÒ ±ÛÀÚ¼ö Å©±â, flag:±¸ºÐ(ex:title=1, name=2)
// Argument    : Object Name(±ÛÀÚ¼ö¸¦ Á¦ÇÑÇÒ ÄÁÆ®·Ñ)
// Return      : 
/*===========================================================================*/
function fc_chk_byte(aro_name,ari_max,flag)
{
   var field = aro_name; // ÇÊµå¸í
   var ls_str     = aro_name.value; // ÀÌº¥Æ®°¡ ÀÏ¾î³­ ÄÁÆ®·ÑÀÇ value °ª
   var li_str_len = ls_str.length;  // ÀüÃ¼±æÀÌ

   // º¯¼öÃÊ±âÈ­
   var li_max      = ari_max; // Á¦ÇÑÇÒ ±ÛÀÚ¼ö Å©±â
   var i           = 0;  // for¹®¿¡ »ç¿ë
   var li_byte     = 0;  // ÇÑ±ÛÀÏ°æ¿ì´Â 2 ±×¹Ü¿¡´Â 1À» ´õÇÔ
   var li_len      = 0;  // substringÇÏ±â À§ÇØ¼­ »ç¿ë
   var ls_one_char = ""; // ÇÑ±ÛÀÚ¾¿ °Ë»çÇÑ´Ù
   var ls_str2     = ""; // ±ÛÀÚ¼ö¸¦ ÃÊ°úÇÏ¸é Á¦ÇÑÇÒ¼ö ±ÛÀÚÀü±îÁö¸¸ º¸¿©ÁØ´Ù.

   for(i=0; i< li_str_len; i++)
   {
      // ÇÑ±ÛÀÚÃßÃâ
      ls_one_char = ls_str.charAt(i);

      // ÇÑ±ÛÀÌ¸é 2¸¦ ´õÇÑ´Ù.
      if (escape(ls_one_char).length > 4)
      {
         li_byte = li_byte+2;
      }
      // ±×¿ÜÀÇ °æ¿ì´Â 1À» ´õÇÑ´Ù.
      else
      {
         li_byte++;
      }

      // ÀüÃ¼ Å©±â°¡ li_max¸¦ ³ÑÁö¾ÊÀ¸¸é
      if(li_byte <= li_max)
      {
         li_len = i + 1;

		 if (flag == 1)
				//document.all.textlimit1.innerText = field.value.length;
		 	document.all.textlimit1.innerText = li_byte;
		 else if (flag == 2)
			document.all.textlimit2.innerText = li_byte;
		 else if (flag == 3)
		    document.all.textlimit3.innerText = li_byte;
		 else if (flag == 4)
		    document.all.textlimit4.innerText = li_byte;
		 else if (flag == 5)
		    document.all.textlimit5.innerText = li_byte;
		 else if (flag == 6)
		    document.all.textlimit6.innerText = li_byte;
		 else 
		    document.all.textlimit7.innerText = li_byte;
      }
   }
   
   // ÀüÃ¼±æÀÌ¸¦ ÃÊ°úÇÏ¸é
   if(li_byte > li_max)
   {
      alert( "±ÛÀÚ¸¦ ÃÊ°ú ÀÔ·ÂÇÒ¼ö ¾ø½À´Ï´Ù. \nÃÊ°úµÈ ³»¿ëÀº ÀÚµ¿À¸·Î »èÁ¦ µË´Ï´Ù. ");
      ls_str2 = ls_str.substr(0, li_len);
      aro_name.value = ls_str2;
      
   }
   aro_name.focus();   
}


/*===========================================================================*/
// ¼ýÀÚÀÎÁö Ã¼Å©ÇÑ´Ù.
/*===========================================================================*/
function isNumeral(str){
        for(var i=0; i<str.length; i++) {
            var uniCode = str.charCodeAt(i);

            if(!(uniCode >= 48 && uniCode <= 57))
                return false;
        }

        return true;
}


/*===========================================================================*/
// ¿µ¹®ÀÌ°Å³ª ¼ýÀÚÀÎÁö Ã¼Å©ÇÑ´Ù.
/*===========================================================================*/
function isNumOrChar(strChar){
        var numCount = 0;
        var charCount = 0;

        for(var i=0; i<strChar.length; i++) {
            var uniCode = strChar.charCodeAt(i);

            if(uniCode >= 48 && uniCode <= 57)    numCount++; //¼ýÀÚÀÌ¸é

            else if(uniCode >= 65 && uniCode <= 90)    charCount++;//¹®ÀÚÀÌ¸é

            else if(uniCode >= 97 && uniCode <= 122)    charCount++;//¹®ÀÚÀÌ¸é

            else{    //±×¿Ü Æ¯¼ö¹®ÀÚÀÌ°Å³ª ÇÑ±ÛÀÎ ÀÎ°æ¿ì
                return false;
            }
        }

        if(numCount == 0 && charCount == 0){
            return false;
        }

        return true;
    }


/*===========================================================================
 * Ajax request call.(Ajax¸¦ ÀÌ¿ëÇÑ Ã³¸®.
 * ¾Æ·¡ ¶óÀÌºê·¯¸®¸¦ ÆäÀÌÁö¿¡ Æ÷ÇÔ. 
 * <script language="JavaScript" src="/inc/js/prototype.js"></script>
 * pRequestURL : È£ÃâµÉ ÆäÀÌÁö, pFormName : ¸Å°³º¯¼ö·Î ³Ñ±æ form ÅÂ±× name.
 * °¢ ÆäÀÌÁö¿¡¼­ ajaxSuccess, ajaxError ÇÔ¼ö¸¦ ¼±¾ðÇÏ¿© °á°ú°ªÀ» Ã³¸®ÇÒ °Í.
 *===========================================================================*/
function ajaxRequest(pRequestURL, pFormName)	{
	if ($L(pFormName).length==0) {
		alert("form[" + pFormName + "] ÅÂ±×°¡ ¼±¾ðµÇÁö ¾Ê¾Ò½À´Ï´Ù.");
		return;
	}

    var httpObj = new Ajax.Request	( 
    	pRequestURL, {
    		  asynchronous: false
    		, parameters:Form.serialize(pFormName)
    		, onSuccess:ajaxSuccess
    		, onFailure:ajaxError 
    		}
    	);
}

/*===========================================================================
 * Ajax updater call.(Ajax¸¦ ÀÌ¿ëÇÑ Ã³¸®).
 * pAsync(default=true) parameter add.
 *===========================================================================*/
function ajaxUpdater(pRequestURL, pFormName, pTargetName, pAsync)	{
	if (pAsync==null) pAsync = true;
	var objUpdater = new Ajax.Updater(
		pTargetName, 
		pRequestURL, {
    		  asynchronous: pAsync
    		, parameters:Form.serialize(pFormName)
			}
		);
}

/*===========================================================================
 * Ojbect »ðÀÔ......... paramList.split("::");
 *===========================================================================*/
function setObject(objParent, pNewID, pClassID, pCodebase, pWidth, pHeight, paramList) {
	var arrParam, paramName, paramValue;
	
	if (!paramList)	paramList	= "";
	var arrParamList	= paramList.split("::");
	var paramTag		= "";

	for (var tLoop=0; tLoop<arrParamList.length; tLoop++)	{
		arrParam = arrParamList[tLoop];
		if (arrParam.indexOf("=")>0)	{
			paramName	= arrParam.substr(0,arrParam.indexOf("="));
			paramValue	= arrParam.substr(arrParam.indexOf("=")+1);

			paramTag += '<PARAM NAME="'+paramName+'" value="'+paramValue+'">';  
		}
	}

	var newObjectTag	= '<OBJECT id="'		+ pNewID	+ '" '
						+ '        codebase="'	+ pCodebase	+ '" '
						+ '        classid="'	+ pClassID	+ '" '
						+ '        width="'		+ pWidth	+ '" '
						+ '        height="'	+ pHeight	+ '" '
						+ '>'
						+ paramTag
						+ '</OBJECT>'
						;

	// ¸¸¾à Parent°¡ ³Ñ¾î¿À¸é Append¸¦ ÀÌ¿ëÇÏ°í, nullÀÌ¸é document.write ÀÌ¿ëÇÔ.
	if (objParent==null || objParent=="")	{
		document.write(newObjectTag);
	}
	else	{
		objParent.innerHTML = newObjectTag;
	}
}



/*===========================================================================
 * ´Þ·ÂÆË¾÷ ¶ç¿ì±â.
 *===========================================================================*/
function calendar(obj)	{
	var tURL	= "/inc/js/popup_calendar.htm";
	var tFeatures = "dialogHeight:265px;dialogWidth:183px;center:yes;resizable:no;scroll:no";
	var tParam = new Object();
		tParam.dateObject = obj;

	return window.showModalDialog(tURL, tParam, tFeatures);
}

/*===========================================================================
 * ÆÄÀÏ ´Ù¿î·Îµå.
 * _download("@@FILE_IDN","@@FILE_NM","@@FILE_PATH","@@FILE_TYPE","@@FILE_GRP")
 *===========================================================================*/
function _download(fileIdn, fileName, filePath, fileType, fileGrp)	{
	var tURL = "/common/asp/fileDownload.asp?fileName="+fileName+"&filePath="+filePath;
	var objFrame	= document.getElementById("iDownload");
		// ÀÓ½ÃÇÁ·¹ÀÓ ¾øÀ¸¸é »ý¼º.
		if (objFrame==null)	{
			objFrame	= document.createElement("<iframe id='iDownload' style='display:none;'></iframe>");
			document.appendChild(objFrame);
		}
		
	objFrame.src = tURL;
}


/*===========================================================================
 * ÄÞº¸¹Ú½º ÃÊ±âÈ­.
 *===========================================================================*/
function initCombobox(obj, frIndex) {
    if(obj==null)	return;
	//if(obj.type!="SELECT") return;
	if (frIndex==null || frIndex=="") frIndex = 0;

	for(var tLoop=(obj.options.length-1); tLoop>=frIndex; tLoop--)	{
		obj.options.remove(frIndex);
	}
}

/*===========================================================================
 * µ¿¿µ»ó º¸±â.
 *===========================================================================*/
function _Movie(pFileIDN) {
    _movie(pFileIDN);
}

/*===========================================================================
 * µ¿¿µ»ó º¸±â ÆË¾÷ È£Ãâ.
 *===========================================================================*/
function _movie(pFileIDN) {
    var tWidth  = 320;
    var tHeight = 280;
    var tTop   	= 50;
    var tLeft  	= screen.width /2 - tWidth /2;
    
    var tParam 	= "toolbar=no,menubar=no,location=no,scrollbars=no,status=yes,resizable=no"
    				+ ",left=" + tLeft + ",top=" +  tTop + ",width=" + tWidth+",height=" + tHeight;
	var TargetURL = "/common/asp/movieView.asp?fileIdn="+pFileIDN;

    window.open(TargetURL, 'Media', tParam );
}

/*===========================================================================
 * µ¿¿µ»ó º¸±â.
 *===========================================================================*/
function _insertMovie(pMediaPath) {
	var mediaStr = ""
		+ "<OBJECT ID=NSPlay Name=NSPlay 																				"
		+ "		classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95'                                                    "
		+ "		codebase=' http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'    "
		+ "		standby='Loading Microsoft Windows Media Player components...'                                          "
		+ "		type='application/x-oleobject '                                                                         "
		+ "		bgcolor='DarkBlue'                                              										"
		+ " 	onresize='javascript:resizeWin(this.width, this.height)' 												"
		+ "		>                                                                                                       "
		+ "		<PARAM NAME='AutoStart' VALUE='-1'>                                                                     "
		+ "		<PARAM NAME='AnimationAtStart' VALUE='-1'>                                                              "
		+ "		<PARAM NAME='DisplayMode' VALUE='4'>                                                                    "
		+ "		<PARAM NAME='Enabled' VALUE='true'>                                                                     "
		+ "		<PARAM NAME='Filename' VALUE='"+pMediaPath+"'>                                  						"
		+ "		<PARAM NAME='Enabled' VALUE='true'>                                                                     "
		+ "		<PARAM NAME='enablecontextmenu' VALUE='false'>                                                          "
		+ "		<PARAM NAME='ShowControls' VALUE='1'>                                                                   "
		+ "		<PARAM NAME='ShowAudioControls' VALUE='0'>                                                              "
		+ "		<PARAM NAME='ShowDisplay' VALUE='0'>                                                                    "
		+ "		<PARAM NAME='ShowGotoBar' VALUE='0'>                                                                    "
		+ "		<PARAM NAME='ShowPositionControls' VALUE='1'>                                                           "
		+ "		<PARAM NAME='ShowStatusBar' VALUE='1'>                                                                  "
		+ "		<PARAM NAME='Volume' VALUE='0'>                                                                         "
		+ "		<PARAM NAME='ShowCaptioning' VALUE='0'>                                                                 "
		+ "		<PARAM NAME='TransparentAtStart' VALUE='0'>                                                             "
		+ "</OBJECT>                                                                                                    "
		;

	document.write(mediaStr);
}

function total_search()
{
	if(isEmpty($("total_keyword"), "°Ë»ö¾î¸¦")) return;
	
	var frm = document.frm;
		frm.action = "/search.asp";
		frm.target = "_self";
		frm.submit();
}

function adminpwd()
	{
		window.open("/beercabin/admin/adminpwd.php","pwd","width=290, height=200, top=50, left=300, scrollbars=no, toolbar=no, resizable=no");
	}
	
function adminpwd2()
	{
		window.open("/bringwell/admin/adminpwd.php","pwd","width=290, height=200, top=50, left=300, scrollbars=no, toolbar=no, resizable=no");
	}
function adminpwd3()
	{
		window.open("/admin/adminpwd.php","pwd","width=290, height=200, top=50, left=300, scrollbars=no, toolbar=no, resizable=no");
	}
function adminpwd4()
	{
		window.open("/futureworld/admin/adminpwd.php","pwd","width=290, height=200, top=50, left=300, scrollbars=no, toolbar=no, resizable=no");
	}