/**
 * ºñ¹Ð¹øÈ£ Check
 * @param passField ÆÐ½º¿öµå element - form.element
 * @param confirmField ÆÐ½º¿öµå È®ÀÎ element - form.element
 * @return boolean
 */
function isNotValidPassword(passField, confirmField) {

	if(isEmpty(passField,"ÆÐ½º¿öµå¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(isEmpty(confirmField,"ÆÐ½º¿öµå¸¦ ÀçÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(isOutOfRange(passField, 4, 10, "ºñ¹Ð¹øÈ£´Â 4~10ÀÚ »çÀÌÀÇ ¼ýÀÚ ¹× ¿µ¹® ´ë¼Ò¹®ÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(isOutOfRange(confirmField, 4, 10, "ºñ¹Ð¹øÈ£´Â 4~10ÀÚ »çÀÌÀÇ ¼ýÀÚ ¹× ¿µ¹® ´ë¼Ò¹®ÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(passField.value != confirmField.value) {
		alert("ºñ¹Ð¹øÈ£°¡ ¼­·Î ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.\n ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		passField.value="";
		confirmField.value="";
		passField.focus();
		passField.select();
		return true;
	}
	return false;
}

/**
 * ÁÖ¹Îµî·Ï¹øÈ£ Check
 * @param pid1 ÁÖ¹Î¹øÈ£ ¾ÕÀÚ¸® - form.element
 * @param pid2 ÁÖ¹Î¹øÈ£ µÚÀÚ¸® - form.element
 * @return boolean
 */
function isNotValidPID(pid1, pid2) {

	if(isEmpty(pid1,"ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(isEmpty(pid2,"ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(!isNumber(pid1,"ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®´Â ¼ýÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(!isNumber(pid2,"ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®´Â ¼ýÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(isNotExactLength(pid1, 6, "ÁÖ¹Îµî·Ï¹øÈ£ ¾ÕÀÚ¸®´Â 6ÀÚ¸®ÀÔ´Ï´Ù!")) return true;
	if(isNotExactLength(pid2, 7, "ÁÖ¹Îµî·Ï¹øÈ£ µÞÀÚ¸®´Â 7ÀÚ¸®ÀÔ´Ï´Ù!")) return true;
	strchr = pid1.value.concat(pid2.value);
	if (strchr.length == 13	) {
		nlength = strchr.length;

		num1 = strchr.charAt(0);
		num2 = strchr.charAt(1);
		num3 = strchr.charAt(2);
		num4 = strchr.charAt(3);
		num5= strchr.charAt(4);
		num6 = strchr.charAt(5);
		num7 = strchr.charAt(6);
		num8 = strchr.charAt(7);
		num9 = strchr.charAt(8);
		num10 = strchr.charAt(9);
		num11 = strchr.charAt(10);
		num12 = strchr.charAt(11);

		var total = (num1*2)+(num2*3)+(num3*4)+(num4*5)+(num5*6)+(num6*7)+(num7*8)+(num8*9)+(num9*2)+(num10*3)+(num11*4)+(num12*5);
		total = (11-(total%11)) % 10;
	//	if (total == 11) total = 1;
	//	if (total == 10) total = 0;

		if(total != strchr.charAt(12)) {
			//¿Ü±¹ÀÎ ÁÖ¹Î¹øÈ£ ÀÏ°æ¿ì
			if(isRegNo_fgnno(pid1.value+pid2.value)){
				return false;
			}else{		
				alert("ÁÖ¹Îµî·Ï¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
				pid1.value="";
				pid2.value="";
				pid1.focus();
				return true;
			}
		}
		return false;
	}	else
		alert("ÁÖ¹Îµî·Ï¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		pid1.value="";
		pid2.value="";
		pid1.focus();
		return true;

}

// ¿Ü±¹ÀÎ ÁÖ¹Î¹øÈ£ Ã¼Å©
function isRegNo_fgnno(fgnno) { 
        var sum=0; 
        var odd=0; 
        buf = new Array(13); 
        for(i=0; i<13; i++) { buf[i]=parseInt(fgnno.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 } 
        return true; 
} 


/**
 * »ç¾÷ÀÚµî·Ï¹øÈ£ Check
 * @param bid1 »ç¾÷ÀÚµî·Ï¹øÈ£ ¾ÕÀÚ¸® - form.element
 * @param bid2 »ç¾÷ÀÚµî·Ï¹øÈ£ Áß°£ ÀÚ¸® - form.element
 * @param bid3 »ç¾÷ÀÚµî·Ï¹øÈ£ Áß°£ ÀÚ¸® - form.element
 * @return boolean
 */
function isNotValidBID(bid1, bid2, bid3) {

	if(isEmpty(bid1,"»ç¾÷ÀÚµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(isEmpty(bid2,"»ç¾÷ÀÚµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(isEmpty(bid3,"»ç¾÷ÀÚµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")) return true;
	if(!isNumber(bid1,"»ç¾÷ÀÚµî·Ï¹øÈ£ ¾ÕÀÚ¸®´Â ¼ýÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(!isNumber(bid2,"»ç¾÷ÀÚµî·Ï¹øÈ£ °¡¿îµ¥ÀÚ¸®´Â ¼ýÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(!isNumber(bid3,"»ç¾÷ÀÚµî·Ï¹øÈ£ µÞÀÚ¸®´Â ¼ýÀÚ·Î¸¸ ±âÀÔÇØ ÁÖ¼¼¿ä!")) return true;
	if(isNotExactLength(bid1, 3, "»ç¾÷ÀÚµî·Ï¹øÈ£ ¾ÕÀÚ¸®´Â 3ÀÚ¸®ÀÔ´Ï´Ù!")) return true;
	if(isNotExactLength(bid2, 2, "»ç¾÷ÀÚµî·Ï¹øÈ£ µÞÀÚ¸®´Â 2ÀÚ¸®ÀÔ´Ï´Ù!")) return true;
	if(isNotExactLength(bid3, 5, "»ç¾÷ÀÚµî·Ï¹øÈ£ µÞÀÚ¸®´Â 5ÀÚ¸®ÀÔ´Ï´Ù!")) return true;
	strchr = bid1.value.concat(bid2.value.concat(bid3.value));

	num1 = strchr.charAt(0);
	num2 = strchr.charAt(1);
	num3 = strchr.charAt(2);
	num4 = strchr.charAt(3);
	num5= strchr.charAt(4);
	num6 = strchr.charAt(5);
	num7 = strchr.charAt(6);
	num8 = strchr.charAt(7);
	num9 = strchr.charAt(8);
	num10 = strchr.charAt(9);

	var total = (num1*1)+(num2*3)+(num3*7)+(num4*1)+(num5*3)+(num6*7)+(num7*1)+(num8*3)+(num9*5);
	total = total + parseInt((num9 * 5) / 10);
	var tmp = total % 10;
	if(tmp == 0) {
		var num_chk = 0;
	} else {
		var num_chk = 10 - tmp;
	}

	if(num_chk != num10) {
		alert("»ç¾÷ÀÚµî·Ï¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		bid1.value="";
		bid2.value="";
		bid3.value="";
		bid1.focus();
		return true;
	}
	return false;
}

/**
 *  E-Mail Check
 * @param field form.element
 * @return booelan
 */
function isNotValidEmail(field)
{
   var checkflag = true;
   var retvalue;

   if(field.value == "") {
	   retvalue = true;
   } else {

	   if (window.RegExp) {
		  var tempstring = "a";
		  var exam = new RegExp(tempstring);
		  if (tempstring.match(exam)) {
			 var ret1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			 var ret2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
			 retvalue = (!ret1.test(field.value) && ret2.test(field.value));
		  } else {
			 checkflag = false;
		  }
	   } else {
		  checkflag = false;
	   }

	   if (!checkflag) {
		  retvalue = ( (field.value != "") && (field.value.indexOf("@")) > 0 && (field.value.index.Of(".") > 0) );
	   }

   }
   if(retvalue) { return false;
   } else {
		alert("ÀÌ¸ÞÀÏ ÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
		field.focus();
		field.select();
		return true;
   }
}

/**
 * TelNumber Check
 * @param field form.element
 * @return boolean
 */
function isNotValidTel(field) {

   var Count;
   var PermitChar =
         "0123456789-";

   for (var i = 0; i < field.value.length; i++) {
      Count = 0;
      for (var j = 0; j < PermitChar.length; j++) {
         if(field.value.charAt(i) == PermitChar.charAt(j)) {
            Count++;
            break;
         }
      }

      if (Count == 0) {
         alert("ÀüÈ­¹øÈ£°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù. \n´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä!")
		 field.focus();
		 field.select();
		 return true;
         break;
      }
   }
   return false;
}
