function checkID(InStr) {
	InStr = InStr.toUpperCase();

	if (InStr.length < 4) return false;

	for (i = 0; i < InStr.length; i++)
		if ( (InStr.charAt(i) == '|') || !((InStr.charAt(i) >= 'A' && InStr.charAt(i) <= 'Z')||
              (InStr.charAt(i) >= '0' && InStr.charAt(i) <= '9')||
                      (InStr.charAt(i) == '_')))
                        return false;
	return true;
}
function checkPhone(InStr) {
	if (InStr.length == 0) return false;
	for (i = 0; i < InStr.length; i++)
		if ( !((InStr.charAt(i) == '-') || (InStr.charAt(i) >= '0' && InStr.charAt(i) <= '9')) ) 
			return false;
	return true;
}
function checkString(str) {
	var strLen = 0;
	var maxLen = 0;
	for (var i=0;i<str.length;i++) {
		if (str.charAt(i) == " ")  strLen++;
	}
	if (strLen == str.length) return false;
	else                      return true;
}
function checkStringMsg(o, max, msg) {
	var lenBlank = 0;
	var lenTotal = 0;
	for (var i=0; i<o.value.length; i++) {
		lenTotal++;
		var retCode = parseInt(o.value.charCodeAt(i));
		var retChar = o.value.substr(i,1).toUpperCase();
		if ((retChar<"0"||retChar>"9") && (retChar<"A"||retChar>"Z") && (retCode<0||retCode>255)) lenTotal++;
		if (o.value.charAt(i) == " ") lenBlank++;
	}
	if (lenBlank == o.value.length) {
		alert(msg +"을(를) 입력하여야 합니다.");
		o.focus();
		o.select();
		return false;
	} else if (lenTotal > max) {
		alert(msg +"은(는) 최대 "+ max +"자까지 입니다.");
		o.focus();
		o.select();
		return false;
	} else {
		return true;
	}
}

function checkStrLength(val, max) {
	var len = 0;
	for (i=0; i<val.length; i++) {
		var retCode = parseInt(val.charCodeAt(i));
		var retChar = val.substr(i,1).toUpperCase();
		len++;
		if ((retChar<"0"||retChar>"9") && (retChar<"A"||retChar>"Z") && (retCode<0||retCode>255)) len++;
	}
	if (len>max) return false;
	else         return true;
}

function checkEmail(strEmail) {	
	var arrMatch = strEmail.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
	if (arrMatch == null) return false;

	var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
	if (arrIP != null) {
		for (var i = 1; i <= 4; i++) {
			if (arrIP[i] > 255)  return false;
   		}
	}
	return true;
}

function checkIP(strIP) {	
	var arrMatch = strIP.match(/^(\".*\"|[A-Za-z0-9_-]([A-Za-z0-9_-]|[\+\.])*).(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)+)$/);
	if (arrMatch == null) return false;

	var arrIP = arrMatch[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
	if (arrIP != null) {
		for (var i = 1; i <= 4; i++) {
			if (arrIP[i] > 255)  return false;
   		}
	}
	return true;
}

function checkRadio(o) {
	var checker = false;
	for(var i=0; i < o.length; i++) {
		if (o[i].checked == true) checker = true;
	}
	if (checker) return true;
	else         return false;
}
function checkRadioMsg(o, msg) {
	var checker = false;
	for(var i=0; i < o.length; i++) {
		if (o[i].checked == true) checker = true;
	}
	if (checker) {
		return true;
	} else {
		alert(msg +"을(를) 선택하여야 합니다.");
		return false;
	}
}

function checkSelect(o) {
	if (o.options[0].selected == true) return false;
	else                               return true;
}

function checkDate(strDate) {
	var arrDate;
	var chkDate
	
	if (strDate.indexOf("-") != -1)  arrDate = strDate.split("-");
	else                             arrDate = strDate.split("/");

	if (arrDate.length != 3)         return false;
	
	chkDate = new Date(arrDate[0] + "/" + arrDate[1] + "/" + arrDate[2]);
	
	if (isNaN(chkDate) == true ||
		(arrDate[1] != chkDate.getMonth() + 1 || arrDate[2] != chkDate.getDate())) {
		return false;
	}
	
	return true;
}

function checkDateForm(strDate, chrSplit) {
	var s1, s2;
	s1 = strDate.substr(4,1);
	s2 = strDate.substr(7,1);
	if (s1 == chrSplit && s2 == chrSplit)   return true;
	else                                    return false;
}
function checkSSN(ssn1,ssn2) {
	if ((ssn1.value == "") || (ssn1.value == null))	{
		alert("주민등록번호를 입력하여 주세요.")
		ssn1.focus();
		ssn1.select();
		return true;
	}
	
	var chk =0;
	var yy = ssn1.value.substring(0,2);
	var mm = ssn1.value.substring(2,4);
	var dd = ssn1.value.substring(4,6);
	var sex = ssn2.value.substring(0,1);
	
	if ((ssn1.value.length!=6)||(yy <25||mm <1||mm>12||dd<1)){
		alert ("주민등록번호를 바로 입력하여 주십시오.");
		ssn1.focus();
		ssn1.select();
		return true;
	}

	if ((sex != 1 && sex !=2 )||(ssn2.value.length != 7 )){
		alert ("주민등록번호를 바로 입력하여 주십시오.");
		ssn2.focus();
		ssn2.select();
		return true;
	}

// 주민등록번호 체크//

	for (var i = 0; i <=5 ; i++){ 
		chk = chk + ((i%8+2) * parseInt(ssn1.value.substring(i,i+1)));
	}

	for (var i = 6; i <=11 ; i++){ 
		chk = chk + ((i%8+2) * parseInt(ssn2.value.substring(i-6,i-5)));
	}

	chk = 11 - (chk %11);
	chk = chk % 10;

	if (chk != ssn2.value.substring(6,7)) {
		alert ("유효하지 않은 주민등록번호입니다.");
		ssn2.focus();
		ssn2.select();
		return true;
	}	
}

//숫자만
function n_check(Objectname) {
	  var intErr
	  var strValue = Objectname.value
	  var retCode = 0

	  for (i = 0; i < strValue.length; i++) {
		var retCode = strValue.charCodeAt(i)
		var retChar = strValue.substr(i,1).toUpperCase()
		retCode = parseInt(retCode)

		if (retChar < "0" || retChar > "9") {
		  intErr = -1;
		  break;
		}
	  }
	  return (intErr);
	}


//한글처리
function h_check(Objectname) {
	  var intErr
	  var strValue = Objectname.value
	  var retCode = 0

	  for (i = 0; i < strValue.length; i++) {
		var retCode = strValue.charCodeAt(i)
		var retChar = strValue.substr(i,1).toUpperCase()
		retCode = parseInt(retCode)

		if ((retChar < "0" || retChar > "9") && (retChar < "A" || retChar > "Z") && ((retCode > 255) || (retCode < 0))) {
		//if(retCode < 256)
		  intErr = -1;
		  break;
		}
	  }
	  return (intErr);
	}

function login(f) {
	if (!checkString(f.member_id.value)) {
		alert("ID를 입력하여야 합니다.");
		f.member_id.focus();
		f.member_id.select();
		return false;
	} else if (!checkString(f.member_pwd.value)) {
		alert("비밀번호를 입력하여야 합니다.");
		f.member_pwd.focus();
		f.member_pwd.select();
		return false;
	}
}

function data_search(o, login) {
	if (login == "true") {
		if (!checkString(o.value)) {
			alert("검색어를 입력하여야 합니다.");
			o.focus();
			o.select();
			return false;
		}
	} else {
		alert("로그인 후 사용 가능합니다.");
		return false;
	}
}

function zip_search(form_name,zip_size,zip_name1,zip_name2,addr_name1,addr_name2) {
	window.open ("/include/post/post.php?"+
	             "form_name="   + form_name  + 
	             "&zip_size="   + zip_size   +
	             "&zip_name1="  + zip_name1  +
	             "&zip_name2="  + zip_name2  +
	             "&addr_name1=" + addr_name1 +
	             "&addr_name2=" + addr_name2 ,
	             "post",
	             "width=455,height=400,top=200,left=200,scrollbars=yes");
}