document.domain = "hyundaicard.com";

/*--------------------------------------------------
 * param¿¡ µû¸¥ POPUPÃ¢À» ¿¬´Ù.
 * 
 * @param addr : POPUP ÁÖ¼Ò
 * @param left_target: POPUP LEFT À§Ä¡
 * @param top_target: POPUP TOP À§Ä¡
 * @param scroll_yn: POPUP SCROLL ¿©ºÎ
 * @param status_yn: POPUP STATUS ¿©ºÎ
 * @param widty_size: POPUP WIDTH SIZE
 * @param height_size: POPUP HEIGHT SIZE
//--------------------------------------------------*/
function Common_Popup(addr,name,left_target,top_target,scroll_yn,status_yn,width_size,height_size){
	var popup_attribute = "left="+left_target+",top="+top_target+",scrollbars="+scroll_yn+",status="+status_yn+",width="+width_size+",height="+height_size;
	var pop = window.open(addr,name,popup_attribute);
	pop.focus();
}


/*--------------------------------------------------
 * param¿¡ µû¸¥ MODAL_POPUPÃ¢À» ¿¬´Ù.
 * 
 * @param addr : POPUP ÁÖ¼Ò
 * @param scroll_yn: POPUP SCROLL ¿©ºÎ
 * @param left_target: POPUP LEFT À§Ä¡
 * @param top_target: POPUP TOP À§Ä¡
 * @param widty_size: POPUP WIDTH SIZE
 * @param height_size: POPUP HEIGHT SIZE
//--------------------------------------------------*/
function Modal_Popup(addr,scroll_yn,left_target,top_target,width_size,height_size) {
    var url = addr;
    var ws = "status:" + scroll_yn + "; dialogLeft:" + left_target+ "px; dialogTop:" + top_target+ "px; dialogWidth:" + width_size+ "px; dialogHeight:" + height_size+ "px";
    var retVal = showModalDialog(url, window, ws);
    return retVal;
}

/**
 * ÀÔ·Â°ª¿¡ ´ëÇØ 1000ÀÚ¸®¸¶´Ù ÄÞ¸¶ ³Ö¾î¼­ ¹®ÀÚ¿­·Î ¸®ÅÏ
 * @param obj   ¼ýÀÚ
 * @return ret  ÄÞ¸¶¸¦ Ãß°¡ÇÑ ¼ýÀÚ
 */
function fnAddComma(obj) {
	var ret;
	var tmpValue  = "";
	var realValue = "";
	var isMinus = "";

	//±Ý¾×ÀÌ Á¤»óÀÔ·ÂµÇÁö ¾ÊÀº °æ¿ì validation check
	if (obj.value == null || obj.value.replace(/ /gi,"") == "") {
		("±Ý¾×À» ÀÔ·ÂÇÏ¼¼¿ä");
	}

	obj.value = obj.value.replace(/,/gi,"");
	
	//±Ý¾×ÀÌ ¼ýÀÚ·Î µÇ¾îÀÖÁö ¾ÊÀº °æ¿ì validation check
	var chars = "0123456789";
	for (var inx = 0; inx < obj.value.length; inx++) {
		if (chars.indexOf(obj.value.charAt(inx)) == -1) {
			alert("¿Ã¹Ù¸¥ ±Ý¾×À» ÀÔ·ÂÇÏ¼¼¿ä");
			obj.value = '';
			obj.focus();
			return;
		}
	}
	if(obj.value.substring(0, 1) == "-") {
		isMinus = "1" ;
		obj.value = obj.value.replace(/-/g, "");
	}
	obj.value = obj.value.replace(/,/g, "");
	var length = obj.value.length;

	var count = 0;
	for(var i=length; i >= 0; i--) {
		tmpValue += obj.value.substring(i,i+1);
		if((count-1)%3 == 2 && i > 0) {
			tmpValue +=",";
		}
		count++;
	}
	length = tmpValue.length;

	for(var i=length; i >= 0; i--) {
		realValue += tmpValue.substring(i, i + 1);
	}
	
	if(isMinus == "1") {
		realValue = "-"+realValue;
	}
	
	obj.value = realValue;
	
	return obj.value;
}

/**
 * ÀÔ·Â°ª¿¡¼­ ÄÞ¸¶¸¦ ¾ø¾Ø´Ù.
 * @param ¹®ÀÚ¿­
 * @return º¯°æµÈ ¹®ÀÚ¿­
 */
function fnRemoveComma(obj) {
	obj.value = obj.value.replace(/,/gi,"");
	return obj.value;
}

/**
 * ÀÔ·Â³»¿ë ÃÊ±âÈ­
 * @param ¹®ÀÚ¿­
 * @return º¯°æµÈ ¹®ÀÚ¿­
 */
function fnClear(obj) {
	obj.value = "";
	obj.focus();
	return obj.value;
}

/**
 * ÇØ´ç CHECKBOX¸¦ ¸ðµÎ non-checked.
 * @param obj
 * @return
 */
function SetAllNonChecked(obj) {
	if (obj != null) {
		var count = obj.length;
		if(count > 0) {
			for(var i=0; i < count; i++) {
				obj[i].checked = false;
			}
		} else {
			obj.checked = false;
		}
		return;
	}
}

/**
 * ÇØ´ç CHECKBOX¸¦ ¸ðµÎ checked.
 * @param obj
 * @return
 */
function SetAllChecked(obj) {
	if (obj != null) {
		var count = obj.length;
		if(count > 0) {
			for(var i=0; i < count; i++) {
				obj[i].checked = true;
			}
		} else {
			obj.checked = true;
		}
		return;
	}
}


/**
  * Ã³À½ obj°¡ ¼±ÅÃµÇ¾îÁø °æ¿ì ÀüÃ¼ checkObj¸¦ ¼±ÅÃÇÏ°í
  * ÇØÁöµÇ¾îÁø °æ¿ì ¸ðµÎ ÇØÁöÇÑ´Ù.
  * @param obj   ÀüÃ¼¸¦ controlÇÏ´Â CHECKBOX ÀÇ OBJECT
  * @param checkObj ÇØ´ç CHECKBOX
  * @return
  */
function toggleCheckAll(obj, checkObj) {
	if (obj.type == "checkbox") {
		if (!obj.checked) {
			SetAllNonChecked(checkObj);
		} else {
			SetAllChecked(checkObj);
		}
	} else if (obj.type == "hidden") {
		if (obj.value == "Y") {
			SetAllNonChecked(checkObj);
			obj.value = "N";
		} else {
			SetAllChecked(checkObj);
			obj.value = "Y";
		}
	}
}

/**
  * »õÃ¢¿­±â
  * window.open ¿¡¼­ »ç¿ëµÇ´Â ¹æ½ÄÀ¸·Î features ¼³Á¤
  * @param theURL    »õÃ¢ÀÇ Url
  * @param winName   »õÃ¢ÀÇ name
  * @param features  »õÃ¢ÀÇ ¼¼ºÎ ¼³Á¤
  * @return
  */
function OpenWindow(theURL, winName, features) {
	var win = window.open(theURL, winName, features);
	win.focus();
}

/**
  * È­¸éÁß¾Ó¿¡ »õÃ¢¿­±â
  * window.open ¿¡¼­ »ç¿ëµÇ´Â ¹æ½ÄÀ¸·Î features ¼³Á¤
  * @param theURL    »õÃ¢ÀÇ Url
  * @param winName   »õÃ¢ÀÇ name
  * @param features  »õÃ¢ÀÇ ¼¼ºÎ ¼³Á¤
  * @return
  */
function CenterOpenWindow(theURL, winName, width, height, fstate) {
	var features = "width=" + width ;
	features += ",height=" + height ;
	var state = "";
	if (fstate == "") {
		state = features + ", left=" + (screen.width-width)/2 + ",top=" + (screen.height-height)/2;
	} else {
		state = fstate + ", " + features + ", left=" + (screen.width-width)/2 + ",top=" + (screen.height-height)/2;
	}
	var win = window.open(theURL,winName,state);
	win.focus();
}

/**
  * È­¸éÁß¾Ó¿¡ »õÃ¢¿­±â2
  * window.open ¿¡¼­ »ç¿ëµÇ´Â ¹æ½ÄÀ¸·Î features ¼³Á¤(Æ÷Ä¿½º no, ±âÅ¸¼³Á¤ no, Ã¢¸¸ ¶ç¿ì°í º»Ã¢¿¡¼­ ¼­¹Ô ´ë±â)
  * @param theURL    »õÃ¢ÀÇ Url
  * @param winName   »õÃ¢ÀÇ name
  * @param features  »õÃ¢ÀÇ ¼¼ºÎ ¼³Á¤
  * @return
  */
function CenterOpenWindow2(winName, width, height) {
	var features = "width=" + width ;
	features += ",height=" + height ;
	features += ",scrollbars=0";
	features += ",toolbar=0";
	features += ",status=0";
	features += ",resizable=0";
	features += ",menubar=0";
	var state = "";
	state = features + ", left=" + (screen.width-width)/2 + ", top=" + (screen.height-height)/2;
	var win = window.open('', winName, state);
}

/**
  * ÀÔ·Â ÇÊµåÀÇ ¹®ÀÚ Å©±â¸¦ ÇÑÁ¤½ÃÅ³¶§.. (ÇÑ±Û±îÁö °í·ÁÇÏ¿© °è»êµÊ)
  * @param obj   ´ë»ó ÆûÅÂ±×(Object)
  * @param len   ºñ±³ÇÒ ±æÀÌ
  * @param elementNm   ÀÔ·Â Æû ÇÑ±Û ÀÌ¸§(ex: '»óÇ°¸í', '»óÇ°³»¿ë'....
  * @return
  */
function ChkLenByByte(obj, len, elementNm) {
	var src = obj.value;
	var srcLen = GetLenByByte(src);
	if (srcLen <= len) return true;
	var delLen = srcLen - len;
	obj.focus();
	alert(elementNm+" Ç×¸ñÀº ¿µ¹® " + len + "ÀÚ (ÇÑ±ÛÀº " + Math.floor(len/2) + "ÀÚ) ±îÁö¸¸ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù \n"
		   + "ÀÔ·Â ³»¿ë¿¡¼­ ¿µ¹® " + delLen + "ÀÚ (ÇÑ±ÛÀº " + Math.ceil(delLen/2) + "ÀÚ)¸¦ Á¦°ÅÇÏ½Ã±â ¹Ù¶ø´Ï´Ù");
	return false;
}

/**
  * ÀÔ·Â ÇÊµåÀÇ ¹®ÀÚ Å©±â¸¦ ¾ò´Â´Ù.. (ÇÑ±Û±îÁö °í·ÁÇÏ¿© °è»êµÊ)
  * @param String   ¹®ÀÚ¿­
  * @return int ¹®ÀÚ¿­ÀÇ ±æÀÌ
  */
function GetLenByByte(value) {
	var byteLength = 0;
	for (var inx = 0; inx < value.length; inx++) {
		var oneChar = escape(value.charAt(inx));
		if ( oneChar.length == 1 ) {
			byteLength ++;
		} else if (oneChar.indexOf("%u") != -1) {
			byteLength += 2;
		} else if (oneChar.indexOf("%") != -1) {
			byteLength += oneChar.length/3;
		}
	}
	return byteLength;
}

/**
  * ´ë»ó Object¸¦ disable ½ÃÅ²´Ù.
  * @param  obj   ´ë»ó ÆûÅÂ±×(Object)
  * @return
  */
function DisableObject(obj) {
	switch( obj.type ) {
		case "checkbox" :
			obj.disabled = true;
			break;
		case "text" :
			obj.readOnly=true;
			obj.style.backgroundColor = "#E9F8F2";
			obj.style.color = "#555555";
		break;
		default:
	}
}

/**
  * ´ë»ó Object¸¦ enable ½ÃÅ²´Ù.
  * @param obj   ´ë»ó ÆûÅÂ±×(Object)
  * @return
  */
function EnableObject(obj) {
	switch(obj.type) {
		case "checkbox" :
			obj.disabled = false;
			break;
		case "text" :
			obj.readOnly=false;
			obj.style.backgroundColor = "#ffffff";
			obj.style.color = "#000000";
			break;
		default:
	}
}

/**
  * ¸®½ºÆ®¿¡¼­ ÇÏ³ªÀÌ»óÀÇ Ã¼Å©¹Ú½º°¡ ¼±ÅÃµÇ¾ú´ÂÁö È®ÀÎÇÑ´Ù.
  * @param obj   ÇØ´ç CHECKBOX ÀÇ OBJECT
  * @return
  */
function IsChecked(obj){
	var count = obj.length;
	var iChecked = 0;
	if(count > 1){
		for(var i=0;i<count;i++){
			if (obj[i].checked) iChecked++;
		}
	} else {
		if (obj.checked) iChecked++;
	}
	if (iChecked == 0) {
		alert("¼±ÅÃµÈ °ªÀÌ ¾ø½À´Ï´Ù");
		return false;
	}
	return true;
}

/**
  * ¸®½ºÆ®¿¡¼­ ÇÏ³ªÀÇ Ã¼Å©¹Ú½º¸¸ ¼±ÅÃµÇ¾ú´ÂÁö È®ÀÎ
  * @param obj   ÇØ´ç CHECKBOX ÀÇ OBJECT
  * @return
  */
function IsCheckedOnlyOne(obj){
	var count = obj.length;
	if(count > 1){
		var iChecked = 0;
		for(var i=0;i<count;i++){
			if (obj[i].checked) iChecked++;
		}
		if (iChecked > 1) {
			alert("ÇÏ³ª¸¸ ¼±ÅÃÇÏ½Ê½Ã¿À");
			return false;
		}
	}
	return true;
}

/**
 * Æ¯Á¤ SELECT°´Ã¼ÀÇ Value,Text°ªÀ» ¹ÝÈ¯ÇÑ´Ù.
 * @param obj_name, get_method
 * @return value or text
 */
function get_select_value(obj_name,get_method) {

	// ÀÔ·ÂµÈ °´Ã¼ÀÌ¸§À» °´Ã¼·Î »ý¼º
	
	if (obj_name != "") // °´Ã¼¸íÀÌ °ø¹éÀÎÁö °Ë»ç
	{
	
		select_obj = eval("document.all." + obj_name);	
	
		if (get_method == "value")
		{
			return select_obj.options(select_obj.selectedIndex).value;
		}
		else
		{
			return select_obj.options(select_obj.selectedIndex).text;
		}
	}	
}

/**
 * ÀÔ·Â°ªÀ» ÄÞ¸¶°¡ Æ÷ÇÔµÈ ¹®ÀÚ¿­·Î º¯È¯ÇÏ¿© ¸®ÅÏ
 * @param str   ¼ýÀÚ
 * @return ret  ÄÞ¸¶¸¦ Ãß°¡ÇÑ ¼ýÀÚ
*/
function strAddComma(val) {
	var ret;

	//¼ýÀÚ¾Õ¿¡ ÀÖ´Â "0"À» ¸ÕÀú »èÁ¦ÇÔ. - 2004.9.12		
	var numstr = val + "";
	var rxSplit = new RegExp('([0-9])([0-9][0-9][0-9][,.])');
	var arrNumber = numstr.split('.');
	arrNumber[0] += '.';
	do {
			arrNumber[0] = arrNumber[0].replace(rxSplit, '$1,$2');
	}		
	while (rxSplit.test(arrNumber[0]));

	if (arrNumber.length > 1) {
			ret = arrNumber.join('');
	} else {
			ret = arrNumber[0].split('.')[0];
	}

	return ret;
}

function sessionOut() {
	parent.document.location = "/index.html";
}

 /**
  * ÀÔ·ÂµÈ ¹®ÀÚ¿­ÀÌ ¼ýÀÚ ¸¸À» Æ÷ÇÔÇÏ°í ÀÖ´ÂÁö ¿©ºÎ ¸®ÅÏ
  * @param obj   Object
  * @return true - ¼ýÀÚ¸¸À» Æ÷ÇÔÇÏ°í ÀÖ´Â °æ¿ì
  */
function IsNumber(obj) {
    var ret = obj.value;
    if(event.keyCode < 48 || event.keyCode > 57){
        if(event.keyCode < 96 || event.keyCode > 105){
            if((event.keyCode != 9 && event.keyCode != 8 && event.keyCode != 229 && event.keyCode != 190 && event.keyCode != 46 && event.keyCode != 13 && event.keyCode != 16 && event.keyCode != 37 && event.keyCode != 39)){
                alert("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
                    
                obj.value = ret.substring(0,ret.length-1);
                obj.focus();
                //obj.select();
                return;
            }
        }
    }  
} 

 /**
  * ÀÔ·Â°ªÀÌ Æ¯Á¤ ¹®ÀÚ(chars)¸¸À¸·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
  * Æ¯Á¤ ¹®ÀÚ¸¸ Çã¿ëÇÏ·Á ÇÒ ¶§ »ç¿ë
  * ex) if (!containsCharsOnly(form.blood,"ABO")) {
  *         alert("Ç÷¾×Çü ÇÊµå¿¡´Â A,B,O ¹®ÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");
  *     }
  * @param obj   Object
  * @return true Æ¯Á¤ ¹®ÀÚ°¡ ÀÖÀ» °æ¿ì
  */
function ContainsCharsOnly(obj,chars) {
	for (var inx = 0; inx < obj.value.length; inx++) {
		if (chars.indexOf(obj.value.charAt(inx)) == -1) {
			return false;
		}
	}
	return true;
}

 /**
  * ÀÌ¹ÌÁö ¹Ì¸®º¸±â
  * @param src   ÀÌ¹ÌÁö°æ·Î
  */
function showPicture(src) {
    var imgObj = new Image();
    imgObj.src = src;
    var wopt = "scrollbars=yes,status=no,resizable=yes";
    wopt += ",width=" + imgObj.width;
    wopt += ",height=" + imgObj.height;
    var wbody = "<head><title>image view</title>";
    wbody += "<script language='javascript'>";
    wbody += "function finalResize(){";
    wbody += "  var oBody=document.body;";
    wbody += "  var oImg=document.images[0];";
    wbody += "  var xdiff=oImg.width-oBody.clientWidth;";
    wbody += "  var ydiff=oImg.height-oBody.clientHeight;";
    wbody += "  window.resizeBy(xdiff,ydiff);";
    wbody += "}";
    wbody += "</"+"script>";
    wbody += "</head>";
    wbody += "<body onLoad='finalResize()' style='margin:0'>";
    wbody += "<a href='javascript:window.close()'><img src='" + src + "' border=0></a>";
    wbody += "</body>";
    winResult = window.open("about:blank","",wopt);
    winResult.document.open("text/html", "replace");
    winResult.document.write(wbody);
    winResult.document.close();
    return;
}

//½ºÆ®¸µ°´Ã¼ Æ®¸² ±¸Çö
String.prototype.trim = function() { return this.replace(/^ *| *$/g, ""); }

/**
 * ÀÌ¸ÞÀÏ @ÀÌÈÄÀÇ µµ¸ÞÀÎÁ¾·ù¸¸ select¹Ú½ºÀÇ ¿É¼Ç ¹®ÀÚ¿­·Î ¸®ÅÏ
 * @param val(ÇØ´çÇÏ´Â @ÀÌÈÄÀÇ µµ¸ÞÀÎ°ª)     
 * @return
 */
function return_eMailList(){
	var strUrl = "chol.com/dreamwiz.com/empal.com/freechal.com/hanmail.net/hanmir.com/hitel.net/hotmail.com/intizen.com/korea.com/lycos.co.kr/nate.com/naver.com/netian.com/netsgo.com/orgio.net/paran.com/simmani.com/weppy.com/yahoo.co.kr/Á÷Á¢ÀÔ·Â";

	splitMail = strUrl.split("/");
	splitUrl = strUrl.split("/");

	for(var i = 0; i < splitUrl.length; i++){
		document.writeln("<option value='" + splitUrl[i] + "'>" + splitMail[i] +"</option>");
	}
}
 
 
function goZipPop() {
	var wopt = "scrollbars=yes,status=no,resizable=yes";
    wopt += ",width=420";
    wopt += ",height=280";
    winResult = window.open("/education/common/comZipLst.do", "zipPop", wopt);
    winResult.document.close();
}
 
