//»õÃ¢¶ç¿ì±â
function open_window(name,url,left,top,width,height,toolbar,menubar,statusbar,scrollbar,resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';
  window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

// Null Check...
function nullcheck(tar, content){
	var target = tar.value
	if ((target.length == 0) ) {
		alert(content + "¸¦ ÀÔ·ÂÇÏ¼¼¿ä.")
		tar.focus(true)
		return true;
	}
	return false;
}

// minimum ¼ýÀÚ Ã¼Å© 
function minlengthcheck(tar, minlength, content){
	var target = tar.value
	if (target.length < minlength){
		alert (content + "´Â " + minlength + "ÀÚ¸®ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù.")
		tar.focus(true);
		return true;
	}		
	return false;
}

// ¼ýÀÚ¸¸ ÀÔ·Â...
function digitcheck(tar, content){
	var target = tar.value
	for (var i=0 ; i<target.length;i++) {
		if (target.charAt(i) < "0" || target.charAt(i) > "9"){
			alert(content + "¶õ¿¡´Â ¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.")
			tar.focus(true)
			return true;
		}
	}
	return false;
}

// ¼ýÀÚ¿Í »©±â¸¸ ÀÔ·Â°¡´É
function dashcheck(tar, content){
	var target = tar.value
	for (var i=0 ; i<target.length;i++) {
		if (target.charAt(i) < "0" || target.charAt(i) > "9" || !(target.charAt(i)=="-")){
			alert(content + "¶õ¿¡´Â ¼ýÀÚ¿Í ´ë½ÃºÎÈ£(-)¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.")
			tar.focus(true)
			return true;
		}
	}
	return false;
}

// ¿µ¹®ÀÚ¿Í ¼ýÀÚ Ã¼Å©...
function charcheck(tar, content){
	var target = tar.value
    for (var i=0 ; i<target.length;i++) {
		if (!((target.charAt(i) >= "a" && target.charAt(i) <= "z")||(target.charAt(i) >= "A" && target.charAt(i) <= "Z")||((target.charAt(i) >= "0") && (target.charAt(i) <= "9")))){
			alert(content + "¶õ¿¡´Â ¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.")
			tar.focus(true)
			return true;
		}
	}
	return false;
}

// ³¯Â¥Ã¼Å©...
function datecheck(tar, content){
	var target = tar.value;
	var dd = new Array(3);
	if ( target.length == 0 ){
		alert (content + "¸¦ ÀÔ·ÂÇÏ¼¼¿ä.")
		tar.focus(true)
		return false;
	}
	if ( target.length != 10 ){
		alert (content + "¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä.")
		tar.value = ""
		tar.focus(true)
		return false;
	}
	dd = target.split("/");
	year = dd[0];
	month = dd[1];
	day = dd[2];
	if ( year.length != 4 ){
		alert ( "³âµµ´Â 4ÀÚ¸® ÀÔ´Ï´Ù.");
		tar.value = ""
		tar.focus(true)
		return false;
	}
	if (month.length != 2 ){
		alert ("ÀªÀº 2ÀÚ¸® ÀÔ´Ï´Ù.");
		tar.value = ""
		tar.focus(true)
		return false;
	}
	if (day.length!= 2){
		alert ("ÀÏÀº 2ÀÚ¸® ÀÔ´Ï´Ù.");
		tar.value = ""
		tar.focus(true)
		return false;
	}
	today = new Date()
	var ddate = new Date(target);
		
	if ( today >= ddate ){
		alert("¿À´Ã ÀÌÈÄÀÇ ³¯Â¥¸¦ ÀÔ·ÂÇÏ¼¼¿ä.")
		tar.value = ""
		tar.focus(true)
		return false
	}
}

//  ÀÌ¸ÞÀÏ Ã¼Å©...
function emailcheck (email,content) {

    var emailPat=/^(.+)@(.+)$/
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
    var validChars="\[^\\s" + specialChars + "\]"
    var quotedUser="(\"[^\"]*\")"
    var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
    var atom=validChars + '+'
    var word="(" + atom + "|" + quotedUser + ")"
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
    var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
    var matchArray=email.value.match(emailPat)

	if (matchArray==null) {
		if(email.value.length == 0){
        			alert("E-Mail À» ÀÔ·ÂÇÏ¼¼¿ä.");
		}
        else{
        			alert("E-Mail Çü½ÄÀÌ Æ²¸³´Ï´Ù. È®ÀÎÇÏ¼¼¿ä.");	
		}
    	email.focus(true);
    	return true;
    }
    var user=matchArray[1]
    var domain=matchArray[2]


    if (user.match(userPat)==null) {

        alert("E-Mail Çü½ÄÀÌ Æ²¸³´Ï´Ù. È®ÀÎÇÏ¼¼¿ä.");
        email.focus(true);
        return true;
    }

    var IPArray=domain.match(ipDomainPat)
    if (IPArray!=null) {

          for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
       			alert("E-Mail Çü½ÄÀÌ Æ²¸³´Ï´Ù. È®ÀÎÇÏ¼¼¿ä.");
            email.focus(true);
            return true;
            }
        }
    }


    var domainArray=domain.match(domainPat)
    if (domainArray==null) {
        alert("E-Mail Çü½ÄÀÌ Æ²¸³´Ï´Ù. È®ÀÎÇÏ¼¼¿ä.");
        email.focus(true);
        return true;
    }

    var atomPat=new RegExp(atom,"g")
    var domArr=domain.match(atomPat)
    var len=domArr.length
    if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
       alert("E-Mail Çü½ÄÀÌ Æ²¸³´Ï´Ù. È®ÀÎÇÏ¼¼¿ä.");
       email.focus(true);
       return true;
    }

    if (len<2) {
        alert("E-Mail Çü½ÄÀÌ Æ²¸³´Ï´Ù. È®ÀÎÇÏ¼¼¿ä.");
        email.focus(true);
        return true;
    }
    return false;
}

//ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å© 
function jumincheck(no1, no2){
	
		var resiNum1 = no1.value;
		var resiNum2 = no2.value;

		total = 0;
		temp = new Array(13);

		for(i=1; i<=6; i++)
			temp[i] = resiNum1.charAt(i-1);
		for(i=7; i<=13; i++)
			temp[i] = resiNum2.charAt(i-7);
		
		for(i=1; i<=12; i++){
			k = i + 1;
			if(k >= 10)
				k = k % 10 + 2;
			total = total + temp[i] * k;
		}
		mm = temp[3] + temp[4];
		dd = temp[5] + temp[6];

		totalmod = total % 11;
		chd = 11 - totalmod;
		if (chd > 9 ) {
			chd = chd - 10;  }
		if(chd == temp[13] && mm < 13 && dd < 32 && (temp[7]==1 || temp[7]==2)) {
			return false;
		}	
		else {
			alert("ÁÖ¹Îµî·Ï¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇÏ¼¼¿ä.");
			no1.focus();
			return true;
		}
}


/*
function  charTest(strTest){
	var emailPat=/^(.+)@(.+)$/
	var matchArray = strTest.value.match(emailPat)
	var user=matchArray[1]
    	var domain=matchArray[2]
    	alert ("1: " + user + "\n" + "2: " + domain)	
}
*/

function lengthcheck(tar, validlength, content){
	var target = tar.value
	if (target.length > validlength){
		alert (validlength + " ÀÌ»ó ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.")
		var re_value = target.substring(0, validlength)
		tar.value = re_value
	}		
}

// textarea ±æÀÌÃ¼Å©...
function textareacheck(tar, validlength, content){
	var target = tar.value
	var temp = target.length
	var tcount = 0 
	var hancount = 0
	for( k=0 ; k<temp ; k++ ){
		onechar = target.charAt(k);
		
		if(escape(onechar).length > 4) {
			tcount += 2;
		}
		else{
			tcount ++
		}
		if (tcount > validlength){
					alert( content + "Ç×¸ñÀº " + validlength + " Bytes ÀÌ»ó ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.")
					tar.value = target.substring(0, k)
					return true;
		}
	}

	return false
}		
// ·Î±×ÀÎ Ã¼Å© ÀÔ´Ï´Ù.
function EnterCheck(form) {
			if(event.keyCode ==13){ 
					var id=document.login.u_id.value;
					if(!id){
						alert('ID¸¦ ÀÔ·ÂÇÏÁö ¾Ê¾Ò½À´Ï´Ù.');
						document.login.u_id.focus();
						return;
					}
					if(id.length<5 || id.length>12) {
						alert("È¸¿øID´Â 5-10±ÛÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä!");
						document.login.u_id.focus();
						return; 
					}
					
					var pass=document.login.u_pw.value;
					if(!pass){
						alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏÁö ¾Ê¾Ò½À´Ï´Ù.');
						document.login.u_pw.focus();
						return;
					}
					if(pass.length<5 || pass.length>12) {
						alert("È¸¿ø ºñ¹Ð¹øÈ£´Â 5-12±ÛÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä!");
						document.login.u_pw.focus();
						return; 
					}
					document.login.submit();
				}
}
	function login_check(form){
		var id=document.login.u_id.value;
		if(!id){
			alert('ID¸¦ ÀÔ·ÂÇÏÁö ¾Ê¾Ò½À´Ï´Ù.');
			document.login.u_id.focus();
			return;
			}
			
		if(id.length<5 || id.length>12) {
			alert("È¸¿øID´Â 5-10±ÛÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä!");
			document.login.u_id.focus();
			return; 
		}

		var pass=document.login.u_pw.value;
		if(!pass){
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏÁö ¾Ê¾Ò½À´Ï´Ù.');
			document.login.u_pw.focus();
			return;
		}
		
		if(pass.length<5 || pass.length>12) {
			alert("È¸¿ø ºñ¹Ð¹øÈ£´Â 5-12±ÛÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä!");
			document.login.u_pw.focus();
			return; 
		}					

		document.login.submit();

	}
// È¸¿ø °¡ÀÔ¹× ·Î±×ÀÎ ¾ÏÈ£ Ã£À»¶§..
	function open_ex(url){
		window.open(url,"popup","width=529, height=365, toolbar=no, menubar=no, resizable =yes, scrollbars=auto"); 
	}
	function open_findid(url){
		window.open(url,"popup","width=529, height=300, toolbar=no, menubar=no, resizable =yes, scrollbars=auto"); 
	}
	function openswin(url) {
		window.open(url,"popup","width=300, height=220, toolbar=no, menubar=no, resizable =yes, scrollbars=auto"); 
	}

	function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable){
		toolbar_str = toolbar ? 'yes' : 'no';
		menubar_str = menubar ? 'yes' : 'no';
		statusbar_str = statusbar ? 'yes' : 'no';
		scrollbar_str = scrollbar ? 'yes' : 'no';
		resizable_str = resizable ? 'yes' : 'no';
		window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
	}

