function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/******************************************************************************
*** ¿ìÆí¹øÈ£ Ã¢
******************************************************************************/
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.PENForm;
      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.PENForm;
     if(J1 =="111111" || J2 =="1111111"){
        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.PENForm;
    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.PENForm.registnum1.value;
        
        if(strjumin.substring(0,2) > "05"){
                document.PENForm.b_year.value = "19" + strjumin.substring(0,2);
		} else{
                document.PENForm.b_year.value = "20" + strjumin.substring(0,2);
        }
        bmonth_pos = strjumin.substring(2,4);
        bday_pos = strjumin.substring(4,6);
        
        document.PENForm.b_month.value = bmonth_pos;
        document.PENForm.b_day.value = bday_pos;
}

/******************************************************************************
*** ¾ÆÀÌµðÁßº¹ Ã¼Å©
******************************************************************************/
function IDcheck(){
   var F = document.PENForm;
   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 count2 = parseInt(count)+1;
  for(i=1;i<count2;i++){
	txtn = txt+eval(i);
	view = eval("this.viewp"+txt+i);
	if(n==txtn){
	   view.style.display = "";
	}
	else{
	   view.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,scrollbars=yes');
}

function winOPEN2(url) {
	window.open('/inc/new2_view.php?url='+url,'teacher','toolbar=no,menubar=no,status=no,scrollbars=yes');
}

/******************************************************************************
*** alertÃ¢
******************************************************************************/
function alertWin(val, f){
	alert(val+'À»(¸¦) ÀÔ·ÂÇÏ¼¼¿ä!');
	f.focus();
}

function goPage(val){
	var f = document.PAGEForm;

	f.page.value = val;
	f.submit();
}

function alertWin(val, f){
	alert(val+'À»(¸¦) ÀÔ·ÂÇÏ¼¼¿ä!');
	f.focus();
}

function textCounter(theField,theCharCounter,maxChars)
{
    var strCharCounter = 0;
    var intLength = theField.value.length;

    for (var i = 0; i < intLength; i++)
    {
		var charCode = theField.value.charCodeAt(i);

		if (charCode > 128)        {
		        strCharCounter += 2;
		} else {
		        strCharCounter++;
		}

		if(strCharCounter < (maxChars+1)) {
		        //theCharCounter.innerHtml = ;
		        theCharCounter.innerText = strCharCounter;
		                
		} else {
		        eval("alert('ÇÑ±Û" + maxChars/2 + ", ¿µ¹®" + maxChars+ "ÀÚ Á¦ÇÑÀÔ´Ï´Ù. ÃÊ°úµÈ ¹®ÀÚ´Â Àß¸³´Ï´Ù.')");
		        if(!cutStr(theField, i, theCharCounter, maxChars)) {
		                alert("¹®ÀÚ¿­ Ä¿Æ® ÇÔ¼ö°¡ ÀÛµ¿µÇÁö ¾Ê½À´Ï´Ù.");
		        }
		        break;
		}
    }
}


function PersonalInsertSub(){
	var f	= document.PENForm;

	if(f.name.value == "" || f.name.value == " "){
		alertWin('¼º¸í',f.name);
		return false;
	}
	if(f.registnum1.value == "" || f.registnum1.value == " "){
		alertWin('ÁÖ¹Îµî·Ï¹øÈ£',f.registnum1);
		return false;
	}
	if(f.registnum2.value == "" || f.registnum2.value == " "){
		alertWin('ÁÖ¹Îµî·Ï¹øÈ£',f.registnum2);
		return false;
	}
	if((f.registnum1.value != "" || f.registnum1.value != " ") && (f.registnum2.value != "" || f.registnum2.value != " ")){
		if(false == CheckBizNo()){
			return false;
		}
	}
	
	f.action	= "/inc/nc_p_new.php";
//	f.action	= "/inc/nc_p.php";
	f.submit();
}

function PersonalInsertSubaa(){

	if(document.PENForm.name.value == "" || document.PENForm.name.value == " "){
		alert('¼º¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä.');
		return;
	}
	if(document.PENForm.registnum1.value == "" || document.PENForm.registnum1.value == " "){
		alert('ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		return;
	}
	if(document.PENForm.registnum2.value == "" || document.PENForm.registnum2.value == " "){
		alert('ÁÖ¹Îµî·Ï¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
		return;
	}
	
	document.PENForm.submit();
}



/******************************************************************************
*** Input
******************************************************************************/
function InputEditSub(){
	var f	= document.fmParam;

	if(getEditCheck(f)) return;   //¿¡µðÅÍº»¹®Ã¼Å©
	/*
	if (f.useup.value != '0'){
		f.BB_FILE.value = getUploadFiles(); //¾÷·ÎµåÃ¼Å©
	}
	*/

	kjsSubmit('fmParam');
}

function InputSub(){
	kjsSubmit('fmParam');
}

function InputSurvSub(){

	kjsSubmit('fmParam2');
}

/******************************************************************************
*** Delete
******************************************************************************/
function DeleteListSub(val){
	var f = document.fmParam;
	var reset;

	reset=confirm("»èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?")
	if (reset==true){
		f.NU.value	= val;
		f.submit();
	}
}


function CheckSub(val, val2){
	var f		= document.PENForm;
	var reset;
	var txt;

	if(val == "MO")			txt	= "¼öÁ¤";
	else if(val == "DE")	txt	= "»èÁ¦";
	else if(val == "DE2")	txt	= "ÃëÇÏ";
	else if(val == "PO")	txt	= "¸¸Á·µµÅõÇ¥";

	reset=confirm(txt+"ÇÏ½Ã°Ú½À´Ï±î?")
	if (reset==true){
			if(f.passwd.value == "" || f.passwd.value == " "){
				alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
				f.passwd.focus();
				return;
			}
			//alert(document.getElementById('passwd').value);
			if(document.getElementById('passwd')) {
				if(document.getElementById('passwd').value == " " || document.getElementById('passwd').value.length < 1) {
					alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
					return false;
				}
			}
			if(document.getElementById('passwd2')) {
				if(document.getElementById('passwd2').value == " " || document.getElementById('passwd2').value.length < 1) {
					alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
					return false;
				}
			}

			f.mode.value= val;
			f.chk.value	= val2;
			
			//f.action = "/bbs/board/board1_send.php";
			f.submit();
	}
}


function CheckSub_F(val, val2){
	var f		= document.PENForm;
	var reset;
	var txt;

	if(val == "MO")			txt	= "modify";
	else if(val == "DE")	txt	= "delete";

	reset=confirm("Will you "+txt+" the content?")
	if (reset==true){
			if(f.passwd.value == "" || f.passwd.value == " "){
				alert('Check Password');
				f.passwd.focus();
				return;
			}

			f.mode.value= val;
			f.chk.value	= val2;
			
			//f.action = "/bbs/board/board1_send.php";
			f.submit();
	}
}

function resizeFrame(iframeObj){
    var innerBody = iframeObj.contentWindow.document.body;
    var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
    var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
    iframeObj.style.height = innerHeight;
    iframeObj.style.width = innerWidth;
}
