function commentwrite(){

	if (cfm.comment.value == ""){
		alert("´ñ±ÛÀ» µî·ÏÇÏ¼¼¿ä");
		cfm.comment.focus();
	}else{
		cfm.submit();
	}

}


function del(num){

	if (confirm("Á¤¸» »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?"))
	{
		hfm.idx.value = num;
		hfm.submit();
	}

}

function search(){
	if (sfm.str.value == "")
	{
		alert("°Ë»ö´Ü¾î¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
		sfm.str.focus();
	}else{
		sfm.submit();
	}
}


// text area ¹®Àå Å©±â Ã¼Å©
function calc_length()
{
   var length = calculate_msglen(cfm.comment.value);
   textlimit.innerText = length;
   if (length > 240) {
       alert("ÃÖ´ë " + 240 + "byteÀÌ¹Ç·Î ÃÊ°úµÈ ±ÛÀÚ¼ö´Â ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.");
       cfm.comment.value = cfm.comment.value.replace(/\r\n$/, "");
       cfm.comment.value = assert_msglen(cfm.comment.value, 240);
   }
}
// <,>,\n µî ±âÈ£ ¹ÙÀÌÆ® Ã¼Å©
function calculate_msglen(message)
{
   var nbytes = 0;

   for (i=0; i<message.length; i++) {
       var ch = message.charAt(i);
       if(escape(ch).length > 4) {
           nbytes += 2;
       } else if (ch == '\n') {
           if (message.charAt(i-1) != '\r') {
               nbytes += 1;
           }
       } else if (ch == '<' || ch == '>') {
           nbytes += 4;
       } else {
           nbytes += 1;
       }
   }

   return nbytes;
}

// ¹®ÀÚ¿­ ÀÚ¸£±â
function assert_msglen(message, maximum)
{
   var inc = 0;
   var nbytes = 0;
   var msg = "";
   var msglen = message.length;

   for (i=0; i<msglen; i++) {
       var ch = message.charAt(i);
       if (escape(ch).length > 4) {
           inc = 2;
       } else if (ch == '\n') {
           if (message.charAt(i-1) != '\r') {
               inc = 1;
           }
       } else if (ch == '<' || ch == '>') {
           inc = 4;
       } else {
           inc = 1;
       }
       if ((nbytes + inc) > maximum) {
           break;
       }
       nbytes += inc;
       msg += ch;
   }
   textlimit.innerText = 240;
   return msg;
}

function imgpop(url,w,h){
	window.open("/learning/img_pop.asp?img="+url+"&imgwidth="+w+"&imgheight="+h,"","width="+w+",height="+h+",scrollbars=yes" );
}

function input_number()
{
	if( window.event.keyCode >= 48 && window.event.keyCode <= 57) {
	} else {
		window.event.keyCode = "";
	}
}

