
/*
' ------------------------------------------------------------------
' Function    : addFile()
' Description : trÀ» ÇÏ³ª»ý¼ºÇÏ°í Ã·ºÎÆÄÀÏÀ» Ãß°¡ÇÑ´Ù.
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function addFile(length){
   var attachTable = document.getElementById("tblAttach");
   var attachRows  = attachTable.rows.length;
   if(attachRows == document.fzForm.limitCount.value){
       alert("Ã·ºÎÆÄÀÏ °¹¼ö°¡ "+attachRows+"·Î Á¦ÇÑ µÇ¾î ÀÖ½À´Ï´Ù.");
   }else{
     var attachTbody = attachTable.childNodes[0];
      var attachRow,attachCell;
      attachRow = document.createElement("TR");
      attachTbody.appendChild(attachRow);
      attachCell = document.createElement("TD");
      attachRow.appendChild(attachCell);
      attachCell.innerHTML = "<input type=\"file\" name=\"file[]\" size=\""+length+"\"  class=\"input\">";
      fzForm.hidCount.value = attachRows+1;
   
   }
   
}
/*
' ------------------------------------------------------------------
' Function    : delFile()
' Description : Å×ÀÌºíÀÇ row¸¦ »èÁ¦ÇÑ´Ù.
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function delFile(){
   var attachTable = document.getElementById("tblAttach");
   var attachRows  = attachTable.rows.length;
   var attachRowIndex = attachRows -1;
   if(attachRowIndex >= 1){
      attachTable.deleteRow(attachRowIndex);
   }   
}
/*
' ------------------------------------------------------------------
' Function    : hiddenFormCheck
' Description : ºñ¹Ð±Û Ã¼Å©½Ã ºñ¹Ð¹øÈ£ ÀÔ·ÂÆû
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function hiddenFormCheck(obj){
   var fm = document.fzForm;
   if(fm.hidden.checked == true){
   document.all[obj].style.visibility = 'visible';
   alert("ÀÐ±â½Ã È®ÀÎ¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä");
   fm.securityNum.focus();
   }else{
   fm.securityNum.value = "";
   document.all[obj].style.visibility = 'hidden';   
   }
}

/*
' ------------------------------------------------------------------
' Function    : formResize
' Description : 
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function formResize(obj, type, num){
	if(type == "add") obj.rows += num;
	if(type == "del" && obj.rows > 3) obj.rows -= num;
}

/*
' ------------------------------------------------------------------
' Function    : formResize
' Description : 
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function passwordForm(id){
    var indexID = "divID_" + id ;
	var indexIDM = "divID_modify";
	var indexIDD = "divID_delete";
	if (document.getElementById(indexID).style.display == "none"){ 
		if(id == "modify" && document.getElementById(indexIDD).style.display == "block"){
		  document.getElementById(indexIDD).style.display = "none" ;
		}
		if(id == "delete" && document.getElementById(indexIDM).style.display == "block"){
		  document.getElementById(indexIDM).style.display = "none" ;
		}
		document.getElementById(indexID).style.display = "block" ;
	}else{
        document.getElementById(indexID).style.display = "none" ;
	}
}

/*
' ------------------------------------------------------------------
' Function    : formResize
' Description : 
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function writeFormCk(){
	var fm = document.fzForm;
	var ep = /^([\w-]+@[\w-]{0,66}\.[A-Za-z]{2,6}(\.[A-Za-z]{2})?)$/;
	if(fm.name.value == ""){
		alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.name.focus();
		return false;
	}else if(fm.email.value != "" && !fm.email.value.match(ep)){
		alert("email°ªÀÌ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
		fm.email.focus();
		return false;
	}else if(fm.title.value == ""){
		alert("Á¦¸ñÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.title.focus();
		return false;
	}else if(fm.comment.value == ""){
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.comment.focus();
		return false;
	}else if(fm.callBack.checked==true &&  fm.email.value == ""){
		alert("È¸½Å emailÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.email.focus();
		return false;
	}else if(fm.password.value == ""){
		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.password.focus();
		return false;
	}else{
		fm.submit();
	}
}

/*
' ------------------------------------------------------------------
' Function    : formResize
' Description : 
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function commentFormCk(){
	var fm = document.fzForm;
	if(fm.comment.value == ""){
		alert("³»¿ëÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.comment.focus();
		return false;
	}else if(fm.commentLimit.value < fm.commentLength.value){
		alert("ÄÚ¸àÆ® ±æÀÌ°¡ ¼³Á¤°ªÀ» ÃÊ°ú ÇÏ¿´½À´Ï´Ù.");
		fm.comment.focus();
		return false;
	}else if(fm.name.value == ""){
		alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.name.focus();
		return false;
	}else if(fm.password.value == ""){
		alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.password.focus();
		return false;
	}else if(fm.spamPasswd.value == ""){
		alert("½ºÆÔ¹æÁö¿ë¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		fm.spamPasswd.focus();
		return false;
	}else{
		fm.submit();
	}
}
/*
' ------------------------------------------------------------------
' Function    : textLength
' Description : 
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/

function textLength(){
   var fm = document.fzForm
   var tmpStr;
   var tmpLen;
   tmpStr=fm.comment.value;
   tmpLen = textByte(tmpStr);
   fm.commentLength.value = tmpLen;
   if(fm.commentLimit.value < tmpLen){
      alert(fm.commentLimit.value);
	  alert(tmpLen);
	  alert("ÄÚ¸àÆ® ±æÀÌ°¡ ¼³Á¤°ªÀ» ÃÊ°ú ÇÏ¿´½À´Ï´Ù.");
	  return false;
   }
}
/*
' ------------------------------------------------------------------
' Function    : textByte
' Description : 
' Argument    : 
' Return      : 
' ------------------------------------------------------------------
*/
function textByte(aquery){
   var tmpStr;
   var temp=0;
   var onechar;
   var tcount=0;
   var line_count=0;

   tmpStr = new String(aquery);
   temp = tmpStr.length;

   for(k=0; k<temp; k++){
      onechar = tmpStr.charAt(k);
      if(escape(onechar).length > 4){
         tcount +=2;
         line_count +=2;
      }else if (onechar != '\r' && onechar != '\n'){
         tcount++;
         line_count++;
      }else if (onechar != '\n'){
         if(line_count < 16){
            temp2=16-line_count;
            tcount=tcount+temp2;
            temp2=0;
            line_count=0;
         }
      }
   }
    return tcount;
}
