/* ±âº»ÀûÀÎ ÇÔ¼ö */
/* 1.ÁÖ¹Î¹øÈ£Ã¼Å©*/
function isCivilNo(it){
	var idtot=0;
	var idadd="234567892345";
	
	for (var i=0; i<12; i++) {
		idtot = idtot+parseInt(it.substring(i,i+1))*parseInt(idadd.substring(i,i+1));
	}
	idtot=11-(idtot%11);
	if (idtot==10) {
		idtot=0;
	} else if(idtot==11) {
		idtot=1;
	}
	if (parseInt(it.substring(12,13))!=idtot) 
		return false;

	return true;
}


/*2.¹®ÀÚ¿­ Ã¼Å©*/
function stringcheck(Str){
	for(i=0; i < Str.length; i++){
		if(!((Str.charAt(i) >= "0" && Str.charAt(i) <= "9") || (Str.charAt(i) >= "A" && Str.charAt(i) <= "Z")
			|| (Str.charAt(i) >= "a" && Str.charAt(i) <= "z") || (Str.charAt(i) == "-") || Str.charAt(i) == " ")){
			return false;
		}
	}
	return true;
}		


/*2-1.¿µ¹® Ã¼Å© - ¿µ¹®¸í*/
function is_english(Str){
	for(var i=0; i < Str.length; i++){
		if(!((Str.charAt(i) >= "A" && Str.charAt(i) <= "Z") || (Str.charAt(i) >= "a" && Str.charAt(i) <= "z") || Str.charAt(i) == " ")){
			return false;
		}
	}
	return true;
}

/*2-1.¿µ¹® Ã¼Å© - Ç÷¾×Çü*/
function is_english2(Str){
	for(var i=0; i < Str.length; i++){
		if(!((Str.charAt(i) >= "A" && Str.charAt(i) <= "Z") || (Str.charAt(i) >= "a" && Str.charAt(i) <= "z") || Str.charAt(i) == "-" || Str.charAt(i) == "+")){
			return false;
		}
	}
	return true;
}

/*3.ÇÑ±ÛÃ¼Å© */
function is_hangul(val)
{
	if(val.length==0) return false;
		for (var i = 0; i < val.length; i++){
			if (val.charCodeAt(i) != 32 && (val.charCodeAt(i)  < 44032 || val.charCodeAt(i) > 55203))
				return false;}
		return  true;
}


/* 4.ÁÖ¹Îµî·Ï¹øÈ£ ÀÔ·Â Æ÷Ä¿½º ÀÌµ¿  */

function movefocus(x){
  if(x.jumin1.value.length == 6){
	x.jumin2.focus();
  }
}


/*5.¿£ÅÍÃ¼Å© - 2006.06.07*/
function entercheck(x,FuncName){
	if(event.keyCode == 13)
		FuncName(x);
}


/*6.À©µµ¿ì ¿ÀÇÂ */
function openwin(url,objname,width,height,top,left,scroll){
	window.open(url, objname, "directories=no,location=no,menubar=no,resizable=no,scrollbars=" +scroll + ",status=no,titlebar=no,toolbar=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left).focus();
}


/*7.¼ýÀÚÀÔ·Â Ã¼Å©*/
function isDigit(val)
{
	var valid = true;
	var cmp = "0123456789";

	for (var i=0; i<val.length; i++) {
		if (cmp.indexOf(val.charAt(i)) < 0) {
			valid = false;
			break;
		}
	}
	return valid;
}

/*7-2.¼ýÀÚÀÔ·Â Ã¼Å©*/
function isDigit2(val)
{
	var valid = true;
	var cmp = "0123456789-";

	for (var i=0; i<val.length; i++) {
		if (cmp.indexOf(val.charAt(i)) < 0) {
			valid = false;
			break;
		}
	}
	return valid;
}

/*7-3.¼ýÀÚÀÔ·Â Ã¼Å©*/
function isDigit3(val)
{
	var valid = true;
	var cmp = "0123456789:/";

	for (var i=0; i<val.length; i++) {
		if (cmp.indexOf(val.charAt(i)) < 0) {
			valid = false;
			break;
		}
	}
	return valid;
}
/*8.±ÛÀÚ¼ö Á¦ÇÑ Ã¼Å©*/
function is_range(val, min, max)
{
	var val_len = val.length;
	var temp;
	for(i = 0; i < val_len; i++) {
		temp = val.charAt(i);
		if(escape(temp).length > 4) val_len++;
	}
	if ((val_len < min) || (val_len > max))	return false;
	else return true;
}

/*9.floatÇü Ã¼Å©*/
function is_float(val)
{
	var index = -1;
	var num1="",num2="",temp="";
	if (val.length==0) return false;
	for(i = 0; i < val.length; i++) {
		temp = val.charAt(i);		
			
		if (temp==".")
		{
			if (index==-1) index = i;
			else
				return false;
		}	
		else
		{
			if (index ==-1)	num1 = num1 + temp;
			else num2 = num2 + temp;
		}					
	}	
	if (!is_number(num1)) return false;
	if (!is_number(num2) && (num2 != "")) return false;
	return true;	
}


/*10.¹®ÀÚ¿­ ±æÀÌ Ã¼Å© */
function getlength(val)
{	
	var len = 0;
	var num="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_+|-=\[]{};',./<>? ";
	if(val.length==0) return 0;
	for (var i = 0; i < val.length; i++){	
		if (-1 == num.indexOf(val.charAt(i)))		
			len = len + 2;
		else
			len = len + 1;				
	}	
	return  len;
}


/*11.·¹ÀÌ¾î °ü¸® */
function ShowLayer()
{
	var str;	
	if(document.sendmail.cate.selectedIndex == 0){
		document.all['apply0'].style.display = '';
		document.all['apply1'].style.display = 'none';
		document.all['apply2'].style.display = 'none';
		document.all['apply3'].style.display = 'none';
	}

	else if(document.sendmail.cate.selectedIndex == 1){
		document.all['apply0'].style.display = 'none';
		document.all['apply1'].style.display = '';
		document.all['apply2'].style.display = 'none';
		document.all['apply3'].style.display = 'none';
	}

	else if(document.sendmail.cate.selectedIndex == 2){
		document.all['apply0'].style.display = 'none';
		document.all['apply1'].style.display = 'none';
		document.all['apply2'].style.display = '';
		document.all['apply3'].style.display = 'none';
	}

	else if(document.sendmail.cate.selectedIndex == 3){
		document.all['apply0'].style.display = 'none';
		document.all['apply1'].style.display = 'none';
		document.all['apply2'].style.display = 'none';
		document.all['apply3'].style.display = '';
	}
}


function ShowLayer1(x, div, cnt)
{
	var num;
	var str;
	
	num = parseInt(x.fileno.value)+1;	
	
	for (i=2;i<cnt+1;i++)
	{
		str = "document.all['"+div +i+"'].style.display = 'none';";
		eval(str);				
	}
	for (i=2;i<num+1;i++)
	{
		str = "document.all['"+div +i+"'].style.display = '';";
		eval(str);			
	}	
}


/*12-1.Æ¯¼ö¹®ÀÚ ÀÔ·Â Ã¼Å©*/
function isSpecialChar(val)
{
	var valid = true;
	var cmp = "/:;'-\"\\";

	for (var i=0; i<val.length; i++) {
		if (cmp.indexOf(val.charAt(i)) >= 0) {
			valid = false;
			break;
		}
	}
	return valid;
}


/*12-2.Æ¯¼ö¹®ÀÚ ÀÔ·Â Ã¼Å©*/
function isSpecialChar2(val)
{
	var valid = true;
	var cmp = "/:;'\"\\";

	for (var i=0; i<val.length; i++) {
		if (cmp.indexOf(val.charAt(i)) >= 0) {
			valid = false;
			break;
		}
	}
	return valid;
}


/*13.°ø¹éÃ¼Å© Ã¼Å©*/
function JS_trim(data)
{
  for(var i=0;i<data.length;i++)
  {
  	var digit = data.charAt(i)
  	if ( digit == " ")	continue; 
  	else return 1;
  }
  return -1;
}


//14.ÀÌ¸ÞÀÏ Ã¼Å©
function chkemail(val){
	if ( val.search(/(^\..*)|(.*\.$)/) != -1 || val.search(/\S+@(\S+)\.(\S+)/) == -1 ) {
        alert("ÀüÀÚ¿ìÆíÁÖ¼ÒÀÇ Çü½ÄÀº '°èÁ¤@[È£½ºÆ®|µµ¸ÞÀÎ]'°ú °°ÀÌ ±¸¼ºµÇ¾î¾ß ÇÏ¸ç,\r\n¾çÂÊ¿¡ '.'ÀÌ ±âÀçµÇ¾î¼­´Â ¾ÈµË´Ï´Ù.\r\n\r\n¿¹) kiv@kado.com");
        return false ;
    }
	/*
	var str = val.substring(val.indexOf("@")+1);
	str1 = str.substring(0,7);
	str2 = str.substring(0,4);
	if((str1.toLowerCase() == "hanmail") || (str2.toLowerCase() == "daum")){
		alert("ÇÑ¸ÞÀÏ °èÁ¤Àº µî·ÏÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.");		
		return false; 
	}	
	*/
	return true;
}


 function isValidateString(pString)
 {
      var r = /[ ]+/;
      var ss = pString.replace(r, "");
      var rr = /[^\\\'\`\"]+/g;
       
      if (rr.test(ss))
        return true;
      else
        return false;
 }
    
 
 function isValidateEmail(pString)
 {
       var rr = /^[^ @\'\"\\]+[@]{1}[^ @\'\"\.]+[\.]{1}[^ @\'\"\\]+/g;

       if(pString == pString.match(rr))
        return true;
       else
        return false;
 }


 function existSpecialChar(pform)
 {
      var strType, strValue;
      var r = /[\'\"\`|]/;
      
      for(i=0; i < pform.elements.length; i++)
      {
        strType = pform.elements[i].type;
        if (strType = "text")
        {
          strValue = pform.elements[i].value;
          //alert("" + pform.elements[i].name + " type=" + strType);
          if(r.test(strValue))
          {
            pform.elements[i].select();
            alert("Æ¯¼ö¹®ÀÚ(\\, \', \", \`,| )´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
            return true;
          }
        }
      } 
      return false;
  }

/*select box À§·Î ·¹ÀÌ¾î ¶ç¿ì±â */
// Internet Explorer¿¡¼­ ¼¿·ºÆ®¹Ú½º¿Í ·¹ÀÌ¾î°¡ °ãÄ¥½Ã ·¹ÀÌ¾î°¡ ¼¿·ºÆ® ¹Ú½º µÚ·Î ¼û´Â Çö»óÀ» ÇØ°áÇÏ´Â ÇÔ¼ö 
// ·¹ÀÌ¾î°¡ ¼¿·ºÆ® ¹Ú½º¸¦ Ä§¹üÇÏ¸é ¼¿·ºÆ® ¹Ú½º¸¦ hidden ½ÃÅ´ 
// »ç¿ë¹ý : 
// <div id=LayerID style="display:none; position:absolute;" onpropertychange="selectbox_hidden('LayerID')"> 
function selectbox_hidden(layer_id) 
{ 
	var ly = eval(layer_id); 

	// ·¹ÀÌ¾î ÁÂÇ¥ 
	var ly_left  = ly.offsetLeft; 
	var ly_top    = ly.offsetTop; 
	var ly_right  = ly.offsetLeft + ly.offsetWidth; 
	var ly_bottom = ly.offsetTop + ly.offsetHeight; 

	// ¼¿·ºÆ®¹Ú½ºÀÇ ÁÂÇ¥ 
	var el; 

	for (i=0; i<document.forms.length; i++) { 
		for (k=0; k<document.forms[i].length; k++) { 
			el = document.forms[i].elements[k];    
			if (el.type == "select-one") { 
				var el_left = el_top = 0; 
				var obj = el; 
				if (obj.offsetParent) { 
					while (obj.offsetParent) { 
						el_left += obj.offsetLeft; 
						el_top  += obj.offsetTop; 
						obj = obj.offsetParent; 
					} 
				} 
				el_left  += el.clientLeft; 
				el_top    += el.clientTop; 
				el_right  = el_left + el.clientWidth; 
				el_bottom = el_top + el.clientHeight; 

				// ÁÂÇ¥¸¦ µûÁ® ·¹ÀÌ¾î°¡ ¼¿·ºÆ® ¹Ú½º¸¦ Ä§¹üÇßÀ¸¸é ¼¿·ºÆ® ¹Ú½º¸¦ hidden ½ÃÅ´
				if ( (el_left >= ly_left && el_top >= ly_top && el_left <= ly_right && el_top <= ly_bottom) || 
					(el_right >= ly_left && el_right <= ly_right && el_top >= ly_top && el_top <= ly_bottom) || 
					(el_left >= ly_left && el_bottom >= ly_top && el_right <= ly_right && el_bottom <= ly_bottom) || 
					(el_left >= ly_left && el_left <= ly_right && el_bottom >= ly_top && el_bottom <= ly_bottom) ) 
					el.style.visibility = 'hidden'; 
			} 
		} 
	} 
} 

// °¨Ãß¾îÁø ¼¿·ºÆ® ¹Ú½º¸¦ ¸ðµÎ º¸ÀÌ°Ô ÇÔ 
function selectbox_visible() 
{ 
	for (i=0; i<document.forms.length; i++) { 
		for (k=0; k<document.forms[i].length; k++) { 
			el = document.forms[i].elements[k];    
			if (el.type == "select-one" && el.style.visibility == 'hidden') 
				el.style.visibility = 'visible'; 
		} 
	} 
} 


/*17.ÀÌ¹ÌÁö »çÀÌÁî ÀÚµ¿ º¯È¯*/
function adjustImage(target_img)
{
    var newX, newY;
    var newHeight, newWidth;
    var newImg;

    var maxWidth = 125;
    var maxHeight = 70;

    newImg = new Image();
    newImg.src = target_img.src;
    imgw = newImg.width;
    imgh = newImg.height;

    if (imgw*1.2 >= imgh) {
    	return false;
    }

    if (imgw > maxWidth || imgh > maxHeight)
    {
        if(imgw > imgh)
        {
            if(imgw > maxWidth)
                newWidth = maxWidth;
            else
                newWidth = imgw;
            newHeight = Math.round((imgh*newWidth)/imgw);
        }
        else
        {
            if(imgh > maxHeight)
                newHeight = maxHeight;
            else
                newHeight = imgh;
            newWidth = Math.round((imgw*newHeight)/imgh);
        }
    }
    else
    {
        newWidth = imgw;
        newHeight = imgh;
    }
    newX = maxWidth/2 - newWidth/2;
    newY = maxHeight/2 - newHeight/2;

	target_img.onload = null;
	target_img.src = newImg.src;
    target_img.width = newWidth;
    target_img.height = newHeight;
}




