////////////////////////////////////////////////////////////////
// ÇÁ·Î±×·¥¸í	: jslib.js
// ¼³¸í			: ÀÚ¹Ù½ºÅ©¸³Æ® ¶óÀÌºê·¯¸® ÇÔ¼ö ¸ðÀ½
// ÀÛ¼ºÀÚ		: ¼Õ»ó¸ð
// ÀÏ ÀÚ		: 2003.01.13 ÃÖÃÊÀÛ¼º            
///////////////////////////////////////////////////////////////

/*

2003-01-13 : CheckBoxChoiceAll,isCheckBoxChoice ÇÔ¼ö Ãß°¡

*/

//
// Sub ID		: doResize
// Description	: iFrame Size Á¶Àý
// Param		: 
// Return		: 
//

function doResize(){
	if(payment.document.body.scrollHeight != 0){
		container.height = payment.document.body.scrollHeight;
	}else{
		container.height = 100;
	}
}


//
// Sub ID		: isEmail
// Description	: Email Format Check
// Param		: str	- Email Address
// Return		: true or false
//
function isEmail(str) {
  // regular expression Áö¿ø ¿©ºÎ Á¡°Ë
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}


//
// Sub ID		: isResNo
// Description	: ÁÖ¹Î¹øÈ£ Sum Check
// Param		: s		- ÁÖ¹Î¹øÈ£
// Return		: true or false
//
function isResNo(s) {
	if( s.charAt(6) == 1 || s.charAt(6) == 2 ){
		if( s.charAt(12) ==	(( 11 - ((s.charAt(0)*2+s.charAt(1)*3+s.charAt(2)*4
			 +s.charAt(3)*5+s.charAt(4)*6+s.charAt(5)*7
			 +s.charAt(6)*8+s.charAt(7)*9+s.charAt(8)*2
			 +s.charAt(9)*3+s.charAt(10)*4+s.charAt(11)*5)
			% 11)))%10)
			return true;
	}
	return false;
}

//
// Sub ID		: isNumVal
// Description	: Number Format Check
// Param		: Num	- number
// Return		: true or false
//
function isNumVal(NUM) {
	for(var i=0;i<NUM.length;i++){
		achar = NUM.substring(i,i+1);
		if( achar < "0" || achar > "9" ){
			return false;
		}
	}
	return true;
}


// 
//	Sub ID		: isNumObj
//	Description	: ¼ýÀÚ¸¸ ÀÔ·Â¹Þµµ·Ï
//  Param		: obj	- text
// Return		: true or false
//
function isNumObj(obj)
{
	for (var i = 0; i < obj.value.length ; i++){
		chr = obj.value.substr(i,1);		
		chr = escape(chr);
		key_eg = chr.charAt(1);
		if (key_eg == 'u'){
			key_num = chr.substr(i,(chr.length-1));			
			if((key_num < "AC00") || (key_num > "D7A3")) { 
				event.returnValue = false;
			} 			
		}
	}
	if (event.keyCode >= 48 && event.keyCode <= 57) {
		
	} else {
		event.returnValue = false;
	}
}

// 
//	Sub ID		: isMaxLength
//	Description	: ¹®ÀÚ¿­ÀÇ ÃÖ´ëÅ©±â
// Param			: str  - ¹®ÀÚ¿­
//					  len -  ÃÖ´ëÅ©±â
// Return		: true or false
//
function isMaxLength(str,len){
	var strlen = 0;
	for (var i = 0; i < str.length ; i++){
		chr = escape(str.substr(i,1));
		key_eg = chr.charAt(1);
		if (key_eg == 'u'){
			strlen+=2;
		} else {
			strlen++;
		}
	}
	if(strlen > len){
		return true;
	} else {
		return false;
	}
}


//
// Sub ID		: isCheckBox
// Description	: Check Box Check À¯¹«
// Param		: obj	- checkbox object
// Return		: true or false
//
function isCheckBox(obj) {
	if (obj.length > 1) {
		for(i=0;i<obj.length;i++) if (obj[i].checked) return true;
	} else {
		return obj.checked;
	}
	return false;
}

//
// Sub ID		: CheckBoxChoiceAll
// Description	: ÇØ´ç CheckBox ¸ðµÎ ¼±ÅÃ
// Param		: obj	- checkbox object
// Param		: objKey	- checkbox object
// Return		: true or false
//
function CheckBoxChoiceAll(obj,objKey){
	if(obj){
		if(obj.length){
			for(i=0;i<obj.length;i++){
				obj[i].checked = objKey.checked;
			}
		} else {
			obj.checked = objKey.checked;
		}
	}
}

//
// Sub ID		: isCheckBoxChoice
// Description	: Ã¼Å©¹Ú½º ¼±ÅÃ¿©ºÎ
// Param		: obj	- checkbox object
// Return		: true or false
//
function isCheckBoxChoice(obj){
	if(obj){
		if(obj.length){
			for(i=0;i<obj.length;i++){
				if(obj[i].checked == true){ return true; }
			}
			return false;
		} else {
			return obj.checked;
		}
	} else { return false; }
}

//
// Sub ID		: isRadio
// Description	: Radio ¼±ÅÃÀ¯¹«
// Param		: obj	- radio object
// Return		: true or false
//
function isRadio(obj) {
	if (obj.length > 1) {
		for(i=0;i<obj.length;i++) if (obj[i].checked) return true;
	} else {
		return obj.checked;
	}
	return false;
}


// 
//	Sub ID		: moveObject
//	Description	: ÀÏÁ¤Å©±âÀÇ °ªÀ» ¹Þ¾ÒÀ»¶§ ´Ù¸¥ object·Î ÀÌµ¿
// Param		: obj	- ÇØ´ç obj
//	Param		: len	- ±æÀÌ
//	Param		: nobj	- ÀÌµ¿ÇÒ obj
// Return		: true or false
//
function moveObject(obj,len,nobj){
	if(obj.value.length == len){
		nobj.focus();
		return true;
	}
	return false;
}

// 
//	Sub ID		: waitEmail
//	Description	: ÀÌ¸ÞÀÏ ¹ß¼ÛÁß
// Param		: obj	- ÇØ´ç frame
//
function waitEmail(obj){
	var wait = "<table width=100% height=90% border=0 cellspacing=0 cellpadding=0><tr><td align=center>";
	wait = wait + "<table width=473 height=116 border=0 cellspacing=0 cellpadding=0><tr>";
	wait = wait + "<td width=147><img src=/admin/img/cp4.gif border=0></td>";
	wait = wait + "<td width=326 background=/admin/img/cp2.gif><p style=margin-top:6><font color=#004CCA size=3><b>ÀÌ¸ÞÀÏÀ» ¹ß¼ÛÁßÀÔ´Ï´Ù.</b></font>";
	wait = wait + "<p style=margin-top:10>ÀÌ¸ÞÀÏÀ» ¹ß¼ÛÁßÀÔ´Ï´Ù.<br>Àá½Ã¸¸ ±â´Ù·Á ÁÖ¼¼¿ä!</td>";
	wait = wait + "</tr></table></td></tr></table>";
	obj.document.write(wait);
}

// 
//	Sub ID		: openWindow
//	Description	: ÆË¾÷À©µµ¿ì ¿­±â
// Param		: theURL	- ÆË¾÷À¸·Î ¿­¸± URL
// Param		: winName	- ÆË¾÷À©µµ¿ì ÀÌ¸§
// Param		: features	- ÆË¾÷Ã¢ÀÇ ¼Ó¼º
// Param		: myWidth	- ÆË¾÷Ã¢ÀÇÆø
// Param		: myHeight	- ÆË¾÷Ã¢ÀÇ³ôÀÌ
// Param		: isCenter	- ÆË¾÷Ã¢ÀÇ Áß¾Ó Á¤·Ä ¿©ºÎ
//
function openWindow(theURL,winName,features, myWidth, myHeight, isCenter) 
{
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

//
// Sub ID		: getRadioValue
// Description	: Ã¼Å©µÈ ¶óµð¿À¹öÆ° °ª
// Param		: obj	- RadioButton object
// Return		: Ã¼Å©µÈ ¶óµð¿À¹öÆ° °ª
//
function getRadioValue(obj){
	if(obj){
		if(obj.length){
			for(i=0;i<obj.length;i++){
				if(obj[i].checked == true){ 
					return obj[i].value;
				}
			}

		}else{
			return obj.value;
		}
	} else { return false; }
}
