function fn_board_read_pop(asp_board_idx,board_content_idx)
{
	var f = document.getElementById("fAspBrdList_"+asp_board_idx);
	if(f == null)
	{
		var pop = window.open(indexFilePop+"?asp_board_idx="+asp_board_idx+"&board_content_idx="+board_content_idx,'boardpop','resizable=yes,scrollbars=yes');
		pop.focus();
	}
	else
	{
		f.sMode.value				= "";
		f.asp_board_idx.value		= asp_board_idx;
		f.board_content_idx.value	= board_content_idx;
		f.action = indexFilePop;
		var pop = window.open('','boardpop','resizable=yes,scrollbars=yes');
		f.target = "boardpop"; //"_blank";
		
		f.submit();
		pop.focus();
	}
}
function fn_board_read(asp_board_idx,board_content_idx)
{
	var f = document.getElementById("fAspBrdList_"+asp_board_idx);
	if(f == null)
	{
		location.href=indexFile+"?asp_board_idx="+asp_board_idx+"&board_content_idx="+board_content_idx;
	}
	else
	{
		f.sMode.value				= "";
		f.asp_board_idx.value		= asp_board_idx;
		f.board_content_idx.value	= board_content_idx;
		f.action = indexFile;//"/pages/";
		f.submit();
	}
}

function fn_board_list_more(asp_board_idx)
{
	if(asp_board_idx>0)
		location.href=indexFile+'?asp_board_idx='+asp_board_idx;
}

function fn_board_list(btnObj)
{
	if(btnObj == null)return;
	fn_board_list_post(btnObj,indexFile);
}

function fn_board_list_pop(btnObj)
{
	if(btnObj == null)return;
	fn_board_list_post(btnObj,indexFilePop);
}

function fn_board_list_post(btnObj,actionFile)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	
	f.sMode.value = "";
	if(f.board_content_idx != null)f.board_content_idx.value = "";
	
	f.action = actionFile;
	
	f.submit();

}


function fn_board_write(btnObj)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	
	f.sMode.value = "write";
	f.submit();
	//location.href="/pages/?asp_board_idx="+asp_board_idx+"&sMode=write";
}

function fn_board_edit(btnObj)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	
	f.sMode.value = "edit";
	f.submit();
	//location.href="/pages/?asp_board_idx="+asp_board_idx+"&board_content_idx="+board_content_idx+"&sMode=edit";
}

function fn_board_reply(btnObj)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	
	f.sMode.value = "reply";
	f.submit();
}

function fn_board_delete(btnObj)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	
	if(f.pAspBrdCt_passwd != null) /*Guest ÀÎ °æ¿ì*/
	{
		var board_content_idx = f.board_content_idx.value;
		var divPasswd = document.getElementById('dAspBrdCt'+board_content_idx);
		if(divPasswd == null)return;
		if(f.pAspBrdCt_passwd.value == "")
		{
			divPasswd.style.display = 'block';
			f.pAspBrdCt_passwd.focus();
			return;
		}
		else divPasswd.style.display = 'none';
	}
	
	if(confirm("Are you sure to delete ?"))
	{
		f.sMode.value="DELETE";
		f.action = "/pages/common/board/boardAction.php3";
		f.submit();
			//location.href="/pages/?asp_board_idx="+asp_board_idx+"&board_content_idx="+board_content_idx+"&sMode=DELETE";
	}
}

function fn_board_delete_cancel(btnObj)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	
	if(f.pAspBrdCt_passwd != null) /*Guest ÀÎ °æ¿ì*/
	{
		var board_content_idx = f.board_content_idx.value;
		var divPasswd = document.getElementById('dAspBrdCt'+board_content_idx);
		if(divPasswd == null)return;
		f.pAspBrdCt_passwd.value = "";
		divPasswd.style.display = "none";
	}
}

function fn_board_submit(btnObj)
{
	if(btnObj == null)return;
	var f = btnObj.form;
	if(f==null)return;
	if(!fn_validation(f))return;
	f.action = "/pages/common/board/boardAction.php3";
	f.submit();
}

function fn_board_paging(id_page,page,id_linecnt,linecnt)
{
	var arr 			= id_page.split("_");
	var asp_board_idx	= arr[1];

	var f = document.getElementById("fAspBrdList_"+asp_board_idx);
	if(f == null)return;
	
	var ctlPg = eval("f."+id_page);
	var ctlLn = eval("f."+id_linecnt);
	if(ctlPg == null || ctlLn == null)return;
	
	ctlPg.value = page;
	ctlLn.value = linecnt;
	
	f.sMode.value ="";
	f.board_content_idx.value ="";
	f.submit();
}

//TODO - test ÀÌÈÄ º°µµ ÆÄÀÏ·Î ºÐ¸® 20080720 By Sam Kim
function fn_tmpl_paging(id_page,page,id_linecnt,linecnt)
{
	var arr 			= id_page.split("_");
	var asp_tmpl_idx	= arr[1];

	var f = document.getElementById("fAspTmplList_"+asp_tmpl_idx);

	if(f == null)return;
	
	var ctlPg = eval("f."+id_page);
	var ctlLn = eval("f."+id_linecnt);
	if(ctlPg == null || ctlLn == null)return;
	ctlPg.value = page;
	ctlLn.value = linecnt;
	
	f.submit();
}
//
/**
  * ÆÄÀÏÃß°¡
  *
  * parameter : none
  * return : void
  */
 function addFileForm(){

  var tb1 = document.getElementById("div_board_atch_file");
  if(4 >= tb1.rows.length) {
   var idx = getObj().parentElement.rowIndex + 1;
   var trow= tb1.insertRow(idx);
   var uploadOBJ="<input name='addfile[]' type='file' id='board_atch_file_ctrl' class='board_atch_file_ctrl'> "
   				//+"<a OnClick='javascript:addFileForm();'>&nbsp;Ãß°¡</a>&nbsp;&nbsp;"
				+"<input type=button value='' class='board_atch_file_button_delete' OnClick='javascript:deleteRow();'> &nbsp;";
   trow.insertCell(0).innerHTML = uploadOBJ;
  } else {
   //alert("¹®¼­ÆÄÀÏÀº 5°³ ÀÌ»ó Á¢¼öÇÒ ¼ö  ¾ø½À´Ï´Ù.");
   alert("You can attach files up to 5");
   return;
  }
 }

 function getObj()
 {
     var obj = event.srcElement
     while (obj.tagName !='TD') //TD°¡ ³ª¿Ã¶§±îÁöÀÇ ObjectÃßÃâ
     {
         obj = obj.parentElement
     }
     return obj
 }

 /**
  * ÆÄÀÏ»èÁ¦
  *
  * parameter :
  * return : void
  */
 function deleteRow(){
  var tb1 = document.getElementById("div_board_atch_file");

  var idx = getObj().parentElement.rowIndex;

  if(tb1.rows.length-1 !=0){
   var tRow = tb1.deleteRow(idx);
  }else{
    document.getElementById('board_atch_file_ctrl').select();
       document.selection.clear();
  }
 }
 
 function fn_board_download(idx)
 {
 	var url = "/pages/common/file/fileAction.php3?idx="+idx;
 	var pop = window.open(url,'','width=0,height=0');
 	/*ajax Ã³¸® ¾ÈµÊ
	 	var f = fn_create_form('f_brd_dl','POST',url);
	 	var h = fn_create_hidden('idx',1111111111111111111);
	 	f.appendChild(h);
	 	ajaxSubmit(f,'callback');
 	*/
 }
