/******************************************************************************
*** ¿ìÆí¹øÈ£ Ã¢
******************************************************************************/
function ZipWindow(sec){
      var window_left = (screen.width-640)/2;
      var window_top = (screen.height-480)/2;
      window.open('/inc/zipcode.php?sec='+sec,'¿ìÆí¹øÈ£','width=398,height=255,status=no,top=' + window_top + ',left=' + window_left + '');
}

/******************************************************************************
*** ÀÌ¸ÞÀÏ Ã¼Å©
******************************************************************************/
function IsEmail(email) {
	if(email.value.indexOf("@")+"" !="-1" &&
	   email.value.indexOf(".")+"" !="-1" &&
	   email.value !="" &&
	   email.value.indexOf("@.")+"" =="-1")
	   return true;
	else
	   return false;
}

/******************************************************************************
*** ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
******************************************************************************/
function CheckBizNo(){ 
	var F = document.SOCForm;
      if(chk_jumin(F.registnum1.value,F.registnum2.value)== false){
		 alert( "±ÍÇÏ²²¼­ ÀÔ·ÂÇÏ½Å ÁÖ¹Îµî·Ï¹øÈ£´Â Á¤»óÀûÀÎ Ã¼°è°¡ ¾Æ´Õ´Ï´Ù." );
		 F.registnum1.value="";
		 F.registnum2.value="";
		 F.registnum1.focus();
		 return false;
}

function chk_jumin(J1,J2){
	var F = document.SOCForm;
     if(J1 =="111111" || J2 =="1111118"){
        alert("ÁÖ¹Îµî·Ï ¹øÈ£¸¦ ´Ù½Ã È®ÀÎ ÇÏ¼¼¿ä.");
		F.registnum1.value=""
		F.registnum2.value=""
		F.registnum1.focus();
        return;
     }
	 else{
		 // ÁÖ¹Îµî·Ï¹øÈ£ 1 ~ 6 ÀÚ¸®±îÁöÀÇ Ã³¸®
		 // ÁÖ¹Îµî·Ï¹øÈ£¿¡ ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ Ã³¸®
		 for(i=0;i<J1.length;i++){
			 if (J1.charAt(i) >= 0 || J1.charAt(i) <= 9) {
			 // ¼ýÀÚ¸é °ªÀ» °öÇØ ´õÇÑ´Ù.
				 if(i == 0){
					SUM = (i+2) * J1.charAt(i);
				 }else{
					SUM = SUM +(i+2) * J1.charAt(i);
				 }
			 }else{
			 // ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
				alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
				F.registnum1.value=""
				F.registnum2.value=""
				return;
			 }
		  }
		  for(i=0;i<2;i++){
		  // ÁÖ¹Îµî·Ï¹øÈ£ 7 ~ 8 ÀÚ¸®±îÁöÀÇ Ã³¸®
			  if (J2.charAt(i) >= 0 || J2.charAt(i) <= 9) {
				  SUM = SUM + (i+8) * J2.charAt(i);
			  }else{
			  // ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
				  alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
				  F.registnum1.value=""
				  F.registnum2.value=""
				  return;
			  }
		   }
		   for(i=2;i<6;i++){
		   // ÁÖ¹Îµî·Ï¹øÈ£ 9 ~ 12 ÀÚ¸®±îÁöÀÇ Ã³¸®
			   if (J2.charAt(i) >= 0 || J2.charAt(i) <= 9) {
				   SUM = SUM + (i) * J2.charAt(i);
			   }else{
			   // ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
				   alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
				   F.registnum1.value=""
				   F.registnum2.value=""
				   return;
			   }
		   }
		   // ³ª¸ÓÁö ±¸ÇÏ±â
		   var checkSUM = SUM % 11;
		   // ³ª¸ÓÁö°¡ 0 ÀÌ¸é 10 À» ¼³Á¤
		   if(checkSUM == 0){
		   var checkCODE = 10;
		   // ³ª¸ÓÁö°¡ 1 ÀÌ¸é 11 À» ¼³Á¤
		   }else if(checkSUM ==1){
		   var checkCODE = 11;
		   }else{
		   var checkCODE = checkSUM;
		   }
		   // ³ª¸ÓÁö¸¦ 11 ¿¡¼­ »«´Ù
		   var check1 = 11 - checkCODE;
		   if (J2.charAt(6) >= 0 || J2.charAt(6) <= 9) {
		   var check2 = parseInt(J2.charAt(6))
		   }else{
			   // ¼ýÀÚ°¡ ¾Æ´Ñ ¹®ÀÚ°¡ ÀÖÀ» ¶§ÀÇ Ã³¸®
			   alert("¼ýÀÚ¸¸ ÀÔ·ÂÇÏ¼¼¿ä");
		   }
		   if(check1 != check2){
			  // ÁÖ¹Îµî·Ï¹øÈ£°¡ Æ²¸± ¶§ÀÇ Ã³¸®
			  alert("ÁÖ¹Îµî·Ï¹øÈ£¸¦ ´Ù½Ã È®ÀÎ ÇÏ¼¼¿ä.");
			  F.registnum1.value=""
			  F.registnum2.value=""
			  F.registnum1.focus();
			  return false;
		   }else{
//		      F.email.focus();
//  			  birthday();
		   }
	 }
  }
}

/******************************************************************************
*** ÁöÁ¤ÇÑ ¹®ÀÚ±æÀÌ¸é ´ÙÀ½ input À¸·Î ³Ñ¾î°¡¶ó
******************************************************************************/
function check(type){
	var F = document.SOCForm;
    var str  = F.registnum1.value.length;
	var str2 = F.registnum2.value.length;
	if (type==1) {
	    if(str == 6)      { F.registnum2.focus();}
	}
	else if (type==2) {
		if(str2 == 7) 	 { CheckBizNo();}
	}
}

/******************************************************************************
*** »ý³â¿ùÀÏ Ã¼Å©
******************************************************************************/
function birth_check() {
        strjumin = document.SOCForm.registnum1.value;
        
        if(strjumin.substring(0,2) > "05"){
                document.SOCForm.b_year.value = "19" + strjumin.substring(0,2);
		} else{
                document.SOCForm.b_year.value = "20" + strjumin.substring(0,2);
        }
        bmonth_pos = strjumin.substring(2,4);
        bday_pos = strjumin.substring(4,6);
        
        document.SOCForm.b_month.value = bmonth_pos;
        document.SOCForm.b_day.value = bday_pos;
}

/******************************************************************************
*** ¾ÆÀÌµðÁßº¹ Ã¼Å©
******************************************************************************/
function IDcheck(){
   var F = document.SOCForm;
   var strTmp = F.userid.value;

   if(strTmp == ""){
      alert('¸ÕÀú ¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
	  F.userid.focus();
	  return;
   }
   if(strTmp.length < 4 || strTmp.length > 10){
      alert("ID´Â 4ÀÚÀÌ»ó 10ÀÚ±îÁö ÀÔ·Â°¡´ÉÇÕ´Ï´Ù.");
	  F.userid.value = "";
	  F.userid.focus();
	  return;
   }
   if(ascii_check(strTmp) < 0) {
	  alert("ID´Â 10ÀÚ ÀÌ³»·Î ¿µ¹®°ú ¼ýÀÚ·Î¸¸ »ç¿ëÇÏ½Ê½Ã¿À");
	  F.userid.value = "";
	  F.userid.focus();
	  return;
   }else{
      window.open('/inc/id_confirm.php?id='+strTmp,'SearchID','scrollbars=no,resizable=no,width=398,height=255');
   }
}

/******************************************************************************
*** ¹®ÀÚ Ã¼Å©
******************************************************************************/
function ascii_check(m_str){
   count = 0;
   for( i = 0 ; i < m_str.length ; i++){
	  buf = m_str.charAt(i);
	  if((buf >= 'A' && buf <= 'Z') || (buf >= 'a' && buf <= 'z') || (buf >= '0' && buf <= '9')){
		 count = count + 1;
	  }
	  else return -1;
   }
   return count;
}

/******************************************************************************
*** view, hidden
******************************************************************************/
function viewpall(n, txt, count){
  var txtn;
  var view;
  var view2;
  var count2 = parseInt(count)+1;
  for(i=1;i<count2;i++){
	txtn = txt+eval(i);
	view = eval("this.viewp"+txt+i);
	view2 = eval("this.viewpm"+i);
	if(n==txtn){
	   view.style.display = "none";
	   view2.style.display = "";
	}
	else{
	   view.style.display = "";
	   view2.style.display = "none";
	}
  }
}

/******************************************************************************
*** ¼ýÀÚ¸¸ ÀÔ·Â°¡´É
******************************************************************************/
function checknumber(x,frm){ 
	var anum=/(^\d+$)|(^\d+\.\d+$)/ 
	if (anum.test(x))
		testresult=true 
	else{ 
		alert("¼ýÀÚ¸¸ ÀÔ·Â ÇÏ¼¼¿ä");
		frm.value = "";
		frm.focus();
		testresult=false 
} 
	return (testresult) 
} 

function checkban(x,frm){ 
	if (document.layers||document.all||document.getElementById) 
		return checknumber(x,frm) 
	else 
		return true 
}

/******************************************************************************
*** ÀÌ¹ÌÁöÃ¢
******************************************************************************/
function winOPEN(url) {
	window.open('/inc/new_view.php?url='+url,'teacher','toolbar=no,menubar=no,status=no');
}